Skip to content

Instantly share code, notes, and snippets.

@selfawaresoup
Last active September 8, 2015 22:32
Show Gist options
  • Save selfawaresoup/2cd58929c81d128f7f02 to your computer and use it in GitHub Desktop.
Save selfawaresoup/2cd58929c81d128f7f02 to your computer and use it in GitHub Desktop.
fibonacci numbers in clojure, lazily evaluated, using thread macros
(defn fib [n]
(->>
(->
(fn [[a b]] [b (+' a b)])
(iterate [1 1]))
(map first)
(take n)))
(fib 5) ;; (1 1 2 3 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment