[plt-scheme] HTDP 21.1.2 - trying to put it together

From: Chris Warrington (chrisw at rice.edu)
Date: Sun Jul 16 16:35:21 EDT 2006

wooks . @ 2006-7-16 2:06:12 PM
"[plt-scheme] HTDP 21.1.2 - trying to put it together" <mid:BAY103-F11E6EFF0190AF0B9751C84C06D0 at phx.gbl>

>>> I've "lost" the (X -> Y) ...the only thing I can think of now is
>>> making somefunc local to the definition of the map function to
>>> bring the (X -> Y) from map within the scope of somefunc.
>> What happens if you do that?
> It works.

> (define (myMap func a-list)
>   (local ((define (someFunc x aloy)
>      (cons (func x) aloy)))
>     (fold someFunc empty a-list)))

Now, can you extend what you learned when writing map to write
something like filter?

filter : (X -> boolean) [X] -> [X]

>> Can you "flatten" someFunc now that you don't have to pass it f?
> If it were an anonymous function I wouldn't have to "pass" it but
> I'm not supposed to know that at HTDP chap 21.

After getting to Intermezzo 4, rewrite myMap without using local.

-- 
Chris Warrington <chrisw at rice.edu>

Black holes are where God divided by zero.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 185 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20060716/971dbdc1/attachment.sig>

Posted on the users mailing list.