Next: Tak, Previous: div-iter and div-rec, Up: Benchmark Sources [Contents][Index]
;;; C optimiser should be able to remove the first recursive call to
;;; move-them. But Solaris 2.4 cc, gcc 2.5.8, and hobbit don't.
(define (hanoi n)
(letrec ((move-them
(lambda (n from to helper)
(if (> n 1)
(begin
(move-them (- n 1) from helper to)
(move-them (- n 1) helper to from))))))
(move-them n 0 1 2)))