在Exercise 35.4.2 from HtDP中,我实现了GUI并有一个名为“Remove”的按钮,它调用了一个回调函数。这是:
(define (cb-remove x)
((lambda (name result)
(cond
[(number? result) (remove-name name address-book)]
[else (draw-message msg "Not found")]))
(string->symbol (text-contents label-name))
(lookup (string->symbol (text-contents label-name)) address-book)))
当我运行此消息时,我收到以下消息:button-callback: result of type <Boolean> expected, your function produced #<set!-result>
。问题是我必须致电set!
才能更改地址簿。但是,set!
的结果是(void)
,它不能与布尔类型结合使用。我怎样才能避免这个问题?感谢您的任何见解。
答案 0 :(得分:2)
简单:
(begin (set! foo bar) #t)