0

当我为这段代码做(访问医生晚餐时间)时:

(define (visit-doctor name)
  (if (equal? name 'suppertime) (end-session)
  ((write-line (list 'hello name))
  (write-line '(what seems to be the trouble?))
  (doctor-driver-loop name initial-earlier-response))))

(define (end-session) (write-line '(the doctor is done seeing patients today)))

它给了我这个错误:

申请:不是程序;期望一个可以应用于给定参数的过程:#arguments...:##

4

1 回答 1

3

您的问题是您正在尝试使用方括号对代码块进行分组。
计划不这样做。

你的else分支是

((write-line (list 'hello name))
 (write-line '(what seems to be the trouble?))
 (doctor-driver-loop name initial-earlier-response))

这是三个元素的列表。

该列表的第一个元素应该是一个过程,然后将其应用于其他两个元素,但是当你评估(write-line (list 'hello name))你没有得到一个过程时,你会得到#<void>.

解决方法是使用以下命令对其进行排序begin

(begin (write-line (list 'hello name))
       (write-line '(what seems to be the trouble?))
       (doctor-driver-loop name initial-earlier-response))
于 2013-02-28T09:00:06.590 回答