[plt-scheme] Syntax question (from 4.2.1 of Report) -- never mind, I see it now
--- Gregory Woodhouse <gregory.woodhouse at sbcglobal.net> wrote:
> I'm puzzled by this example from the report
>
> (cond ((assv 'b '((a 1) (b 2))) => cadr)
> (else #f))
>
> which evaluates to 2. I understand that (assv 'b '((a 1) (b 2)))
> evaluates to (b 2), and cadr is an abbreviation for the car of the
> cdr, but don't quite know what to make of the cond expression.
>
Ah...never mind. I wasn't paying attention. I see now that if <test>
evaluates to true, then
(<test> => <expression>) applies <expression> to the value of <test>.
Since (assv 'b '((a 1) (b 2))) evaluates to (b 2), the result is just
(cadr '(b 2)) or 2.
I had just never seen the => notation before and mistook it for
something else.
===
Gregory Woodhouse <gregory.woodhouse at sbcglobal.net>
"Interaction is the mind-body problem of computing."
--Philip L. Wadler