| www.delorie.com/gnu/docs/guile/guile_292.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Guile provides three syntactic constructs for conditional evaluation.
if is the normal if-then-else expression (with an optional else
branch), cond is a conditional expression with multiple branches
and case branches if an expression has one of a set of constant
values.
#f, alternate is evaluated instead. The value of the
evaluated branch (consequent or alternate) is returned as
the value of the if expression.
When alternate is omitted and the test evaluates to
#f, the value of the expression is not specified.
cond-clause must look like this:
(test expression ...) |
where test and expression are arbitrary expression, or like this
(test => expression |
where expression must evaluate to a procedure.
The tests of the clauses are evaluated in order and as soon as one
of them evaluates to a true values, the corresponding expressions
are evaluated in order and the last value is returned as the value of
the cond-expression. For the => clause type,
expression is evaluated and the resulting procedure is applied to
the value of test. The result of this procedure application is
then the result of the cond-expression.
The test of the last clause may be the keyword else.
Then, if none of the preceding tests is true, the expressions following the else are evaluated to produce the result of the cond-expression.
((datum1 ...) expr1 expr2 ...) |
and the last clause may have the form
(else expr1 expr2 ...) |
All datums must be distinct. First, key is evaluated. The
the result of this evaluation is compared against all datums using
eqv?. When this comparison succeeds, the expression(s) following
the datum are evaluated from left to right, returning the value of
the last expression as the result of the case expression.
If the key matches no datum and there is an
else-clause, the expressions following the else are
evaluated. If there is no such clause, the result of the expression is
unspecified.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |