; ; uLisp Animals Game ; see http://www.ulisp.com/show?1LKX ; (defvar *data* '("Does it live in the sea?" "a dolphin" "a horse")) (defun run (tree) (if (listp tree) (ask tree) (try tree))) (defun yes-no () (eq (read) 'y)) (defun printlist (&rest lst) (terpri) (mapc princ lst)) (defun ask (tree) (printlist (first tree) " ") (if (yes-no) (list (first tree) (run (second tree)) (third tree)) (list (first tree) (second tree) (run (third tree))))) (defun try (animal) (printlist "Is it " animal "? ") (cond ((yes-no) (printlist "Ho ho!") animal) (t (printlist "What were you thinking of? ") (add animal (read-line))))) (defun add (animal new) (printlist "Give me a yes/no question to distinguish between " new " and " animal ": ") (let ((question (read-line))) (printlist "What would the answer be for " new "? ") (if (yes-no) (list question new animal) (list question animal new)))) (defun go () (setq *data* (run *data*)) nil)