March 20th Tuesday (三月 二十日 火曜日)

来源:互联网 发布:mac怎么玩lol国服 编辑:程序博客网 时间:2024/03/29 13:29

  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 htesti evaluates to a true value, then
the remaining hexpressionis in its hclausei are evaluated in order,and the result(s) of the last
<expression> in the hclausei is(are) returned as the result(s) of the entire cond expression.  If
the selected hclausei contains only the htesti and no hexpressionis, then the value of the htesti
is returned as the result.  If the selected hclausei uses the => alternate form, then the <expression>
is evaluated. Its value must be a procedure that accepts one argument; this procedure is then called
on the value of the htesti and the value(s) returned by this procedure is(are) returned by the cond
expression.  If all htestis evaluate to false values, and there is no else clause, then the result of
the conditional expression is the unspecified value; if there is an else clause, then its expression
(is) are evaluated, and the value(s) of the last one is(are) returned.

  (and <test1> . . . )

  Syntax: The <test>s must be expressions.

  Semantics: 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.


  (letrec <bindings> <body>)
<Bindings> must have the form
((<variable1> <init1>) . . . )

  The <variable>s are bound to fresh locations, the hinitis are evaluated in the resulting environment
 (in some unspecified order), each <variable> is assigned to the result of the corresponding <init>,
 the <body> is evaluated in the resulting environment, and the value(s) of the last expression in
<body> is(are) returned.  Each binding of a <variable> has the entire letrec expression as its region,
making it possible to define mutually recursive procedures.

  One restriction on letrec is very important: it must be possible to evaluate each <init> without
 assigning or referring to the value of any hvariablei.  If this restriction is violated, an exception
with condition type &assertion is raised. The restriction is necessary because Scheme passes arguments
by value rather than by name.  In the most common uses of letrec, all the hinitis are lambda
expressions and the restriction is satisfied automatically.

  (letrec* <bindings> <body>)

  One restriction on letrec* is very important: it must be possible to evaluate each <init> without
assigning or referring to the value the corresponding <variable> or the <variable> of any of the
 bindings that follow it in <bindings>.  If this restriction is violated, an exception with condition
type &assertion is raised.  The restriction is necessary because Scheme passes arguments by value
rather than by name.

  Of the equivalence predicates described in this section, eq? is the finest or most discriminating,
and equal? is the coarsest.  The eqv? predicate is slightly less discriminating than eq?.

  The equal? predicate returns #t if and only if the (possibly infinite) unfoldings of its arguments
into regular trees are equal as ordered trees.

  The equal? predicate treats pairs and vectors as nodes with outgoing edges, uses string=? to compare strings, uses bytesvector=? to compare bytevectors, and uses eqv? to compare other nodes. 

原创粉丝点击