Here is an experiment to figure out what causes the problem. If this is an 
issue of the lazy sequence, then this code should be equally bad:

(defn lazy-seq-fibo
  ([]
     (concat [0 1] (lazy-seq-fibo 0N 1N)))
  ([a b]
     (let [n (+ (mod a 1000) (mod b 1000))]      
       (lazy-seq                       
        (cons n (lazy-seq-fibo b n))))))

Instead of the real Fibonacci number, we can use the modulus to get the 
same result, i.e. instead of a + b, we use (a mod 1000) + (b mod 1000).

Now we get:

user=> (time (rem (nth (lazy-seq-fibo) 1000000) 1000))

"Elapsed time: 201.592 msecs"

875N

Thus  it is not the lazy sequence. As mentioned by others, it is the big 
integer addition.  

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to