Created
November 14, 2014 16:11
-
-
Save paavohuhtala/b5bef62b11339eca4c04 to your computer and use it in GitHub Desktop.
selitys
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
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