Hello,

There's something I don't understand : I've used this code :
(ns clojure.examples.createfn)
(defn create-fn []
  (fn [] (println "hi")))

(defn test-create-fn [n]
  (time (dotimes [x n]
          (create-fn))))

and made these tests :

user=> (require 'clojure.examples.createfn :reload)
nil
user=> (clojure.examples.createfn/test-create-fn 40000000)
"Elapsed time: 356.096374 msecs"
nil
user=> (clojure.examples.createfn/test-create-fn 4000000000)
"Elapsed time: 0.013218 msecs"
nil

When I call test-create-fn with 4000000000, the elapsed time falls down to
zero : I suspect it does nothing, and in the same time it does not seem to
correctly crash by throwing an exception ?

I've tested the correct handling of that high numeric values by clojure, it
sounds ok :
user=> (println 4000000000)
4000000000
nil
user=> (dec 4000000000)
3999999999


Can someone explain me what happens here ?

2009/2/18 David Nolen <dnolen.li...@gmail.com>

> new MBP 2.53ghz
>
> (defn create-fn []
>   (fn [] (println "hi")))
>
> (time (dotimes [x 40000000]
>     (create-fn)))
>
> > "Elapsed time: 1034.409 msecs"
>
> Hopefully you don't need 40,000,000 functions in less than a second ;)
>
> On Wed, Feb 18, 2009 at 1:16 AM, CuppoJava <patrickli_2...@hotmail.com>wrote:
>
>> (defn create_fn []
>>  (fn [] (println "hi")))
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to