mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 05:39:17 +02:00
WIP
This commit is contained in:
parent
fad0a908b6
commit
f0128d9db4
1 changed files with 104 additions and 0 deletions
|
@ -163,6 +163,8 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
|
|||
|
||||
# and
|
||||
|
||||
*Syntax*
|
||||
|
||||
(and {test1} ...)
|
||||
|
||||
# any
|
||||
|
@ -231,8 +233,43 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
|
|||
|
||||
# case
|
||||
|
||||
*Syntax*
|
||||
|
||||
(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 z)
|
||||
|
@ -263,10 +300,59 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
|
|||
|
||||
# cond
|
||||
|
||||
*Syntax*
|
||||
|
||||
(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
|
||||
|
||||
*Syntax*
|
||||
|
||||
(cond-expand {ce-clause2} {ce-clause2} ...)
|
||||
|
||||
# current-error-port
|
||||
|
@ -283,6 +369,8 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
|
|||
|
||||
# define-record-type
|
||||
|
||||
*Syntax*
|
||||
|
||||
(define-record-type {name}
|
||||
|
||||
{constructor} {pred} {field} ...)
|
||||
|
@ -293,6 +381,8 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
|
|||
|
||||
# do
|
||||
|
||||
*Syntax*
|
||||
|
||||
(do (({variable1} {init1} {step1})
|
||||
|
||||
...)
|
||||
|
@ -389,6 +479,8 @@ For more information see the [R<sup>7</sup>RS Scheme Specification](../../r7rs.p
|
|||
|
||||
# guard
|
||||
|
||||
*Syntax*
|
||||
|
||||
(guard ({variable}
|
||||
|
||||
{cond clause1} {cond clause2} ...)
|
||||
|
@ -665,6 +757,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
|
|||
|
||||
# or
|
||||
|
||||
*Syntax*
|
||||
|
||||
(or {test1} ...)
|
||||
|
||||
# output-port-open?
|
||||
|
@ -677,6 +771,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
|
|||
|
||||
# parameterize
|
||||
|
||||
*Syntax*
|
||||
|
||||
(parameterize (({param1} {value1}) ...)
|
||||
|
||||
{body})
|
||||
|
@ -687,6 +783,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
|
|||
|
||||
# quasiquote
|
||||
|
||||
*Syntax*
|
||||
|
||||
(quasiquote {qq template})
|
||||
|
||||
# quotient
|
||||
|
@ -719,6 +817,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
|
|||
|
||||
# receive
|
||||
|
||||
*Syntax*
|
||||
|
||||
(receive {formals} {expression} {body})
|
||||
|
||||
# record?
|
||||
|
@ -857,6 +957,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
|
|||
|
||||
# unless
|
||||
|
||||
*Syntax*
|
||||
|
||||
(unless {test} {expression1} {expression2} ...)
|
||||
|
||||
# utf8->string
|
||||
|
@ -929,6 +1031,8 @@ If it is not possible to evaluate each `{init}` without assigning or referring t
|
|||
|
||||
# when
|
||||
|
||||
*Syntax*
|
||||
|
||||
(when {test} {expression1} {expression2} ...)
|
||||
|
||||
# with-exception-handler
|
||||
|
|
Loading…
Add table
Reference in a new issue