Created
March 28, 2009 11:20
-
-
Save lenst/87088 to your computer and use it in GitHub Desktop.
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
;; My take on Fibonacci numbers | |
(defn gen-fibo [] | |
(let [fibo (atom nil)] | |
(reset! fibo (lazy-cat [0 1] (lazy-seq (map + @fibo (rest @fibo))))))) | |
(def fib (proxy [clojure.lang.Seqable] [] | |
(seq [] (gen-fibo)))) | |
user> (take 10 fib) | |
(0 1 1 2 3 5 8 13 21 34) | |
user> (nth (seq fib) 10000) | |
336447648764..59947366875 ; 2067 digits | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment