ca7rmq
Last Updated: February 25, 2016
·
1.051K
· runexec
81609937c20aeab3598aea56f1f4f022

Shortest possible fibonacci sequence?

Clojure really shines with this example.

 user=> (def f (lazy-cat [0 1] (map + f (rest f))))
 #'user/f
user=> (take 10 f)
(0 1 1 2 3 5 8 13 21 34)
user=> 
Say Thanks
Respond

1 Response
Add your response

2125
2263e59b3b4f65895d0d3dd592f00662

Looks very similar to Haskell version:
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
http://www.haskell.org/haskellwiki/The_Fibonacci_sequence

over 1 year ago ·