Created
September 22, 2014 08:22
-
-
Save siosio/5348fc2bf0f2272f69ef to your computer and use it in GitHub Desktop.
This file contains 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
package fibo | |
fun fibo(max:Int):Stream<Pair<Int, Int>> { | |
return stream(Pair(0, 1)) { | |
val next = it.first + it.second | |
if (next < max) { | |
Pair(it.second, next) | |
} else { | |
null | |
} | |
} | |
} | |
fun main(args:Array<String>) { | |
fibo(10000).forEach {print("${it.first} ")} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment