Created
February 7, 2014 13:55
-
-
Save bstrie/8862964 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
use std::iter::Unfold; | |
fn next(arg: &mut (int, int)) -> Option<int> { | |
let (lo, hi) = *arg; | |
*arg = (hi, lo + hi); | |
Some(lo) | |
} | |
fn main() { | |
for fib in Unfold::new((0,1), next).take(20) { | |
println!("{}", fib); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment