Skip to content

Instantly share code, notes, and snippets.

@jameskeane
Created July 6, 2011 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameskeane/1066772 to your computer and use it in GitHub Desktop.
Save jameskeane/1066772 to your computer and use it in GitHub Desktop.
C++0x lazy list example
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