Iterator -> Iterable

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@12445 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
michelou 2007-07-27 14:54:11 +00:00
parent 5466e68c7d
commit a428b37140
1 changed files with 3 additions and 3 deletions

View File

@ -28,10 +28,10 @@ object fors {
def isPrime(n: Int) = divisors(n).length == 2
def findNums(n: Int): Iterator[Pair[Int, Int]] =
def findNums(n: Int): Iterable[(Int, Int)] =
for (i <- 1 until n;
j <- 1 until (i-1);
if isPrime(i+j)) yield Pair(i, j)
if isPrime(i+j)) yield (i, j)
def sum(xs: List[Double]): Double =
xs.foldLeft(0.0) { (x, y) => x + y }
@ -99,7 +99,7 @@ object fors {
println("divisors(34) = " + divisors(34))
print("findNums(15) =");
findNums(15) foreach { x => Console.print(" " + x); }
findNums(15) foreach { x => print(" " + x); }
println
val xs = List(3.5, 5.0, 4.5)