altos/lisp: Optimize chunk searching in collect
[fw/altos] / src / test / hanoi.lisp
index b84b8174737c56d928d0b790f140f31ab6e087da..7a25656c06e1a7e5903d8921e5e311ffb19a5954 100644 (file)
@@ -32,9 +32,7 @@
 
 ; Here's the pieces to display
 
-(setq stack '("*" "**" "***" "****" "*****" "******" "*******"))
-
-(setq top (+ (length stack) 3))
+(setq stack '("     *     " "    ***    " "   *****   " "  *******  " " ********* " "***********"))
 
 ;
 ; Here's all of the stacks of pieces
               )
         )
        (t (progn
-            (display-string x y "          ")
+            (display-string x y "                    ")
             (display-stack x (1+ y) (1- clear) stack)
             )
           )
        )
   )
 
-; This should probably be included in the rom image...
-
-(defun length (list)
-  (cond (list (1+ (length (cdr list))))
-       (0)
-       )
-  )
-
 ; Position of the top of the stack on the screen
 ; Shorter stacks start further down the screen
 
 
 (defun reset-stacks ()
   (setq stacks (list stack nil nil))
+  (setq top (+ (length stack) 3))
   (length stack)
   )
 
        )
   )
 
-(defun nth (list n)
-  (cond ((= n 0) (car list))
-       ((nth (cdr list) (1- n)))
-       )
-  )
-
 ; Replace a stack in the list of stacks
 ; with a new value
 
     (setq stacks (replace stacks from from-stack))
     (setq stacks (replace stacks to to-stack))
     (display)
-    (delay 100)
+;    (delay 100)
     )
   )
 
   (clear)
   (_hanoi len 0 1 2)
   )
+
+(defun hanois(n)
+  (while (> n 0)
+    (progn
+      (hanoi)
+      (setq l (1- l))
+      )
+    )
+  )