Lazy infinite sequences in Clojure and Python

clojure, python

Solution

I like:

(def fibs 
  (map first 
       (iterate 
           (fn [[ a, b       ]]  
                [ b, (+ a b) ]) 
           [0, 1])))     

Which seems to have some similarities to the python/generator version.

Problem

Here are the best implementations I could find for lazy infinite sequences of Fibonacci numbers in both Clojure and Python: Clojure: ``` (def fib-seq (lazy-cat [0 1] (map + fib-seq (rest fib-seq)))) ``` sample usage: ``` (take 5 fib-seq) ``` Python: ``` def fib(): a = b = 1 while True: yield a a,b = b,a+b ``` sample usage: ``` for i in fib(): if i > 100: break else: print i ``` Obviously the Python code is much more intuitive. My question is: Is there a better (more intuitive and simple) implementation in Clojure ? Edit I'm opening a follow up question at Clojure Prime Numbers

Original source