Skip to content

Instantly share code, notes, and snippets.

@paavohuhtala
Created November 14, 2014 16:11
Show Gist options
  • Save paavohuhtala/b5bef62b11339eca4c04 to your computer and use it in GitHub Desktop.
Save paavohuhtala/b5bef62b11339eca4c04 to your computer and use it in GitHub Desktop.
selitys
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
{-|
0 : 1 : ... combines 0, 1 and the result of zipWith into an (infinite) list
(tail fibs) is functionally equivalent to fibs.Skip(1)
zipWith takes a function and two (infinite) lists as arguments
it creates an (infinite) list by lazily applying the function to every item of both lists
meta-c#:
IEnumerable<int> Fibonacci()
{
yield 0;
yield 1;
while(true)
{
yield Fibonacci() + Fibonacci().Skip(1);
}
}
-}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment