Created
October 30, 2012 08:30
-
-
Save gkojax/3978981 to your computer and use it in GitHub Desktop.
フィボナッチを書いたんだけどprintlnの位置が気に入らない
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val op: Pair[BigInt, BigInt] = Pair(1, 1) | |
(0 until 10).foldLeft(op) { (ab, x) => | |
println(ab._1) | |
Pair[BigInt, BigInt](ab._2, ab._2 + ab._1) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val op: Pair[BigInt, BigInt] = Pair(1, 1) | |
(0 until 10).scanLeft(op) { (ab, x) => | |
Pair[BigInt, BigInt](ab._2, ab._2 + ab._1) | |
}.foreach { x => | |
println(x._1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
scanLeftをおすすめされた結果。