Search

( caddr [ pair? pair ] ) *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
( cadr [ pair? pair ] ) *
caar, cadr, cdar, cddr These procedures are compositions of car and cdr
( cadr [ pair? pair ] ) *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
( call-with-current-continuation [ procedure? proc ] ) *
proc ( λ [ procedure? k ] ) *
It is an error if proc does not accept one argument. The procedure call-with-current-continuation (or its equivalent abbreviation call/cc) packages the current continuation (see the rationale below) as an "escape procedure" and passes it as an argument to proc. The escape procedure is a Scheme procedure that, if it is later called, will abandon whatever continuation is in ect at that later time and will instead use the continuation that was in effect when the escape procedure was created. Calling the escape procedure will cause the invocation of before and after thunks installed using dynamic-wind. The escape procedure accepts the same number of arguments as the continuation to the original call to call-with-current-continuation. Most continuations take only one value. Continuations created by the call-with-values procedure (including the initialization expressions of define-values, let-values, and let*-values expressions), take the number of values that the consumer expects. The continuations of all non-final expressions within a sequence of expressions, such as in lambda, case-lambda, begin, let, let*, letrec, letrec*, let-values, let*-values, let-syntax, letrec-syntax, parameterize, guard, case, cond, when, and unless expressions, take an arbitrary number of values because they discard the values passed to them in any event. The ect of passing no values or more than one value to continuations that were not created in one of these ways is unspecified. The escape procedure that is passed to proc has unlimited extent just like any other procedure in Scheme. It can be stored in variables or data structures and can be called as many times as desired. However, like the raise and error procedures, it never returns to its caller. Rationale: A common use of call-with-current-continuation is for structured, non-local exits from loops or procedure bodies, but in fact call-with-current-continuation is useful for implementing a wide variety of advanced control structures. In fact, raise and guard provide a more structured mechanism for nonlocal exits. Whenever a Scheme expression is evaluated there is a continuation wanting the result of the expression. The continuation represents an entire (default) future for the computation. If the expression is evaluated at the REPL, for example, then the continuation might take the result, print it on the screen, prompt for the next input, evaluate it, and so on forever. Most of the time the continuation includes actions specified by user code, as in a continuation that will take the result, multiply it by the value stored in a local variable, add seven, and give the answer to the REPL's continuation to be printed. Normally these ubiquitous continuations are hidden behind the scenes and programmers do not think much about them. On rare occasions, however, a programmer needs to deal with continuations explicitly. The call-with-current-continuation procedure allows Scheme programmers to do that by creating a procedure that acts just like the current continuation.
( call-with-input-file [ string? string ] [ procedure? proc ] ) *
proc ( λ [ input-port? port ] ) *
call-with-input-file, call-with-output-file It is an error if proc does not accept one argument. These procedures obtain a textual port obtained by opening the named file for input or output as if by open-input-file or open-output-file. The port and proc are then passed to a procedure equivalent to call-with-port.
( call-with-output-file [ string? string ] [ procedure? proc ] ) *
proc ( λ [ output-port? port ] ) *
call-with-input-file, call-with-output-file It is an error if proc does not accept one argument. These procedures obtain a textual port obtained by opening the named file for input or output as if by open-input-file or open-output-file. The port and proc are then passed to a procedure equivalent to call-with-port.
( call-with-port [ port? port ] [ procedure? proc ] ) *
proc ( λ [ port? port ] ) *
It is an error if proc does not accept one argument. The call-with-port procedure calls proc with port as an argument. If proc returns, then the port is closed automatically and the values yielded by the proc are returned. If proc does not return, then the port must not be closed automatically unless it is possible to prove that the port will never again be used for a read or write operation. Rationale: Because Scheme’s escape procedures have unlimited extent, it is possible to escape from the current continuation but later to resume it. If implementations were permitted to close the port on any escape from the current continuation, then it would be impossible to write portable code using both call-with-current-continuation and call-with-port.
( call-with-values [ procedure? producer ] [ procedure? consumer ] ) *
producer ( λ ) *
consumer ( λ obj ... ) *
Calls its producer argument with no arguments and a continuation that, when passed some values, calls the consumer procedure with those values as arguments. The continuation for the call to consumer is the continuation of the call to call-with-values.
( call/cc [ procedure? proc ] ) *
proc ( λ [ procedure? k ] ) *
It is an error if proc does not accept one argument. The procedure call-with-current-continuation (or its equivalent abbreviation call/cc) packages the current continuation (see the rationale below) as an "escape procedure" and passes it as an argument to proc. The escape procedure is a Scheme procedure that, if it is later called, will abandon whatever continuation is in ect at that later time and will instead use the continuation that was in effect when the escape procedure was created. Calling the escape procedure will cause the invocation of before and after thunks installed using dynamic-wind. The escape procedure accepts the same number of arguments as the continuation to the original call to call-with-current-continuation. Most continuations take only one value. Continuations created by the call-with-values procedure (including the initialization expressions of define-values, let-values, and let*-values expressions), take the number of values that the consumer expects. The continuations of all non-final expressions within a sequence of expressions, such as in lambda, case-lambda, begin, let, let*, letrec, letrec*, let-values, let*-values, let-syntax, letrec-syntax, parameterize, guard, case, cond, when, and unless expressions, take an arbitrary number of values because they discard the values passed to them in any event. The ect of passing no values or more than one value to continuations that were not created in one of these ways is unspecified. The escape procedure that is passed to proc has unlimited extent just like any other procedure in Scheme. It can be stored in variables or data structures and can be called as many times as desired. However, like the raise and error procedures, it never returns to its caller. Rationale: A common use of call-with-current-continuation is for structured, non-local exits from loops or procedure bodies, but in fact call-with-current-continuation is useful for implementing a wide variety of advanced control structures. In fact, raise and guard provide a more structured mechanism for nonlocal exits. Whenever a Scheme expression is evaluated there is a continuation wanting the result of the expression. The continuation represents an entire (default) future for the computation. If the expression is evaluated at the REPL, for example, then the continuation might take the result, print it on the screen, prompt for the next input, evaluate it, and so on forever. Most of the time the continuation includes actions specified by user code, as in a continuation that will take the result, multiply it by the value stored in a local variable, add seven, and give the answer to the REPL's continuation to be printed. Normally these ubiquitous continuations are hidden behind the scenes and programmers do not think much about them. On rare occasions, however, a programmer needs to deal with continuations explicitly. The call-with-current-continuation procedure allows Scheme programmers to do that by creating a procedure that acts just like the current continuation.
( car [ pair? pair ] ) *
Returns the contents of the car field of pair . Note that it is an error to take the car of the empty list.
( car [ pair? pair ] ) *
car, cdr These functions return the contents of the car and cdr field of their argument, respectively. Note that it is an error to apply them to the empty list.
( car+cdr [ pair? pair ] ) ( values * * )
The fundamental pair deconstructor: (lambda (p) (values (car p) (cdr p)))
( case key clause1 clause2 ... )
clause⟩:= 
( ( datum1 ... ) expression1 expression2 ... ) ( ( datum1 ... ) => expression ) ( else expression1 expression2 ... ) ( else => expression )
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 (in the sense of eqv?; see section 6.1) 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 key clause1 clause2 ... )
clause⟩:= 
( ( datum1 ... ) expression1 expression2 ... ) ( else expression1 expression2 ... )
( case-lambda clause ... ) procedure?
clause⟩:= 
( formals body )
formals⟩:= 
( variable1 ... ) variable ( variable1 ... variable_n . variable_n+1 )
A CASE-LAMBDA expression evaluates to a procedure that accepts a variable number of arguments and is lexically scoped in the same manner as procedures resulting from LAMBDA expressions. When the procedure is called with some arguments V1 .. Vk, then the first <clause> for which the arguments agree with <formals> is selected, where agreement is specified as for the <formals> of a LAMBDA expression. The variables of <formals> are bound to fresh locations, the values V1 .. Vk are stored in those locations, the <body> is evaluated in the extended environment, and the results of <body> are returned as the results of the procedure call. It is an error for the arguments not to agree with the <formals> of any <clause>.
( cdaaar [ pair? pair ] ) *
The (scheme cxr) library exports twenty-four procedures which are the compositions of from three to four car and cdr operations. For example caddar could be defined by (define caddar (lambda (x) (car (cdr (cdr (car x)))))).
( cdaaar [ pair? pair ] ) *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
( cdaadr [ pair? pair ] ) *
The (scheme cxr) library exports twenty-four procedures which are the compositions of from three to four car and cdr operations. For example caddar could be defined by (define caddar (lambda (x) (car (cdr (cdr (car x)))))).
( cdaadr [ pair? pair ] ) *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
( cdaar [ pair? pair ] ) *
The (scheme cxr) library exports twenty-four procedures which are the compositions of from three to four car and cdr operations. For example caddar could be defined by (define caddar (lambda (x) (car (cdr (cdr (car x)))))).
( cdaar [ pair? pair ] ) *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
( cdadar [ pair? pair ] ) *
The (scheme cxr) library exports twenty-four procedures which are the compositions of from three to four car and cdr operations. For example caddar could be defined by (define caddar (lambda (x) (car (cdr (cdr (car x)))))).
( cdadar [ pair? pair ] ) *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
( cdaddr [ pair? pair ] ) *
The (scheme cxr) library exports twenty-four procedures which are the compositions of from three to four car and cdr operations. For example caddar could be defined by (define caddar (lambda (x) (car (cdr (cdr (car x)))))).
( cdaddr [ pair? pair ] ) *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
( cdadr [ pair? pair ] ) *
The (scheme cxr) library exports twenty-four procedures which are the compositions of from three to four car and cdr operations. For example caddar could be defined by (define caddar (lambda (x) (car (cdr (cdr (car x)))))).
( cdadr [ pair? pair ] ) *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
( cdar [ pair? pair ] ) *
caar, cadr, cdar, cddr These procedures are compositions of car and cdr