From 2cc8ca2b781be0a6e7ce14405eb4611bc00a3a3e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 17 Nov 2016 18:45:31 -0800 Subject: [PATCH] altos/lisp: Take advantage of implicit progns in hanoi demo Remove extra progn wrappers now that cond, lambda and while all support implicit ones. Signed-off-by: Keith Packard --- src/test/hanoi.lisp | 50 +++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 34 deletions(-) diff --git a/src/test/hanoi.lisp b/src/test/hanoi.lisp index d8ff2c86..b5f2d0f5 100644 --- a/src/test/hanoi.lisp +++ b/src/test/hanoi.lisp @@ -43,18 +43,16 @@ (defun display-stack (x y clear stack) (cond ((= 0 clear) - (cond (stack (progn - (display-string x y (car stack)) - (display-stack x (1+ y) 0 (cdr stack)) - ) - ) + (cond (stack + (display-string x y (car stack)) + (display-stack x (1+ y) 0 (cdr stack)) + ) ) ) - (t (progn - (display-string x y " ") - (display-stack x (1+ y) (1- clear) stack) - ) - ) + (t + (display-string x y " ") + (display-stack x (1+ y) (1- clear) stack) + ) ) ) @@ -68,10 +66,9 @@ ; Display all of the stacks, spaced 20 columns apart (defun display-stacks (x y stacks) - (cond (stacks (progn - (display-stack x 0 (stack-pos y (car stacks)) (car stacks)) - (display-stacks (+ x 20) y (cdr stacks))) - ) + (cond (stacks + (display-stack x 0 (stack-pos y (car stacks)) (car stacks)) + (display-stacks (+ x 20) y (cdr stacks))) ) ) @@ -132,16 +129,12 @@ (defun _hanoi (n from to use) (cond ((= 1 n) - (progn - (move-piece from to) - nil) + (move-piece from to) ) (t - (progn - (_hanoi (1- n) from use to) - (_hanoi 1 from to use) - (_hanoi (1- n) use to from) - ) + (_hanoi (1- n) from use to) + (_hanoi 1 from to use) + (_hanoi (1- n) use to from) ) ) ) @@ -155,16 +148,5 @@ (setq len (reset-stacks)) (clear) (_hanoi len 0 1 2) - ) - - ; Run many in a row to time them - -(defun hanois(n) - (cond ((> n 0) - (progn - (hanoi) - (hanois (1- n)) - ) - ) - ) + (move-to 0 23) ) -- 2.30.2