n is stored in a var and thus boxed. You can cast it to primitive long with (long n).
On Tuesday, November 1, 2011, redraiment <redraim...@gmail.com> wrote: > Hi all, > > My environment is, Kubuntu 11.10, Clojure v1.3 and sun-java6-jdk. I > issued the following forms in REPL: > > user=> (def n 100000000) > #'user/n > user=> (time (loop [cnt 100000000 sum 0] (if (zero? cnt) sum (recur > (dec cnt) (+ sum cnt))))) > "Elapsed time: 605.564858 msecs" > 5000000050000000 > user=> (time (loop [cnt n sum 0] (if (zero? cnt) sum (recur (dec cnt) > (+ sum cnt))))) > "Elapsed time: 3707.245668 msecs" > 5000000050000000 > > Why did the second loop so slow?! > > Thanks! > > -- > 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 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