Created
February 10, 2017 14:36
-
-
Save clemp6r/ef55749255284038a3660250e0a444eb to your computer and use it in GitHub Desktop.
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
// inferred type is Sequence<Int> | |
val fibonacci = buildSequence { | |
yield(1) | |
var cur = 1 | |
var next = 1 | |
while (true) { | |
yield(next) | |
val tmp = cur + next | |
cur = next | |
next = tmp | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment