Ah, brilliant, many thanks Laurent!
Interesteresting stuff under the hood ..
Kind regards, alux
Laurent PETIT schrieb:
> hi, follow links from here:
> http://www.infoq.com/news/2009/12/clojure-11-rc1-transients
>
> chunked sequences have their first elements realized in advanced by
> packets of
hi, follow links from here:
http://www.infoq.com/news/2009/12/clojure-11-rc1-transients
chunked sequences have their first elements realized in advanced by
packets of 32
Under the hoods, it seems that range uses chunked sequences (
http://github.com/richhickey/clojure/blob/master/src/clj/clojure/
Yes, chunked sequences explain the behaviour, look:
1:1 user=> (set! *print-length* 10)
10
1:2 user=> (defn fib0
[n]
(let [fib (fn fib [n] (if (< n 1) 1 (+ (fib (- n 1)) (fib (- n 2)]
(println (str "fib0[" n "]"))
(fib n)))
#'user/fib0
1:7 user=> (time (map fib0 (iterate inc 0)))
"
Laurent,
> Could chunked seqs explain something here ?
sounds possible. If I only knew what this is ;-)
Regards, alux
Laurent PETIT schrieb:
> 2010/3/19 alux :
> > ;-)
> >
> > Still, I dont believe.
> >
> > I get the same difference with
> >
> > user=> (time (map fib0 (range 100)))
> > "Elapsed
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)))
"El
Hi,
On Mar 19, 1:39 pm, alux 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)))
> "Elaps
2010/3/19 alux :
> ;-)
>
> Still, I dont believe.
>
> 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
;-)
Still, I dont believe.
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 ...)
Hm.
Regards, al
Hi,
On Mar 19, 12:34 pm, alux wrote:
> You didnt try this, as I can judge, because you responded in finite
> time ;-)
Ah, yes. Intersperse with (take 10 ...) at will. :)
> My main irritation is still: Why do my range and my iterate version
> differer in their print beheavior?
Because with ran
You didnt try this, as I can judge, because you responded in finite
time ;-)
(fib0 35) takes 20 seconds already. So your suggestion
(time (doall (map fib0 (range 100)))
will do all up to 100, time it, and print the first ten, in that
order. (fib0 100) takes a good while (I just estimaded 15 mill
Hi,
On Mar 19, 11:27 am, alux wrote:
> user=> (time (fib0 35))
> "Elapsed time: 20874.18345 msecs"
> 24157817
>
> user=> (time (map fib0 (iterate inc 1)))
> "Elapsed time: 0.913524 msecs"
> (2 3 5 8 13 21 34 55 89 144 ...)
>
> Everything fine.
> Now what puzzles me:
>
> user=> (time (map fib0 (r
11 matches
Mail list logo