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) a (fibr (-n 1) b (+ a b)))) (fibr n 0 1)) (define (test n) (do ((i 0 (+ i 1))) ((= i n) 'done) (fib i)))
And the results:
> (time (test 4500)) 00:00:02.5623016 done
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.