Created
July 6, 2011 07:53
-
-
Save jameskeane/1066772 to your computer and use it in GitHub Desktop.
C++0x lazy list example
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
LazyList<int> fibonacci([](unsigned int index, LazyList<int> *obj) -> int | |
{ | |
if(index < 2) return index; | |
return (*obj)[index-1] + (*obj)[index-2]; | |
}); | |
/* Print the first 20 fibonacci numbers */ | |
for(int i = 0; i < 20; i++) | |
printf("%d ", fibonacci[i]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment