This commit is contained in:
Justin Ethier 2016-12-10 03:32:49 -05:00
parent fad0a908b6
commit f0128d9db4

View file

@ -163,6 +163,8 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
# and # and
*Syntax*
(and {test1} ...) (and {test1} ...)
# any # any
@ -231,8 +233,43 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
# case # case
*Syntax*
(case {key} {clause1} {clause2} ...) (case {key} {clause1} {clause2} ...)
Syntax: `{Key}` can be any expression. Each `{clause}` has the form
(({datum1} ...) {expression1} {expression2} ...),
where each `{datum}` is an external representation of some object. It is an error if any of the `{datum}`'s are the same anywhere in the expression. Alternatively, a `{clause}` can be of the form
((hdatum1} ...) => {expression})
The last `{clause}` can be an "else clause," which has one of the forms
(else {expression1} {expression2} . . . )
or
(else => {expression}).
Semantics: A `case` expression is evaluated as follows. `{Key}` is evaluated and its result is compared against each `{datum}`. If the result of evaluating `{key}` is the same to a `{datum}`, then the expressions in the corresponding `{clause}` are evaluated in order and the results of the last expression in the `{clause}` are returned as the results of 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 results of the last are the results of the case expression; otherwise the result of the case expression is unspecified.
If the selected `{clause}` or else clause uses the `=>` alternate form, then the `{expression}` is evaluated. It is an error if its value is not a procedure accepting one argument. This procedure is then called on the value of the `{key}` and the values returned by this procedure are returned by the case expression.
(case (* 2 3)
((2 3 5 7) prime)
((1 4 6 8 9) composite)) => composite
(case (car (c d))
((a) a)
((b) b)) => unspecified
(case (car (c d))
((a e i o u) vowel)
((w y) semivowel)
(else => (lambda (x) x))) => c
# ceiling # ceiling
(ceiling z) (ceiling z)
@ -263,10 +300,59 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
# cond # cond
*Syntax*
(cond {clause1} {clause2} ...) (cond {clause1} {clause2} ...)
else
=>
Syntax: hClausesi take one of two forms, either
({test} {expression1} ...)
where htesti is any expression, or
({test} => {expression})
The last hclausei can be an “else clause,” which has the
form
(else {expression1} {expression2} ...)
Semantics: A `cond` expression is evaluated by evaluating
the `{test}` expressions of successive `{clause}`'s in order until
one of them evaluates to a true value.
When a `{test}` evaluates to a true value, the remaining
`{expression}`'s in its `{clause}` are evaluated in order, and the
results of the last `{expression}` in the `{clause}` are returned
as the results of the entire cond expression.
If the selected `{clause}` contains only the `{test}` and no
`{expression}`'s, then the value of the `{test}` is returned as
the result. If the selected `{clause}` uses the `=>` alternate
form, then the `{expression}` is evaluated. It is an error if
its value is not a procedure that accepts one argument.
This procedure is then called on the value of the `{test}` and
the values returned by this procedure are returned by the
cond expression.
If all `{test}`'s evaluate to `#f`, 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
in order, and the values of the last one 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
# cond-expand # cond-expand
*Syntax*
(cond-expand {ce-clause2} {ce-clause2} ...) (cond-expand {ce-clause2} {ce-clause2} ...)
# current-error-port # current-error-port
@ -283,6 +369,8 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
# define-record-type # define-record-type
*Syntax*
(define-record-type {name} (define-record-type {name}
{constructor} {pred} {field} ...) {constructor} {pred} {field} ...)
@ -293,6 +381,8 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
# do # do
*Syntax*
(do (({variable1} {init1} {step1}) (do (({variable1} {init1} {step1})
...) ...)
@ -389,6 +479,8 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
# guard # guard
*Syntax*
(guard ({variable} (guard ({variable}
{cond clause1} {cond clause2} ...) {cond clause1} {cond clause2} ...)
@ -665,6 +757,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
# or # or
*Syntax*
(or {test1} ...) (or {test1} ...)
# output-port-open? # output-port-open?
@ -677,6 +771,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
# parameterize # parameterize
*Syntax*
(parameterize (({param1} {value1}) ...) (parameterize (({param1} {value1}) ...)
{body}) {body})
@ -687,6 +783,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
# quasiquote # quasiquote
*Syntax*
(quasiquote {qq template}) (quasiquote {qq template})
# quotient # quotient
@ -719,6 +817,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
# receive # receive
*Syntax*
(receive {formals} {expression} {body}) (receive {formals} {expression} {body})
# record? # record?
@ -857,6 +957,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
# unless # unless
*Syntax*
(unless {test} {expression1} {expression2} ...) (unless {test} {expression1} {expression2} ...)
# utf8->string # utf8->string
@ -929,6 +1031,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
# when # when
*Syntax*
(when {test} {expression1} {expression2} ...) (when {test} {expression1} {expression2} ...)
# with-exception-handler # with-exception-handler