Towers of Hanoi#

General Information

Author: Datasoft
Language: LISP
Compiler/Interpreter: InterLisp/65

(HANOI OTHER MOVE DISPLAY HLIN CADR LOC VTAB GOXY)
(DEFINEQ HANOI '(LAMBDA NIL (PROG (ONE TWO THREE) (GR 20) (PAGE) (POKE 752 1) (TAB 4) (PRIN1 (QUOTE -ONE-)) (TAB 17) (PRIN1 (QUOTE -TWO-)) (TAB 29) (PRINT (QUOTE -THREE-)) (COL 1) (HLIN 13 13 20) (HLIN 11 15 22) (HLIN 9 17 24) (HLIN 7 19 26) (HLIN 5 21 28) (HLIN 3 23 30) (HLIN 1 25 32) (SETQ ONE (QUOTE (0 1 2 3 4 5 6))) (MOVE 7 (QUOTE ONE) (QUOTE THREE)) (READC) (SOUND 0 0 0 0) (POKE 752 0)))
)
(DEFINEQ OTHER '(LAMBDA (X Y) (COND ((EQ X (QUOTE ONE)) (COND ((EQ Y (QUOTE TWO)) (QUOTE THREE)) (T (QUOTE TWO)))) ((EQ X (QUOTE TWO)) (COND ((EQ Y (QUOTE ONE)) (QUOTE THREE)) (T (QUOTE ONE)))) ((EQ X (QUOTE THREE)) (COND ((EQ Y (QUOTE ONE)) (QUOTE TWO)) (T (QUOTE ONE))))))
)
(DEFINEQ MOVE '(LAMBDA (D E F) (COND ((EQ D 1) (PROGN (SET F (CONS (CAR (EVAL E)) (EVAL F))) (SET E (CDR (EVAL E))) (DISPLAY E F))) (T (PROGN (MOVE (SUB D 1) E (OTHER E F)) (SET F (CONS (CAR (EVAL E)) (EVAL F))) (SET E (CDR (EVAL E))) (DISPLAY E F) (MOVE (SUB D 1) (OTHER E F) F)))))
)
(DEFINEQ DISPLAY '(LAMBDA (X Y) (PROG NIL (SETQ Z (CAR (EVAL Y))) (COL 0) (HLIN (SUB (CADR (ASSOC X LOC)) (+ Z Z)) (+ (CADR (ASSOC X LOC)) (+ Z Z)) (+ (+ Z Z) 20)) (COL 1) (HLIN (SUB (CADR (ASSOC Y LOC)) (+ Z Z)) (+ (CADR (ASSOC Y LOC)) (+ Z Z)) (+ (+ Z Z) 20)) (GOXY 10 2) (PRIN1 (LIST (QUOTE MOVE) X (QUOTE TO) Y)) (PRIN1 (QUOTE "  ")) (SOUND 0 (+ 120 (* 10 Z)) 10 15)))
)
(DEFINEQ HLIN '(LAMBDA (X1 X2 Y) (PROGN (PLOT X1 Y) (DRAW X2 Y)))
)
(DEFINEQ CADR '(LAMBDA (X) (CAR (CDR X)))
)
(SETQ LOC '((ONE 13) (TWO 40) (THREE 66))
)
(DEFINEQ VTAB '(LAMBDA (R) (POKE 656 R))
)
(DEFINEQ GOXY '(LAMBDA (X Y) (PROGN (VTAB Y) (TAB X)))
)
NIL

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-1) was last changed on 14-Mar-2010 13:16 by Carsten Strotmann