我正在编写一个函数,try-weak-cues
用于从大量响应中选择一个响应。该程序本质上是与用户的对话。
(define try-weak-cues
(lambda (sentence context)
(define helper
(lambda(list-of-pairs)
(define helper2
(lambda(list-of-pairs context)
(cond((null? list-of-pairs)
(cond((null? list-of-pairs) '())
((any-good-fragments?(cue-part(car list-of-pairs))sentence) (helper2(cdr(car list-of-pairs))context))
(else(helper(cdr list-of-pairs)))))))))
(helper *weak-cues*))))
以下是该函数应该从中提取的响应列表:
(define *weak-cues*
'( ( ((who) (whos) (who is))
((first-base)
((thats right) (exactly) (you got it)
(right on) (now youve got it)))
((second-base third-base)
((no whos on first) (whos on first) (first base))) )
( ((what) (whats) (what is))
((first-base third-base)
((hes on second) (i told you whats on second)))
((second-base)
((right) (sure) (you got it right))) )
( ((whats the name))
((first-base third-base)
((no whats the name of the guy on second)
(whats the name of the second baseman)))
((second-base)
((now youre talking) (you got it))))
))
错误:
定义:语法错误(标识符后有多个表达式)在:(定义助手(lambda(列表对))(定义助手2(lambda(列表对上下文)(cond((null?列表对)) cond ((null?list-of-pairs) (quote ())) ((any-good-fragments? (cue-part (car list-of-pairs)) 句子) (helper2 (cdr (car list-of- pair)) context)) (else (helper (cdr list-of-pairs)))))))))) (helper weak-cues ))