Posted by: leppie | November 30, 2007

IronScheme joins the fib smokers

You can read the story up to the build up here .

Now IronScheme comes to the party.

(define (fib n)
  (define (fibr n a b)
    (if (= n 0)
        (fibr (-n 1) b (+ a b))))
  (fibr n 0 1))

(define (test n)
    ((i 0 (+ i 1)))
    ((= i n) 'done)
    (fib i)))

And the results:

> (time (test 4500))

2.5 secs, eat this SBCL 🙂 Obviously IronScheme is completely tail-recursive. The only problem is the lack of big numbers, or rather the promotion to big numbers. I will work on it this weekend and post some updated numbers.



  1. Out of curiosity, how much time would it take to print out the results of each call to fib? It looks like that’s what the SBCL implementation does. On my machine, the SBCL version with format took 11.376 sec of real time. Once I comment out the format call, it reports 0.0 sec of real time up.

    But aren’t benchmarks fun?

  2. OK 🙂

    Now I get 13.37 seconds with printing. Just had to implement some transitions for bignumbers (i am sure that helped a ‘little’).

  3. HAHA, by minimizing the console , I can get it down to 8.3 seconds :p

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s


%d bloggers like this: