[plt-scheme] Re: HTDP Exercise 22.3.3. - Hint needed

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Nov 29 11:16:10 EST 2003

The introduction of lambda in the intermezzo is a structural flaw in 
HtDP.
Because of that, I always introduce lambda as soon as I introduce loops
in this chapter.

(Das ist wirklich "Matthias", wie in D. "Matt" is der andere, der die 
ganze
Arbeit macht.)

-- Matthias


On Saturday, November 29, 2003, at 10:48 AM, Guenther Schmidt wrote:

>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
> Thanks Matt,
>
> I'll have go at this right after my nap.
>
> Guenther
>
> P.S. I didn't know that lambda had been introduced yet.
>
> Matthias Felleisen wrote:
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>> You will need a callback for each button. When the event happens the 
>> callback
>> to this button is triggered. Do it manually for each button and then 
>> follow the
>> design recipe from this section to abstract over the button creation 
>> process in
>> general
>>  (map (lambda (row) (map make-button row)) pad)
>> and the button callback function in particular. -- Matthias
>> P.S. I promise it will be enlightening.
>> On Saturday, November 29, 2003, at 10:30 AM, Guenther Schmidt wrote:
>>>  For list-related administrative tasks:
>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>>
>>> 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
>>>
>



Posted on the users mailing list.