kernelthread.com

Common Lisp

The Towers of Hanoi implemented in Common Lisp.

;; ;; The Towers Of Hanoi ;; Common Lisp ;; Copyright (C) 1998 Amit Singh. All Rights Reserved. ;; http://hanoi.kernelthread.com ;; ;; Last tested under GNU Common Lisp (gcl) 2.5.3 ;; Load this file in gcl using `gcl -load <thisfile>' ;; Then invoke the hanoi function as follows: ;; (hanoi N) ;; where N is replaced by an integer (defun dohanoi(n to from u) (cond ( (> n 0) (dohanoi (- n 1) u from to) (format t "move ~D --> ~D~&" from to) (dohanoi (- n 1) to u from) ) ) ) (defun hanoi(n) (dohanoi n 3 1 2) )

Download

hanoi.gcl