Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Why is learning functional programming so damned hard? (2019). Parent comment
fib(N) when ... -> fib(N - 2, fib(0) + fib(1), fib(1)).
Then you can check for N = 0 to return Current, and do N - 1 in the iteration. One less value to pass in each recursion should make it faster, and it's less to think about.
There are no comments on this comment yet.
fib(N) when ... -> fib(N - 2, fib(0) + fib(1), fib(1)).
Then you can check for N = 0 to return Current, and do N - 1 in the iteration. One less value to pass in each recursion should make it faster, and it's less to think about.