Last active
September 8, 2015 22:32
-
-
Save selfawaresoup/2cd58929c81d128f7f02 to your computer and use it in GitHub Desktop.
fibonacci numbers in clojure, lazily evaluated, using thread macros
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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