Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

In Clojure you can generate the Fibonacci sequence with

(def fibs (lazy-cat [0N 1N] (map + fibs (rest fibs))))

which is an example of (memory consuming) corecursion that I managed to sneak into two recent articles:

http://arstechnica.com/science/2014/05/scientific-computings...

and

http://lee-phillips.org/lispmath/

(I did not come up with this.)



Similarly in Haskell:

  fibs = 1:1:zipWith (+) fibs (tail fibs)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: