Writing your own infinite series - oliyh/learning-clojure GitHub Wiki
Fibonnaci
The Fibonnaci sequence is a sequence of numbers where the nth number is calculated as the sum of the n-2th and n-1th numbers. Therefore given a sequence of two numbers we can calculate the next one.
This function returns joined sequences, where each sequence contains the next value and a lazy pointer to a function that will calculate the value afterwards.
[1 -> [1 -> [2 -> [3 -> [5 -> [8 -> ...
(defn fib
([] (fib [1 1]))
([s] (cons (first s) (lazy-seq (fib [(last s) (+ (first s) (last s))])))))