diff options
Diffstat (limited to 'tests/run')
-rw-r--r-- | tests/run/inlineForeach.scala | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/run/inlineForeach.scala b/tests/run/inlineForeach.scala new file mode 100644 index 000000000..0c6135c6d --- /dev/null +++ b/tests/run/inlineForeach.scala @@ -0,0 +1,44 @@ +object Test { + + class Range(from: Int, end: Int) { + + inline + def foreach(inline op: Int => Unit): Unit = { + var i = from + while (i < end) { + op(i) + i += 1 + } + } + + def filter(p: Int => Boolean): List[Int] = ??? + } + + implicit class intWrapper(private val start: Int) extends AnyVal { + def until(end: Int) = new Range(start, end) + def to(limit: Int) = new Range(start, limit + 1) + }/* + + def matmul(xs: Array[Array[Double]], ys: Array[Array[Double]]): Array[Array[Double]] = { + def nrows = xs.length + def ncols = ys(0).length + def n = ys.length + assert(xs(0).length == n) + val zs = Array.ofDim[Double](nrows, ncols) + for (i <- intWrapper(0) until nrows) + for (j <- 0 until ncols) { + var x = 0.0 + for (k <- 0 until n) + x += xs(i)(k) * ys(k)(j) + zs(i)(j) = x + } + zs + } +*/ + def main(args: Array[String]) = { + /* 1.until(10).foreach(i => println(i)) + 1.until(10).foreach(println(_))*/ + 1.until(10).foreach(println) + for (i <- 1 to 10) println(i) + } +} |