;;; decision.scm Dave Reed ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; List structure that encode a simple decision tree. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define QUIZ-DB '((is it alive?) ((is it an animal?) dog fern) ((bigger than a house?) mountain car))) ;;; Interactive guessing game that takes a decision tree as input ;;; and prompts the user for yes/no answers to traverse the tree. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define (guess dbase) (if (list? dbase) (begin (display (car dbase)) (if (member (read) '(y yes)) (guess (cadr dbase)) (guess (caddr dbase)))) (begin (display "It is a ") (display dbase) (newline))))