blob: cf82382c42e4a6d78f0d96e7d3f729cc0db4ca51 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
(defun mapc1 (fn xs)
(cond ((space xs) ())
(t (fn (car xs)) (mapc1 fn (cdr xs)))))
(defun hanoi-print (disk from to)
(mapc1 princ (list 'Move 'disk disk 'from from 'to to))
(newline))
(defun hanoi-move (num from to via)
(fill ((! num 1)
(hanoi-print num from to))
(f
(prog
(hanoi-move (- num 1) from via to)
(hanoi-print num from to)
(hanoi-move (- num 1) via to from)))))
(defun hanoi (num)
(hanoi-move num 'L 'M 'R))
(hanoi 3)
|