;;;; section 2.2 ;;;;;;; ;;adam nelson ;;chet tobrey (defun sentence () (append (noun-phrase)(verb-phrase))) (defun noun-phrase() (append (Article)(Noun))) (defun verb-phrase() (append (Verb)(noun-phrase))) (defun Article() (one-of '(the a))) (defun Noun() (one-of '(man ball woman table))) (defun Verb() (one-of '(hit took saw liked))) (defun one-of (set) "picks an element of a set, and makes a list of it." (list (random-elt set))) (defun random-elt(choices) "Chooses and element randomly from a list" (elt choices (random (length choices)))) ;;;;; (egs :2.2 (eg '(sentence) :of "the first generated sentence") (eg '(sentence) :of "sentence 2") (eg '(sentence) :of "sentence3") (eg '(sentence) :of "sentence 4") (eg '(noun-phrase) :of "a noun phrase") (eg '(verb-phrase) :of "a verb phrase" ) (eg '(trace sentence noun-phrase verb-phrase article noun verb) :of "turning trace on") (eg '(sentence) :of "tracing the sentence function") (eg '(untrace) :of "untracing a sentence"))