summaryrefslogtreecommitdiff
path: root/docs/examples/iterators.scala
diff options
context:
space:
mode:
authormichelou <michelou@epfl.ch>2007-05-16 13:30:30 +0000
committermichelou <michelou@epfl.ch>2007-05-16 13:30:30 +0000
commit1f65685c9626929f3e6d7b81225f57fd4e68438c (patch)
tree54d3462ca86d36545ab6ef946a1095a0f15ac38f /docs/examples/iterators.scala
parent73b2db5db4fc7316467b51299994b47065bde74d (diff)
downloadscala-1f65685c9626929f3e6d7b81225f57fd4e68438c.tar.gz
scala-1f65685c9626929f3e6d7b81225f57fd4e68438c.tar.bz2
scala-1f65685c9626929f3e6d7b81225f57fd4e68438c.zip
updated examples
Diffstat (limited to 'docs/examples/iterators.scala')
-rw-r--r--docs/examples/iterators.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/examples/iterators.scala b/docs/examples/iterators.scala
index b390f4007a..4f4aa79f28 100644
--- a/docs/examples/iterators.scala
+++ b/docs/examples/iterators.scala
@@ -1,16 +1,16 @@
-package examples;
+package examples
object iterators {
def Array(elems: Double*): Array[Double] = {
val ar = new Array[Double](elems.length)
- for (i <- Iterator.range(0, elems.length))
+ for (i <- 0 until elems.length)
ar(i) = elems(i)
ar
}
def printArray(xs: Array[Double]) =
- Iterator.fromArray(xs) foreach { x => Console.println(x) }
+ Iterator.fromArray(xs) foreach { x => println(x) }
def findGreater(xs: Array[Double], limit: Double) =
Iterator.fromArray(xs)
@@ -18,10 +18,10 @@ object iterators {
.filter{case Pair(x, i) => x > limit }
.map{case Pair(x, i) => i}
- def main(args: Array[String]): Unit = {
+ def main(args: Array[String]) {
val ar = Array/*[Double]*/(6, 2, 8, 5, 1)
printArray(ar)
- Console.println("Elements greater than 3.0:")
+ println("Elements greater than 3.0:")
findGreater(ar, 3.0) foreach { x => Console.println(ar(x)) }
}