I'm learning SICP and do the programming exercises. I have a question about exercise 4.5. The exercise 4.5 is:
Scheme allows an additional syntax for
cond
clauses,(<test> => <recipient>)
. If<test>
evaluates to a true value, then<recipient>
is evaluated. Its value must be a procedure of one argument; this procedure is then invoked on the value of the<test>
, and the result is returned as the value of thecond
expression. For example:
(cond
((assoc 'b '((a 1) (b 2))) => cadr)
(else false))
As shown above,if <test>
is true,the value of the cond
clause should be (<recipient> <test>)
(i.e.
then
<recipient>
is evaluated. Its value must be a procedure of one argument; this procedure is then invoked on the value of the<test>
, and the result is returned...
But when I search the solution on the Internet, almost all I found are (list (extended-cond-recipient first) (extended-cond-test first))
. It's a list consist of <recipient>
and <test>
, not a function call.
What should I do? It has troubled me a long time...