Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
moomin
on March 10, 2018
|
parent
|
context
|
favorite
| on:
Tail Recursion Tactics: Fibonacci
The canonical zipWith solution is a thing of beauty.
cgmg
on March 10, 2018
[–]
I agree. The scanl version is even more elegant:
fibs = 0 : scanl (+) 1 fibs
Replacing 0 with 2 yields the Lucas numbers:
lucas = 2 : scanl (+) 1 lucas
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: