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