Skip to content

Instantly share code, notes, and snippets.

@mattyw
Created October 31, 2010 17:47
Show Gist options
  • Save mattyw/656896 to your computer and use it in GitHub Desktop.
Save mattyw/656896 to your computer and use it in GitHub Desktop.
An example from Bruce Tate's 7 languages in 7 weeks, Fib numbers in clojure. Try running this with (nth-fib 500). Very fast
(defn fib-pair [[a b]] [b (+ a b)])
(defn nth-fib [n]
"Return the nth fib number"
(nth (map first (iterate fib-pair [0 1])) n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment