[plt-scheme] HTDP Exercise 22.3.3. - Hint needed
Hi,
I've developed the code following code but I have one problem: How do I
identify the button that was pressed?
When I specify the callback function to a button do I need to pass
specific arguments, in short: I don't know how it's done.
;; model
(define pad
'((1 2 3)
(4 5 6)
(7 8 9)
(\# 0 *)))
(define pad2
'((1 2 3 +)
(4 5 6 -)
(7 8 9 *)
(0 = \. /)))
;; view
(define md (make-message "n"))
(define (pad->gui title a-list)
(cons
(list (make-message title))
(cons (list md)
(traverse a-list))))
(define (traverse a-list)
(cond
((empty? a-list) empty)
((list? a-list)
(cons (traverse (first a-list))
(traverse (rest a-list))))
(else
(make-button
(cond
((symbol? a-list) (symbol->string a-list))
(else (number->string a-list)))
test))))
;; controller
(define (test e)
(draw-message md "2"))
(create-window (pad->gui "PHONE" pad))
Cheers
Guenther