|
From: | Tobia Conforto |
Subject: | Re: [Chicken-users] Good way to code the equivalent to this? |
Date: | Mon, 25 Aug 2008 11:12:42 +0200 |
Elf wrote:
(define a (alist->hash-table (let loop ((i 0)) (if (fx= 250000 i) '() (cons (cons (random 500000) (random 500000)) (loop (fx+ 1 i))))) =))for an improvement in time (surprisingly), use (define a (alist->hash-table (let loop ((i 0) (r '())) (if (fx= 250000 i) r (loop (fx+ 1 i) (cons (cons (random 500000) (random 500000)) r)))) =)) ...there are a lot more minor GCs this way
Why is it surprising that the tail-recursive version performs better? And why do you say it has more GC? Isn't it supposed to produce less garbage?
Tobia
[Prev in Thread] | Current Thread | [Next in Thread] |