| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
(if (number? 3) 'yes 'no) => yes
(if (number? #f) 'yes 'no) => no
(let ((x '(1 . 2)))
(if (pair? x)
(values (car x) (cdr x))
(values #f #f)))
=> 1 and 2
|
clause must be the form
(test expr ...) (test => expr) (else expr expr2 ...) |
cond evaluates test of each clauses in order, until
it yields a true value. Once it yields true, if the clause
is the first form, the corresponding exprs are evaluated
and the result(s) of last expr is(are) returned; if the clause
is the second form, the expr is evaluated and it must yield
a procedure that takes one argument. Then the result of test
is passed to it, and the result(s) it returns will be returned.
If no test yields true, and the last clause is not the third form
(else clause), an undefined value is returned.
If the last clause is else clause and all tests are failed, exprs in the else clause are evaluated, and its last expr's result(s) is(are) returned.
(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
|
((datum ...) expr expr2 ...) |
(else expr expr2 ...) |
First, key is evaluated and its result is compared against each
datum. If the result of evaluating datum is equivalent
(using eqv?, See section 6.1 Equivalence), to a datum,
then the expressions in the corresponding clause are evaluated
sequentially, and the result(s) of the last expression in the
clause is(are) returned from the case expression.
If the result of evaluating key is different from every datum,
then if there is an else clause its expressions are evaluated and
the result(s) of the last is(are) the result(s) of the case expression;
otherwise the result of the case expression is unspecified.
(case (* 2 3) ((2 3 5 7) 'prime) ((1 4 6 8 9) 'composite)) => composite (case (car '(c d)) ((a) 'a) ((b) 'b)) => undefined (case (car '(c d)) ((a e i o u) 'vowel) ((w y) 'semivowel) (else 'consonant)) => consonant |
#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 |
#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)
|
unless), body ... are evaluated sequentially, and
the result(s) of the last evaluation is(are) returned. Otherwise, undefined
value is returned.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |