(no subject)

Dec 01, 2012 17:51


имхо это идиотизм

scala> for (i <- 1 to 3) yield i
res0: scala.collection.immutable.IndexedSeq[Int] = Vector(1, 2, 3)

scala> for (i <- (1 to 3).toList) yield i
res1: List[Int] = List(1, 2, 3)

scala> for (i <- (1 to 3).toList; j <- 1 to 3) yield (i, j)
res4: List[(Int, Int)] = List((1,1), (1,2), (1,3), (2,1), (2,2), (2,3), (3,1), (
3,2), (3,3))

scala> for (i <- (1 to 3); j <- 1 to 3) yield (i, j)
res5: scala.collection.immutable.IndexedSeq[(Int, Int)] = Vector((1,1), (1,2), (
1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3))

scala> for (i <- (1 to 3); j <- (1 to 3).toList) yield (i, j)
res6: scala.collection.immutable.IndexedSeq[(Int, Int)] = Vector((1,1), (1,2), (
1,3), (2,1), (2,2), (2,3), (3,1), (3,2), (3,3))
Previous post Next post
Up