3 ms·
Why do you need so many lines? fib = 1 : zipWith (+) (0 : fib) fib
by eru 6y ago
Why do you need so many lines?
fib = 1 : zipWith (+) (0 : fib) fib
- exdsq 6y agoBecause the three liner is easier to read
- eru 6y agoBtw, which three-liner do you mean?
- deleted 6y ago[deleted]
- exdsq 6y agofib 0 = 0 fib 1 = 1 fib n = fib (n-1) + fib (n-2)
- eru 6y agoOh, that version takes exponential time to compute. The one-liner I gave computes up to the n-th Fibonacci number in linear time.