| if <test> <consequent> <alternate> | R5RS |
| if <test> <consequent> | R5RS |
An if expression is evaluated as follows: first, <test> is
evaluated. If it yields a true value, then <consequent> is
evaluated and its value(s) is(are) returned. Otherwise <alternate>
is evaluated and its value(s) is(are) returned. If <test> yields a
false value and no <alternate> is specified, then the result of the
expression is void.
(if (> 3 2) 'yes 'no) => yes
(if (> 2 3) 'yes 'no) => no
(if (> 3 2)
(- 3 2)
(+ 3 2)) => 1
|
| cond <clause1> <clause2> ... | R5RS |
In a cond, each <clause> should be of the form
(<test> <expression1> ...)
where (<test> => <expression>)
The last (else <expression1> <expression2> ...)
A cond expression is evaluated by evaluating the (cond ((> 3 2) 'greater)
((< 3 2) 'less)) => greater
(cond ((> 3 3) 'greater)
((< 3 3) 'less)
(else 'equal)) => equal
(cond ((assv 'b '((a 1) (b 2))) => cadr)
(else #f)) => 2
|
| case <key> <clause1> <clause2> ... | R5RS |
In a case, each <clause> should have the form
((<datum1> ...) <expression1> <expression2> ...),
where each (else <expression1> <expression2> ...).
A case expression is evaluated as follows. (case (* 2 3)
((2 3 5 7) 'prime)
((1 4 6 8 9) 'composite)) => composite
(case (car '(c d))
((a) 'a)
((b) 'b)) => void
(case (car '(c d))
((a e i o u) 'vowel)
((w y) 'semivowel)
(else 'consonant)) => consonant
|
| and <test1> ... | R5RS |
The <test> expressions are evaluated from left to right, and the
value of the first expression that evaluates to a false value is
returned. Any remaining expressions are not evaluated. If all the
expressions evaluate to true values, the value of the last expression
is returned. If there are no expressions then #t is returned.
(and (= 2 2) (> 2 1)) => #t
(and (= 2 2) (< 2 1)) => #f
(and 1 2 'c '(f g)) => (f g)
(and) => #t
|
| or <test1> ... | R5RS |
The <test> expressions are evaluated from left to right, and the
value of the first expression that evaluates to a true value is
returned. Any remaining expressions are not evaluated. If all
expressions evaluate to false values, the value of the last expression
is returned. If there are no expressions then #f is returned.
(or (= 2 2) (> 2 1)) => #t
(or (= 2 2) (< 2 1)) => #t
(or #f #f #f) => #f
(or (memq 'b '(a b c))
(/ 3 0)) => (b c)
|
| when <test> <expression1> <expression2> ... | STKLOS Syntax |
If the <test> expression yields a true value, the <expression>s are
evaluated from left to right and the value of the last <expression> is
returned. Otherwise, when returns void
|
| unless <test> <expression1> <expression2> ... | STKLOS Syntax |
If the <test> expression yields a false value, the <expression>s are
evaluated from left to right and the value of the last <expression> is
returned. Otherwise, unless returns void
|