[plt-scheme] HTDP 21.1.2 - trying to put it together
>From: Chris Warrington <chrisw at rice.edu>
>Reply-To: Chris Warrington on the PLT Scheme List
><plt-scheme at list.cs.brown.edu>
>To: wooks on the PLT Scheme List <plt-scheme at list.cs.brown.edu>
>Subject: Re: [plt-scheme] HTDP 21.1.2 - trying to put it together
>Date: Sun, 16 Jul 2006 13:03:13 -0400
>
>
>wooks . @ 2006-7-16 11:37:55 AM
>"[plt-scheme] HTDP 21.1.2 - trying to put it together"
><mid:BAY103-F5BD54E0B21FC7ACDD2B86C06D0 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)))
(define (square n) (* n n))
(myMap square (list 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16))
>
>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.