Haskell: Fibonacci in O(n) time
Inspired by: https://www.youtube.com/watch?v=_JtPhF8MshA&t=13m12s
Use https://repl.it/languages/haskell to run the code.\
A mind-blowing version I’ve seen:
fibs = Data.Function.fix $ (0:) . scanl (+) 1
fib = (fibs !!)
Inspired by: https://www.youtube.com/watch?v=_JtPhF8MshA&t=13m12s
Use https://repl.it/languages/haskell to run the code.\
A mind-blowing version I’ve seen:
fibs = Data.Function.fix $ (0:) . scanl (+) 1
fib = (fibs !!)
--
Maths, stats, econs / software, functional programming _ https://github.com/2jacobtan
Love podcasts or audiobooks? Learn on the go with our new app.