chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Good way to code the equivalent to this?


From: Elf
Subject: Re: [Chicken-users] Good way to code the equivalent to this?
Date: Sun, 24 Aug 2008 03:47:55 -0700 (PDT)


my solution :)  its faster (at least on chicken 3.3.something).
timing on this box put this at just under 8s.

-elf

---

(use extras)

(print "filling ...")

(define a
    (alist->hash-table
        (let loop ((i   0))
            (if (fx= 250000 i)
                '()
                (cons (cons (random 500000) (random 500000))
                      (loop (fx+ 1 i)))))
        =))

(print "reading ...")

(define hits
    (let loop ((i   0)
               (r   0))
        (if (fx= i 10000)
            r
            (if (fx= (random 500000)
                     (hash-table-ref/default a (random 500000) -1))
                (loop (fx+ 1 i) (fx+ 1 r))
                (loop (fx+ 1 i) r)))))

(print "done.")







reply via email to

[Prev in Thread] Current Thread [Next in Thread]