Created
September 3, 2018 08:19
-
-
Save berdario/870eebc06beee7a87da5d99a63071e2b to your computer and use it in GitHub Desktop.
expansion of a recursive fibs impl
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
scanl f q ls = q : (case ls of | |
[] -> [] | |
x:xs -> scanl f (f q x) xs) | |
fibs = 1 : scanl (+) 1 fibs | |
1 : 1 : (case fibs of | |
[] -> [] | |
x:xs -> scanl (+) ((+) 1 x) xs) | |
# fibs is not [] | |
# x:xs becomes 1:fibs | |
1 : scanl (+) ((+) 1 1) fibs | |
1 : scanl (+) 2 fibs | |
1 : 2 : (case fibs of | |
[] -> [] | |
x:xs -> scanl (+) ((+) 2 x) xs) | |
2 : scanl (+) ((+) 2 1) fibs | |
2 : scanl (+) 3 fibs | |
2 : 3 : (case fibs of | |
[] -> [] | |
x:xs -> scanl (+) ((+) 3 x) xs) | |
3 : scanl (+) ((+) 3 2) fibs | |
3 : scanl (+) 5 fibs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment