On Oct 21, 2016, at 11:39 AM, Doug Edmunds <dougedmu...@gmail.com> wrote:
> 
> (define series
>  (lambda (mk)
>    (hc-append 4 (mk 5) (mk 10) (mk 20))))
> 
> (define (rgb-series mk)
>  (vc-append
>   (series (lambda (sz) (colorize (mk sz) "red")))
>   (series (lambda (sz) (colorize (mk sz) "green")))
>   (series (lambda (sz) (colorize (mk sz) "blue")))))
> 
> I am having difficulty understanding how the numbers 5, 10, and 20
> in the first definition 
> become "sz"  in the second definition. 

`series` is a function that takes one argument (also a function), labeled `mk`, 
and applies it to 5, 10, and 20.

So if `series` is called like this:

(series (lambda (sz) (colorize (mk sz) "red")))

Then the `mk` argument in `series` is:

(lambda (sz) (colorize (mk sz) "red"))

(Note that the `mk` identifier inside this lambda refers to a different `mk` = 
the one from `rgb-series`)

So within `series`, this:

(mk 5)

Means this:

((lambda (sz) (colorize (mk sz) "red")) 5) 

When this lambda is applied to 5, then `sz` takes on the value 5 (or 10, or 20) 
within the lambda.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to