Created
October 31, 2014 19:59
-
-
Save takscape/a23391aec1b7e4a31863 to your computer and use it in GitHub Desktop.
Fibonacci Sequence in Kotlin (5)
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
import java.math.BigInteger | |
import kotlin.math.plus | |
fun main(args: Array<String>) { | |
fibo().take(10).forEach { println(it.first) } | |
} | |
private fun fibo() = | |
stream(BigInteger.ZERO to BigInteger.ONE, {(e) -> | |
e.second to (e.first plus e.second) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is rewrite in current Kotlin: