rules
a rule consists of
- two patterns
- one is used to generate matches (a list of dictionaries) – called the matching pattern
- the other is used as a template to generate results – called the template
examples from toy Eliza program
- (~a mother ~b) (tell me more about your mother)
- ?x (why are you being short with me ?)
- (~phrase) (what makes you say ~phrase ?)
- yes (you sound confident)
example: dotted tail notation
- (define (sum x . t) (if (null? t) x (+ x (sum t)))
- how many matches for this kind of pattern?
nameless vars
- no point giving names to vars not used in the template
- so just use ? and ~ by themselves
- note that template is not exactly a pattern: it can use ? and ~ as atoms