File: hanoi.l

package info (click to toggle)
picolisp 3.1.0.7-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,100 kB
  • sloc: ansic: 14,205; lisp: 795; makefile: 290; sh: 13
file content (24 lines) | stat: -rw-r--r-- 500 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 10nov04abu
# (c) Software Lab. Alexander Burger

# Lisp
(de hanoi (N)
   (move N 'left 'center 'right) )

(de move (N A B C)
   (unless (=0 N)
      (move (dec N) A C B)
      (println 'Move 'disk 'from 'the A 'to 'the B 'pole)
      (move (dec N) C B A) ) )

# Pilog
(be hanoi (@N)
   (move @N left center right) )

(be move (0 @ @ @) T)

(be move (@N @A @B @C)
   (@M - (-> @N) 1)
   (move @M @A @C @B)
   (@ println 'Move 'disk 'from 'the (-> @A) 'to 'the (-> @B) 'pole)
   (move @M @C @B @A) )