Hi, What is the meaning of '=> symbol used in cond forms? Best Regards, -- Aycan iRiCAN C0R3 Computer Security Group http://people.core.gen.tr/~aycan.irican/
Afficher les réponses par date
On Oct 8, 2006, at 6:35 PM, Aycan iRiCAN wrote:
Hi,
What is the meaning of '=> symbol used in cond forms?
Standards documents are your friends. From <http://schemers.org/ Documents/Standards/R5RS/HTML/r5rs-Z-H-2.html#%25_toc_%25_sec_4.2.1>:
If the selected <clause> uses the => alternate form, then the <expression> is evaluated. Its value must be a procedure that accepts one argument; this procedure is then called on the value of the <test> and the value(s) returned by this procedure is(are) returned by the cond expression. If all <test>s evaluate to false values, and there is no else clause, then the result of the conditional expression is unspecified; if there is an else clause, then its <expression>s are evaluated, and the value(s) of the last one is(are) returned.
Regards, Ed
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 8-Oct-06, at 6:35 PM, Aycan iRiCAN wrote:
Hi,
What is the meaning of '=> symbol used in cond forms?
Best Regards,
In Scheme the form (cond (X => F) ...) is equivalent to (let ((x X)) (if x (F x) (cond ...))) This is useful when the result of the test (the expression X) is needed in the clause selected. This is frequently used in code like (cond ((assoc X Y) => cdr) ...) Marc -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (Darwin) iD8DBQFFKZTx//V9Zc2T/v4RAiDxAJ4hIuljNHsGFIcVFr/I6cxr8CHmwgCfc1w8 s4rxaA/zU54hxeNXGbNpml4= =B/Uz -----END PGP SIGNATURE-----
participants (3)
-
Aycan iRiCAN -
Ed Watkeys -
Marc Feeley