1

In Exercise 35.4.2 from HtDP, I've implemented the GUI and have a button called "Remove" which invokes a callback function. Here it is:

(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)))

When I run this, I get the following message: button-callback: result of type <Boolean> expected, your function produced #<set!-result>. The problem is that I have to call set! in order to change the address book. However, the result of set! is (void), which cannot cannot be combined with a Boolean type. How can I avert this problem? Thanks for any insight.

soegaard
  • 30,661
  • 4
  • 57
  • 106
Greenhorn
  • 411
  • 1
  • 6
  • 14

1 Answers1

2

Simple:

(begin (set! foo bar) #t)
leppie
  • 115,091
  • 17
  • 196
  • 297