Meikel, you are right, I changed horses, uh, definitions inbetween. So the REPL interaction of my last response should read
Clojure 1.1.0 user=> (set! *print-length* 10) 10 user=> (defn fib0 [n] (if (< n 1) 1 (+ (fib0 (- n 1)) (fib0 (- n 2))))) #'user/fib0 user=> (time (map fib0 (range 100))) "Elapsed time: 1.979022 msecs" (1 2 3 5 8 13 21 34 55 89 ...) user=> (time (map fib0 (iterate inc 0))) "Elapsed time: 0.969677 msecs" (1 2 3 5 8 13 21 34 55 89 ...) user=> Despite this, the text I wrote seems still valid to me; note that I changed the start point for the iterate as response to your mail. Thats why now both starts with 0 as argument, and 1 as result. But the range one waits some five sec, the iterate doesnt. Sorry for the confusion. And thanks for the patience ;-) Kind regards, alux PS.: A correct Fibonacci sequence would use (< n 2) instead of (< n 1). Just to mention it. Meikel Brandmeyer schrieb: > Hi, > > On Mar 19, 1:39 pm, alux <alu...@googlemail.com> wrote: > > > Still, I dont believe. > > You should... > > > > > I get the same difference with > > > > user=> (time (map fib0 (range 100))) > > "Elapsed time: 1.916445 msecs" > > > > more than 5 seconds > > > > (0 1 1 2 3 5 8 13 21 34 ...) > > > > user=> (time (map fib0 (iterate inc 0))) > > "Elapsed time: 0.104203 msecs" > > (0 1 1 2 3 5 8 13 21 34 ...) > > How does this fit to following? > > > user=> (time (map fib0 (iterate inc 1))) > > "Elapsed time: 0.913524 msecs" > > (2 3 5 8 13 21 34 55 89 144 ...) > ^^^ > > The example you posted can't be. With the fib0 you posted you get: > > (fib0 0) => 1 > (fib0 1) => (+ (fib0 0) (fib0 -1)) => (+ 1 1) => 2 > > So what you posted above can't be true. At least not with the fib0 you > gave in your original post. > > Sincerely > Meikel -- 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 To unsubscribe from this group, send email to clojure+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.