Skip to content

Instantly share code, notes, and snippets.

@jameskeane
Created July 6, 2011 07:53
Show Gist options
  • 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