diff options
author | michelou <michelou@epfl.ch> | 2003-12-08 16:17:42 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2003-12-08 16:17:42 +0000 |
commit | 5e87c33e2aaec7a0c9bcd6f257a9a8e4f9664529 (patch) | |
tree | 941571431fef1a7273ea82fa2475b99d35ba66ca /sources/examples/iterators.scala | |
parent | 103888d458fe8cc0ba7c8000c9e2b66923a1b430 (diff) | |
download | scala-5e87c33e2aaec7a0c9bcd6f257a9a8e4f9664529.tar.gz scala-5e87c33e2aaec7a0c9bcd6f257a9a8e4f9664529.tar.bz2 scala-5e87c33e2aaec7a0c9bcd6f257a9a8e4f9664529.zip |
- adapted to current Scala version
Diffstat (limited to 'sources/examples/iterators.scala')
-rw-r--r-- | sources/examples/iterators.scala | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sources/examples/iterators.scala b/sources/examples/iterators.scala index 8eae9fb026..958934e65e 100644 --- a/sources/examples/iterators.scala +++ b/sources/examples/iterators.scala @@ -1,6 +1,6 @@ -module iterators { +object iterators { - def printArray(xs: Array[Int]) = + def printArray(xs: Array[Double]) = Iterator.fromArray(xs) foreach (x => System.out.println(x)); def findGreater(xs: Array[Double], limit: Double) = @@ -9,4 +9,11 @@ module iterators { .filter{case Pair(x, i) => x > limit} .map{case Pair(x, i) => i} + def main(args: Array[String]) = { + val xs = List(6, 2, 8, 5, 1); + val ar = xs.copyToArray(new Array[Double](xs.length), 0); + printArray(ar); + findGreater(ar, 3.0) foreach { x => Console.print(x); }; + } + } |