Can anyone explain why the time jumps by an order of magnitude simply by wrapping this in a function?
user> (time (loop [n 0 t 0] (if (= n 10000000) t (recur (inc n) (+ t n))))) "Elapsed time: 29.312145 msecs" 49999995000000 user> (defn tl [r] (loop [n 0 t 0] (if (= n r) t (recur (inc n) (+ t n))))) #<Var@54dd6004: #object[user$eval3462$tl__3463 0x7d8ba46 "user$eval3462$tl__3463@7d8ba46"]> user> (time (tl 10000000)) "Elapsed time: 507.333844 msecs" 49999995000000 I'm curious how a simply iteration like this can be made much faster. For example, a similar iterative loop in C++ takes less than 1 ms in Release mode, or about 20 ms in Debug mode on the same system as this Clojure code.