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


_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to