Programming

(Clojure) Fibonacci Numbers

steloflute 2012. 9. 14. 23:30
(defn fib
  ([] (fib 1 1))
  ([a b] (cons a (lazy-seq (fib b (+ a b))))))

(println (take 5 (fib)))

(1 1 2 3 5)

'Programming' 카테고리의 다른 글

Continuation-passing style (CPS)  (0) 2012.09.17
Semicolons in JavaScript are optional  (0) 2012.09.15
Using the XML HTTP Request object  (0) 2012.09.14
Clojure: The zombie-reanimated corpse of Lisp | imagine27  (0) 2012.09.14
(Racket) (system)  (0) 2012.09.12