diff options
author | michelou <michelou@epfl.ch> | 2004-01-08 19:10:55 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2004-01-08 19:10:55 +0000 |
commit | f5919ef574e6d6cbdf96835db6f53ea80dca0991 (patch) | |
tree | 3a5d86d07a771e2456edb6b4969cb78a2de735bb /sources/examples | |
parent | 2f487fd928d6ceb83b04c890e57ba2f0f71af6d9 (diff) | |
download | scala-f5919ef574e6d6cbdf96835db6f53ea80dca0991.tar.gz scala-f5919ef574e6d6cbdf96835db6f53ea80dca0991.tar.bz2 scala-f5919ef574e6d6cbdf96835db6f53ea80dca0991.zip |
- now uses the Array function to initialize an ...
- now uses the Array function to initialize an array.
Diffstat (limited to 'sources/examples')
-rw-r--r-- | sources/examples/iterators.scala | 3 | ||||
-rw-r--r-- | sources/examples/sort.scala | 5 |
2 files changed, 3 insertions, 5 deletions
diff --git a/sources/examples/iterators.scala b/sources/examples/iterators.scala index 7936e413da..3f2ddbb0be 100644 --- a/sources/examples/iterators.scala +++ b/sources/examples/iterators.scala @@ -12,8 +12,7 @@ object iterators { .map{case Pair(x, i) => i} def main(args: Array[String]) = { - val xs: List[Double] = List(6, 2, 8, 5, 1); - val ar = xs.copyToArray(new Array[Double](xs.length), 0); + val ar = Array[Double](6, 2, 8, 5, 1); printArray(ar); Console.println("Elements greater than 3.0:"); findGreater(ar, 3.0) foreach { x => Console.println(ar(x)); } diff --git a/sources/examples/sort.scala b/sources/examples/sort.scala index 2c3c3666a5..38a9755774 100644 --- a/sources/examples/sort.scala +++ b/sources/examples/sort.scala @@ -34,12 +34,11 @@ object sorter { ar(i) + (if (i < ar.length-1) "," + iter(i+1) else ""); if (ar.length == 0) "" else iter(0) } - Console.println("[" + print1 + "]"); + Console.println("[" + print1 + "]") } def main(args: Array[String]) = { - val xs = List(6, 2, 8, 5, 1); - val ar = xs.copyToArray(new Array[Int](xs.length), 0); + val ar = Array(6, 2, 8, 5, 1); println(ar); sort(ar); println(ar) |