Scheme Index (Static)

Hello! This is a project borne from the frustration of using index.scheme.org: the site is extremely slow due to being written in Angular. This site here is an attempt to reproduce (most of) the functionality of index.scheme org. But with static pre-rendered pages and zero JavaScript required. (index.scheme.org requires JavaScript to work, locking the users of older / weaker / JS-less browsers out.) Some of the features present on index.scheme.org are not present here. For reasons:

Other than that, it’s quite similar: choose the libraries you need, and search / skim / read their docs.

This site is sourced from scheme-index repository.

library (scheme base)

(scheme base) procedure (* (z number?) ... ) ⟹ number?

This procedure returns the product of its arguments.

(scheme base) procedure (+ (z number?) ... ) ⟹ number?

This procedure returns the sum of its arguments.

(scheme base) procedure (- (z number?) ... ) ⟹ number?

With two or more arguments, this procedure returns the difference of its arguments, associating to the left. With one argument, however, it returns the additive inverse of its argument.

(scheme base) procedure (/ (z1 number?) (z2 number?) ... ) ⟹ number?

With two or more arguments, this procedure returns the quotient of its arguments, associating to the left. With one argument, however, it returns multiplicative inverse of its argument. It is an error if any argument of / other than the first is an exact zero. If the first argument is an exact zero, an implementation may return an exact zero unless one of the other arguments is a NaN.

(scheme base) procedure (< (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically increasing, and #f otherwise. If any of the arguments are +nan.0, predicate returns #f. It does not distinguish between inexact zero and inexact negative zero. The predicate is transitive. Note: While it is not an error to compare inexact numbers using this predicate, the results are unreliable because a small inaccuracy can affect the result. When in doubt, consult a numerical analyst.

(scheme base) procedure (<= (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically non-decreasing, and #f otherwise. If any of the arguments are +nan.0, predicate returns #f. It does not distinguish between inexact zero and inexact negative zero. The predicate is transitive. Note: While it is not an error to compare inexact numbers using this predicate, the results are unreliable because a small inaccuracy can affect the result. When in doubt, consult a numerical analyst.

(scheme base) procedure (= (z1 number?) (z2 number?) (z3 number?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are equal, and #f otherwise. If any of the arguments are +nan.0, the predicate return #f. It does not distinguish between inexact zero and inexact negative zero. This predicate is transitive. Note: While it is not an error to compare inexact numbers using this predicate, the results are unreliable because a small inaccuracy can affect the result; this is especially true of =. When in doubt, consult a numerical analyst.

(scheme base) procedure (> (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically decreasing, and #f otherwise. If any of the arguments are +nan.0, predicate returns #f. It does not distinguish between inexact zero and inexact negative zero. The predicate is transitive. Note: While it is not an error to compare inexact numbers using this predicate, the results are unreliable because a small inaccuracy can affect the result. When in doubt, consult a numerical analyst.

(scheme base) procedure (>= (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically non-increasing, and #f otherwise. If any of the arguments are +nan.0, predicate returns #f. It does not distinguish between inexact zero and inexact negative zero. The predicate is transitive. Note: While it is not an error to compare inexact numbers using this predicate, the results are unreliable because a small inaccuracy can affect the result. When in doubt, consult a numerical analyst.

(scheme base) procedure (abs (x real?) ) ⟹ number?

The abs procedure returns the absolute value of its argument.

(scheme base) syntax (and () ((_ test1 ...)) )

Semantics: The test expressions are evaluated from left to right, and if any expression evaluates to #f (see section 6.3), then #f is returned. Any remaining expressions are not evaluated. If all the expressions evaluate to true values, the values of the last expression are returned. If there are no expressions, then #t is returned.

(scheme base) procedure (append (list list?) ... ) ⟹ list?

(scheme base) procedure (append (list list?) ... obj ) ⟹ *

Returns a list consisting of the elements of the first list followed by the elements of the other list s. If there are no arguments, the empty list is returned. If there is exactly one argument, it is returned. Otherwise the resulting list is always newly allocated, except that it shares structure with the last argument. An improper list results if the last argument is not a proper list.

(scheme base) procedure (apply (proc procedure?) arg1 ... (args list?) ) ⟹ *

The apply procedure calls proc with the elements of the list

(scheme base) procedure (assoc obj (alist list?) ) ⟹ pair? / #f /

(scheme base) procedure (assoc obj (alist list?) (= procedure?) ) ⟹ pair? / #f /

(= a b ) ⟹ *

It is an error if alist (for "association list") is not a list of pairs. This procedure finds the first pair in alist whose car field is obj, and returns that pair. If no pair in alist has obj as its car, then #f (not the empty list) is returned. The assoc procedure uses compare if given and equal? otherwise. Rationale: Although they are often used as predicates, memq, memv, member, assq, assv, and assoc do not have question marks in their names because they return potentially useful values rather than just #t or #f.

(scheme base) procedure (assq obj (alist list?) ) ⟹ pair? / #f /

It is an error if alist (for "association list") is not a list of pairs. This procedure finds the first pair in alist whose car field is obj, and returns that pair. If no pair in alist has obj as its car, then #f (not the empty list) is returned. The assq procedure uses eq? to compare obj with the car fields of the pairs in alist. Rationale: Although they are often used as predicates, memq, memv, member, assq, assv, and assoc do not have question marks in their names because they return potentially useful values rather than just #t or #f.

(scheme base) procedure (assv obj (alist list?) ) ⟹ pair? / #f /

It is an error if alist (for "association list") is not a list of pairs. This procedure finds the first pair in alist whose car field is obj, and returns that pair. If no pair in alist has obj as its car, then #f (not the empty list) is returned. The assv procedure uses eqv? to compare obj with the car fields of the pairs in alist. Rationale: Although they are often used as predicates, memq, memv, member, assq, assv, and assoc do not have question marks in their names because they return potentially useful values rather than just #t or #f.

(scheme base) syntax (begin () ((_ expression-or-definition ...)) )

This form of begin can be used as an ordinary expression. The expressions are evaluated sequentially from left to right, and the values of the last expression are returned. This expression type is used to sequence side effects such as assignments or input and output. Note that there is another form of begin used as a library declaration: see section 5.6.1.

(scheme base) procedure (boolean=? (boolean1 boolean?) (boolean2 boolean?) (boolean3 boolean?) ... ) ⟹ boolean?

Returns #t if all the arguments are booleans and all are #t or all are #f.

(scheme base) procedure (boolean? obj ) ⟹ boolean?

The boolean? predicate returns #t if obj is either #t or #f and returns #f otherwise.

(scheme base) procedure (bytevector (byte integer?) ... ) ⟹ bytevector?

Returns a newly allocated bytevector containing its arguments.

(scheme base) procedure (bytevector-append (bytevector bytevector?) ... ) ⟹ bytevector?

Returns a newly allocated bytevector whose elements are the concatenation of the elements in the given bytevectors.

(scheme base) procedure (bytevector-copy (bytevector bytevector?) ) ⟹ bytevector?

(scheme base) procedure (bytevector-copy (bytevector bytevector?) (start integer?) ) ⟹ bytevector?

(scheme base) procedure (bytevector-copy (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ bytevector?

Returns a newly allocated bytevector containing the bytes in bytevector between start and end.

(scheme base) procedure (bytevector-copy! (to bytevector?) (at integer?) (from bytevector?) ) ⟹ undefined

(scheme base) procedure (bytevector-copy! (to bytevector?) (at integer?) (from bytevector?) (start integer?) ) ⟹ undefined

(scheme base) procedure (bytevector-copy! (to bytevector?) (at integer?) (from bytevector?) (start integer?) (end integer?) ) ⟹ undefined

Copies the bytes of bytevector from between start and end to bytevector to, starting at at. The order in which bytes are copied is unspecified, except that if the source and destination overlap, copying takes place as if the source is first copied into a temporary bytevector and then into the destination. This can be achieved without allocating storage by making sure to copy in the correct direction in such circumstances. Note: This procedure appears in R6RS, but places the source before the destination, contrary to other such procedures in Scheme.

(scheme base) procedure (bytevector-length (bytevector bytevector?) ) ⟹ integer?

Returns the length of bytevector in bytes as an exact integer.

(scheme base) procedure (bytevector-u8-ref (bytevector bytevector?) (k integer?) ) ⟹ integer?

It is an error if k is not a valid index of bytevector. Returns the kth byte of bytevector.

(scheme base) procedure (bytevector-u8-set! (bytevector bytevector?) (k integer?) (byte integer?) ) ⟹ undefined

It is an error if k is not a valid index of bytevector. Stores byte as the kth byte of bytevector.

(scheme base) procedure (bytevector? obj ) ⟹ boolean?

Returns #t if obj is a bytevector. Otherwise, #f is returned.

(scheme base) procedure (caar (pair pair?) ) ⟹ *

This procedure is composition of car and car

(scheme base) procedure (cadr (pair pair?) ) ⟹ *

This procedure is composition of car and cdr

(scheme base) procedure (call-with-current-continuation (proc procedure?) ) ⟹ *

(proc (k procedure?) ) ⟹ *

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.

(scheme base) procedure (call-with-port (port port?) (proc procedure?) ) ⟹ *

(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.

(scheme base) procedure (call-with-values (producer procedure?) (consumer procedure?) ) ⟹ *

(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.

(scheme base) procedure (call/cc (proc procedure?) ) ⟹ *

(proc (k procedure?) ) ⟹ *

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.

(scheme base) procedure (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.

(scheme base) syntax (case (=> else ) ((_ key clause1 clause2 ...)) )

((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.

(scheme base) procedure (cdar (pair pair?) ) ⟹ *

This procedure is composition of cdr and car

(scheme base) procedure (cddr (pair pair?) ) ⟹ *

This procedure is composition of cdr and cdr

(scheme base) procedure (cdr (pair pair?) ) ⟹ *

Returns the contents of the cdr field of pair . Note that it is an error to take the cdr of the empty list.

(scheme base) procedure (ceiling (x real?) ) ⟹ real?

The ceiling procedure returns the smallest integer not smaller than x. Note: If the argument is inexact, then the result will also be inexact. If an exact value is needed, the result can be passed to the exact procedure. If the argument is infinite or a NaN, then it is returned.

(scheme base) procedure (char->integer (char char?) ) ⟹ integer?

Given a Unicode character, char->integer returns an exact integer between 0 and #xD7FF or between #xE000 and #x10FFFF which is equal to the Unicode scalar value of that character. Given a non-Unicode character, it returns an exact integer greater than #x10FFFF. This is true independent of whether the implementation uses the Unicode representation internally. Given an exact integer that is the value returned by a character when char->integer is applied to it, integer->char returns that character.

(scheme base) procedure (char-ready? ) ⟹ boolean?

(scheme base) procedure (char-ready? (port input-port?) ) ⟹ boolean?

Returns #t if a character is ready on the textual input port and returns #f otherwise. If char-ready returns #t then the next read-char operation on the given port is guaranteed not to hang. If the port is at end of file then char-ready? returns #t. Rationale: The char-ready? procedure exists to make it possible for a program to accept characters from interactive ports without getting stuck waiting for input. Any input editors associated with such ports must ensure that characters whose existence has been asserted by char-ready? cannot be removed from the input. If char-ready? were to return #f at end of file, a port at end of file would be indistinguishable from an interactive port that has no ready characters.

(scheme base) procedure (char<=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

This procedure returns #t if the results of passing their arguments to char->integer are monotonically non-decreasing. This predicate is required to be transitive.

(scheme base) procedure (char<? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

This procedure returns #t if the results of passing their arguments to char->integer are monotonically increasing. This predicate is required to be transitive.

(scheme base) procedure (char=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

This procedure returns #t if the results of passing their arguments to char->integer are equal. This predicate is required to be transitive.

(scheme base) procedure (char>=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

This procedure returns #t if the results of passing their arguments to char->integer are monotonically non-increasing. This predicate is required to be transitive.

(scheme base) procedure (char>? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

This procedure returns #t if the results of passing their arguments to char->integer are monotonically decreasing. This predicate is required to be transitive.

(scheme base) procedure (char? obj ) ⟹ boolean?

Returns #t if obj is a character, otherwise returns #f.

(scheme base) procedure (close-input-port (port input-port?) ) ⟹ undefined

Closes the resource associated with port, rendering the port incapable of delivering data. It is an error to apply the procedure to a port which is not an input port. Scheme implementations may provide ports which are simultaneously input and output ports, such as sockets; the close-input-port and close-output-port procedures can then be used to close the input and output sides of the port independently. The routine has no effect if the port has already been closed.

(scheme base) procedure (close-output-port (port output-port?) ) ⟹ undefined

Closes the resource associated with port, rendering the port incapable of accepting data. It is an error to apply the procedure to a port which is not an output port. Scheme implementations may provide ports which are simultaneously input and output ports, such as sockets; the close-input-port and close-output-port procedures can then be used to close the input and output sides of the port independently. The routine has no effect if the port has already been closed.

(scheme base) procedure (close-port (port port?) ) ⟹ undefined

Closes the resource associated with port, rendering the port incapable of delivering or accepting data. This routine has no effect if the port has already been closed.

(scheme base) syntax (cond (else => ) ((_ clause1 clause2 ...)) )

(test expression1 ...) (test => receiver) (else expression1 expression2 ...)

receiver ⟹ procedure?

A cond expression is evaluated by evaluating the test expressions of successive clauses in order until one of them evaluates to a true value (see section 6.3). When a test evaluates to a true value, the remaining expressions 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 expressions, 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 tests 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 expressions are evaluated in order, and the values of the last one are returned.

(scheme base) procedure (cons obj1 obj2 ) ⟹ pair?

Returns a newly allocated pair whose car is obj1 and whose cdr is obj2. The pair is guaranteed to be different(sense of eqv?) from every existing object.

(scheme base) syntax (define () ((_ variable expression)) ((_ (variable parameter1 ...) body)) ((_ (variable parameter1 ... . parameter) body)) )

At the outermost level of a program, a definition (define variable expression) has essentially the same effect as the assignment expression (set! variable expression) if variable is bound to a non-syntax value. However, if variable is not bound, or is a syntactic keyword, then the definition will bind variable to a new location before performing the assignment, whereas it would be an error to perform a set! on an unbound variable. Definitions can occur at the beginning of a body (that is, the body of a lambda, let, let*, letrec, letrec*, let-values, let*-values, let-syntax, letrec-syntax, parameterize, guard, or case-lambda). Note that such a body might not be apparent until after expansion of other syntax. Such definitions are known as internal definitions as opposed to the global definitions described above. The variables defined by internal definitions are local to the body That is, variable is bound rather than assigned, and the region of the binding is the entire body. An expanded body containing internal definitions can always be converted into a completely equivalent letrec* expression. Just as for the equivalent letrec* expression, it is an error if it is not possible to evaluate each expression of every internal definition in a body without assigning or referring to the value of the corresponding variable or the variable of any of the definitions that follow it in body. It is an error to define the same identifier more than once in the same body. Wherever an internal definition can occur, (begin definition1 ...) is equivalent to the sequence of definitions that form the body of the begin.

(scheme base) syntax (define-syntax () ((_ keyword transformer-spec)) )

transformer-spec ⟹ transformer-spec

If the define-syntax occurs at the outermost level, then the global syntactic environment is extended by binding the keyword to the specified transformer, but previous expansions of any global binding for keyword remain unchanged. Otherwise, it is an internal syntax definition, and is local to the body in which it is defined. Any use of a syntax keyword before its corresponding definition is an error. In particular, a use that precedes an inner definition will not apply an outer definition. Macros can expand into definitions in any context that permits them. However, it is an error for a definition to define an identifier whose binding has to be known in order to determine the meaning of the definition itself, or of any preceding definition that belongs to the same group of internal definitions. Similarly, it is an error for an internal definition to define an identifier whose binding has to be known in order to determine the boundary between the internal definitions and the expressions of the body it belongs to.

(scheme base) syntax (define-values () ((_ formals expression)) )

(variable1 ...) variable (variable1 ... variable_n . variable_n+1)

Another kind of definition is provided by define-values, which creates multiple definitions from a single expression returning multiple values. It is allowed wherever define is allowed. It is an error if a variable appears more than once in the set of formals. Semantics: Expression is evaluated, and the formals are bound to the return values in the same way that the formals in a lambda expression are matched to the arguments in a procedure call.

(scheme base) procedure (denominator (q rational?) ) ⟹ integer?

This procedure returns the denominator of its argument; the result is computed as if the argument was represented as a fraction in lowest terms. The denominator is always positive. The denominator of 0 is defined to be 1.

(scheme base) syntax (do () ((_ (variable-decl1 ...) (test expression ...) command ...)) )

(variable init step) (variable init)

A do expression is an iteration construct. It specifies a set of variables to be bound, how they are to be initialized at the start, and how they are to be updated on each iteration. When a termination condition is met, the loop exits after evaluating the expressions. A do expression is evaluated as follows: The init expressions are evaluated (in some unspecified order), the variables are bound to fresh locations, the results of the init expressions are stored in the bindings of the variables, and then the iteration phase begins. Each iteration begins by evaluating test; if the result is false (see section 6.3), then the command expressions are evaluated in order for effect, the step expressions are evaluated in some unspecified order, the variables are bound to fresh locations, the results of the steps are stored in the bindings of the variables, and the next iteration begins. If test evaluates to a true value, then the expressions are evaluated from left to right and the values of the last expression are returned. If no expressions are present, then the value of the do expression is unspecified. The region of the binding of a variable consists of the entire do expression except for the inits. It is an error for a variable to appear more than once in the list of do variables. A step can be omitted, in which case the effect is the same as if (variable init variable) had been written instead of (variable init).

(scheme base) procedure (dynamic-wind (before procedure?) (thunk procedure?) (after procedure?) ) ⟹ *

(before ) ⟹ undefined

(thunk ) ⟹ *

(after ) ⟹ undefined

Calls thunk without arguments, returning the result(s) of this call. Before and after are called, also without arguments, as required by the following rules. Note that, in the absence of calls to continuations captured using call-with-current-continuation, the three arguments are called once each, in order. Before is called whenever execution enters the dynamic extent of the call to thunk and after is called whenever it exits that dynamic extent. The dynamic extent of a procedure call is the period between when the call is initiated and when it returns. The before and after thunks are called in the same dynamic environment as the call to dynamic-wind. In Scheme, because of call-with-current-continuation, the dynamic extent of a call is not always a single, connected time period. It is defined as follows: 1) The dynamic extent is entered when execution of the body of the called procedure begins; 2) The dynamic extent is also entered when execution is not within the dynamic extent and a continuation is invoked that was captured (using call-with-current-continuation) during the dynamic extent; 3) It is exited when the called procedure returns; 4) It is also exited when execution is within the dynamic extent and a continuation is invoked that was captured while not within the dynamic extent. If a second call to dynamic-wind occurs within the dynamic extent of the call to thunk and then a continuation is invoked in such a way that the after s from these two invocations of dynamic-wind are both to be called, then the after associated with the second (inner) call to dynamic-wind is called first. If a second call to dynamic-wind occurs within the dynamic extent of the call to thunk and then a continuation is invoked in such a way that the befores from these two invocations of dynamic-wind are both to be called, then the before associated with the first (outer) call to dynamic-wind is called first. If invoking a continuation requires calling the before from one call to dynamic-wind and the after from another, then the after is called first. The ect of using a captured continuation to enter or exit the dynamic extent of a call to before or after is unspecified.

(scheme base) procedure (eof-object ) ⟹ eof-object?

Returns an end-of-file object, not necessarily unique.

(scheme base) procedure (eof-object? obj ) ⟹ boolean?

Returns #t if obj is an end-of-file object, otherwise returns #f. The precise set of end-of-file objects will vary among implementations, but in any case no end-of-file object will ever be an object that can be read in using read.

(scheme base) procedure (eq? obj1 obj2 ) ⟹ boolean?

The eq? procedure is similar to eqv? except that in some cases it is capable of discerning distinctions finer than those detectable by eqv?. It must always return #f when eqv? also would, but may return #f in some cases where eqv? would return #t. On symbols, booleans, the empty list, pairs, and records, and also on non-empty strings, vectors, and bytevectors, eq? and eqv? are guaranteed to have the same behavior. On procedures, eq? must return true if the arguments' location tags are equal. On numbers and characters, eq?'s behavior is implementation-dependent, but it will always return either true or false. On empty strings, empty vectors, and empty bytevectors, eq? may also behave differently from eqv?.

(scheme base) procedure (equal? obj1 obj2 ) ⟹ boolean?

The equal? procedure, when applied to pairs, vectors, strings and bytevectors, recursively compares them, returning #t when the unfoldings of its arguments into (possibly infinite) trees are equal (in the sense of equal? ) as ordered trees, and #f otherwise. It returns the same as eqv? when applied to booleans, symbols, numbers, characters, ports, procedures, and the empty list. If two objects are eqv? , they must be equal? as well. In all other cases, equal? may return either #t or #f. Note: A rule of thumb is that objects are generally equal? if they print the same.

(scheme base) procedure (eqv? obj1 obj2 ) ⟹ boolean?

The eqv? procedure defines a useful equivalence relation on objects. Briefly, it returns #t if obj1 and obj2 are normally regarded as the same object. This relation is left slightly open to interpretation, but the following partial specification of eqv? holds for all implementations of Scheme. The eqv? procedure returns #t if: obj1 and obj2 are both #t or both #f; obj1 and obj2 are both symbols and are the same symbol according to the symbol=? procedure (section 6.5); obj1 and obj2 are both exact numbers and are numerically equal (in the sense of =); obj1 and obj2 are both inexact numbers such that they are numerically equal (in the sense of =) and they yield the same results (in the sense of eqv?) when passed as arguments to any other procedure that can be defined as a finite composition of Scheme's standard arithmetic procedures, provided it does not result in a NaN value; obj1 and obj2 are both characters and are the same character according to the char=? procedure (section 6.6); obj1 and obj2 are both the empty list; obj1 and obj2 are pairs, vectors, bytevectors, records, or strings that denote the same location in the store (section 3.4); obj1 and obj2 are procedures whose location tags are equal (section 4.1.4). The eqv? procedure returns #f if: obj1 and obj2 are of different types (section 3.2); one of obj1 and obj2 is #t but the other is #f; obj1 and obj2 are symbols but are not the same symbol according to the symbol=? procedure (section 6.5); one of obj1 and obj2 is an exact number but the other is an inexact number; obj1 and obj2 are both exact numbers and are numerically unequal (in the sense of =); obj1 and obj2 are both inexact numbers such that either they are numerically unequal (in the sense of =), or they do not yield the same results (in the sense of eqv?) when passed as arguments to any other procedure that can be defined as a finite composition of Scheme's standard arithmetic procedures, provided it does not result in a NaN value. As an exception, the behavior of eqv? is unspecified when both obj1 and obj2 are NaN; obj1 and obj2 are characters for which the char=? procedure returns #f; one of obj1 and obj2 is the empty list but the other is not; obj1 and obj2 are pairs, vectors, bytevectors, records, or strings that denote distinct locations; obj1 and obj2 are procedures that would behave differently (return different values or have different side effects) for some arguments.

(scheme base) procedure (error-object-irritants (error-object error-object?) ) ⟹ list?

Returns a list of the irritants encapsulated by error-object.

(scheme base) procedure (error-object-message (error-object error-object?) ) ⟹ string?

Returns the message encapsulated by error-object.

(scheme base) procedure (error-object? obj ) ⟹ boolean?

Returns #t if obj is an object created by error or one of an implementation-defined set of objects. Otherwise, it returns #f. The objects used to signal errors, including those which satisfy the predicates file-error? and read-error?, may or may not satisfy error-object?.

(scheme base) procedure (exact (z number?) ) ⟹ exact?

The procedure exact returns an exact representation of z. The value returned is the exact number that is numerically closest to the argument. For exact arguments, the result is the same as the argument. For inexact nonintegral real arguments, the implementation may return a rational approximation, or may report an implementation violation. For inexact complex arguments, the result is a complex number whose real and imaginary parts are the result of applying exact to the real and imaginary parts of the argument, respectively. If an inexact argument has no reasonably close exact equivalent, (in the sense of =), then a violation of an implementation restriction may be reported.

(scheme base) procedure (exact-integer-sqrt (k integer?) ) ⟹ (values integer?integer?)

Returns two non-negative exact integers s and r where k = s^2 + r and k < (s + 1)^2.

(scheme base) procedure (exact-integer? (z number?) ) ⟹ boolean?

Returns #t if z is both exact and an integer; otherwise returns #f.

(scheme base) procedure (exact? (z number?) ) ⟹ boolean?

This numerical predicate provides tests for the exactness of a quantity. For any Scheme number, precisely one of exact? or inexact? predicates is true.

(scheme base) procedure (expt (z1 number?) (z2 number?) ) ⟹ number?

Returns z1 raised to the power z2.

(scheme base) procedure (features ) ⟹ list?

Returns a list of the feature identifiers which cond-expand treats as true. It is an error to modify this list.

(scheme base) procedure (file-error? obj ) ⟹ boolean?

Error type predicate. Returns #t if obj is an object raised by the inability to open an input or output port on a file. Otherwise, it returns #f.

(scheme base) procedure (floor (x real?) ) ⟹ integer?

The floor procedure returns the largest integer not larger than x. Note: If the argument is inexact, then the result will also be inexact. If an exact value is needed, the result can be passed to the exact procedure. If the argument is infinite or a NaN, then it is returned.

(scheme base) procedure (floor-quotient (n1 integer?) (n2 integer?) ) ⟹ integer?

This procedure implements number-theoretic (integer) division. It is an error if n2 is zero. The procedure computes a quotient nq and remainder nr such that n1 = n2 * nq + nr.

(scheme base) procedure (floor-remainder (n1 integer?) (n2 integer?) ) ⟹ integer?

This procedure implements number-theoretic (integer) division. It is an error if n2 is zero. The procedure computes a quotient nq and remainder nr such that n1 = n2 * nq + nr.

(scheme base) procedure (floor/ (n1 integer?) (n2 integer?) ) ⟹ (values integer?integer?)

This procedure implements number-theoretic (integer) division. It is an error if n2 is zero. The procedure computes a quotient nq and remainder nr such that n1 = n2 * nq + nr.

(scheme base) procedure (flush-output-port ) ⟹ undefined

(scheme base) procedure (flush-output-port (port output-port?) ) ⟹ undefined

Flushes any buffered output from the buffer of output-port to the underlying file or device and returns an unspecified value.

(scheme base) procedure (for-each (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ undefined

(proc obj1 obj2 ... ) ⟹ undefined

It is an error if proc does not accept as many arguments as there are lists. The arguments to for-each are like the arguments to map, but for-each calls proc for its side ects rather than for its values. Unlike map, for-each is guaranteed to call proc on the elements of the lists in order from the first element( s) to the last, and the value returned by for-each is unspecified. If more than one list is given and not all lists have the same length, for-each terminates when the shortest list runs out. It is an error for proc to mutate any of the lists.

(scheme base) procedure (gcd (n integer?) ... ) ⟹ integer?

This procedure returns the greatest common divisor of its arguments. The result is always non-negative.

(scheme base) procedure (get-output-bytevector (port output-port?) ) ⟹ bytevector?

It is an error if port was not created with open-output-bytevector. Returns a bytevector consisting of the bytes that have been output to the port so far in the order they were output.

(scheme base) syntax (if () ((_ test consequent)) ((_ test consequent alternate)) )

An if expression is evaluated as follows: first, test is evaluated. If it yields a true value (see section 6.3), then consequent is evaluated and its values are returned. Otherwise alternate is evaluated and its values are returned. If test yields a false value and no alternate is specified, then the result of the expression is unspecified.

(scheme base) syntax (include () ((_ string1 string2 ...)) )

Include takes one or more filenames expressed as string literals, applies an implementation-specific algorithm to find corresponding files, reads the contents of the files in the specified order as if by repeated applications of read, and effectively replaces the include expression with a begin expression containing what was read from the files. Note: Implementations are encouraged to search for files in the directory which contains the including file, and to provide a way for users to specify other directories to search.

(scheme base) syntax (include-ci () ((_ string1 string2 ...)) )

Include-ci takes one or more filenames expressed as string literals, applies an implementation-specific algorithm to find corresponding files, reads the contents of the files in the specified order as if by repeated applications of read, and effectively replaces the include-ci expression with a begin expression containing what was read from the files. Include-ci reads each file as if it began with the #!fold-case directive. Note: Implementations are encouraged to search for files in the directory which contains the including file, and to provide a way for users to specify other directories to search.

(scheme base) procedure (inexact (z number?) ) ⟹ inexact?

The procedure inexact returns an inexact representation of z. The value returned is the inexact number that is numerically closest to the argument. For inexact arguments, the result is the same as the argument. For exact complex numbers, the result is a complex number whose real and imaginary parts are the result of applying inexact to the real and imaginary parts of the argument, respectively. If an exact argument has no reasonably close inexact equivalent (in the sense of =), then a violation of an implementation restriction may be reported.

(scheme base) procedure (inexact? (z number?) ) ⟹ boolean?

This numerical predicate provides tests for the exactness of a quantity. For any Scheme number, precisely one of exact? and inexact? predicates is true.

(scheme base) procedure (input-port-open? (port input-port?) ) ⟹ boolean?

Returns #t if port is still open and capable of performing input, and #f otherwise.

(scheme base) procedure (integer->char (n integer?) ) ⟹ char?

Given an exact integer that is the value returned by a character when char->integer is applied to it, integer->char returns that character.

(scheme base) syntax (lambda () ((_ formals body) procedure?) )

(variable1 ...) variable (variable1 ... variable_n . variable_n+1)

A lambda expression evaluates to a procedure. The environment in effect when the lambda expression was evaluated is remembered as part of the procedure. When the procedure is later called with some actual arguments, the environment in which the lambda expression was evaluated will be extended by binding the variables in the formal argument list to fresh locations, and the corresponding actual argument values will be stored in those locations. (A fresh location is one that is distinct from every previously existing location.) Next, the expressions in the body of the lambda expression (which, if it contains definitions, represents a letrec* form -- see section 4.2.2) will be evaluated sequentially in the extended environment. The results of the last expression in the body will be returned as the results of the procedure call. Each procedure created as the result of evaluating a lambda expression is (conceptually) tagged with a storage location, in order to make eqv? and eq? work on procedures (see section 6.1).

(scheme base) procedure (lcm (n integer?) ... ) ⟹ integer?

This procedure returns the least common multiple of its arguments. The result is always non-negative.

(scheme base) procedure (length (list list?) ) ⟹ integer?

Returns the length of list.

(scheme base) syntax (let () ((_ ((var1 init1) ...) body)) ((_ name ((var1 init1) ...) body)) )

The inits are evaluated in the current environment (in some unspecified order), the variables are bound to fresh locations holding the results, the body is evaluated in the extended environment, and the values of the last expression of body are returned. Each binding of a variable has body as its region. "Named let" is a variant on the syntax of let which provides a more general looping construct than do and can also be used to express recursion. It has the same syntax and semantics as ordinary let except that variable is bound within body to a procedure whose formal arguments are the bound variables and whose body is body. Thus the execution of body can be repeated by invoking the procedure named by variable.

(scheme base) syntax (let* () ((_ bindings body)) )

((variable1 init1) ...)

The let* binding construct is similar to let, but the bindings are performed sequentially from left to right, and the region of a binding indicated by (variable init) is that part of the let* expression to the right of the binding. Thus the second binding is done in an environment in which the first binding is visible, and so on. The variables need not be distinct.

(scheme base) syntax (let-syntax () ((_ bindings body)) )

((keyword transformer-spec) ...)

transformer-spec ⟹ transformer-spec

The body is expanded in the syntactic environment obtained by extending the syntactic environment of the let-syntax expression with macros whose keywords are the keywords, bound to the specified transformers. Each binding of a keyword has body as its region.

(scheme base) syntax (letrec () ((_ bindings body)) )

((variable1 init1) ...)

The variables are bound to fresh locations holding unspecified values, the inits 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 values of the last expression in body are returned. Each binding of a variable has the entire letrec expression as its region, making it possible to define mutually recursive procedures.

(scheme base) syntax (letrec* () ((_ bindings body)) )

((variable1 init1) ...)

The variables are bound to fresh locations, each variable is assigned in left-to-right order to the result of evaluating the corresponding init, the body is evaluated in the resulting environment, and the values of the last expression in body are returned. Despite the left-to-right evaluation and assignment order, each binding of a variable has the entire letrec* expression as its region, making it possible to define mutually recursive procedures. If it is not possible to evaluate each init without assigning or referring to the value of the corresponding variable or the variable of any of the bindings that follow it in bindings, it is an error. Another restriction is that it is an error to invoke the continuation of an init more than once.

(scheme base) syntax (letrec-syntax () ((_ bindings body)) )

((keyword transformer-spec) ...)

The body is expanded in the syntactic environment obtained by extending the syntactic environment of the letrec-syntax expression with macros whose keywords are the keywords, bound to the specified transformers. Each binding of a keyword has the transformer specs as well as the body within its region, so the transformers can transcribe expressions into uses of the macros introduced by the letrec-syntax expression.

(scheme base) procedure (list obj ... ) ⟹ list?

Returns a newly allocated list of its arguments.

(scheme base) procedure (list->string (list list?) ) ⟹ string?

list ⟹ (list (c char?))

list->string returns a newly allocated string formed from the elements in the list list. The order is preserved. string->list and list->string are inverses so far as equal? is concerned.

(scheme base) procedure (list->vector (list list?) ) ⟹ vector?

The list->vector procedure returns a newly created vector initialized to the elements of the list list. The order is preserved.

(scheme base) procedure (list-copy obj ) ⟹ *

Returns a newly allocated copy of the given obj if it is a list. Only the pairs themselves are copied; the cars of the result are the same (in the sense of eqv?) as the cars of list . If obj is an improper list, so is the result, and the final cdrs are the same in the sense of eqv?. An obj which is not a list is returned unchanged. It is an error if obj is a circular list.

(scheme base) procedure (list-ref (list list?) (k integer?) ) ⟹ *

It is an error if list has fewer than k elements. Returns the kth element of list. (This is the same as the car of (list-tail list k).)

(scheme base) procedure (list-set! (list list?) (k integer?) obj ) ⟹ undefined

It is an error if k is not a valid index of list. The list-set! procedure stores obj in element k of list.

(scheme base) procedure (list-tail (list list?) (k integer?) ) ⟹ list?

It is an error if list has fewer than k elements. Returns the sublist of list obtained by omitting the first k elements.

(scheme base) procedure (list? obj ) ⟹ boolean?

Returns #t if obj is a list. Otherwise, it returns #f. By definition, all lists have finite length and are terminated by the empty list.

(scheme base) procedure (make-bytevector (k integer?) ) ⟹ bytevector?

(scheme base) procedure (make-bytevector (k integer?) (byte integer?) ) ⟹ bytevector?

The make-bytevector procedure returns a newly allocated bytevector of length k. If byte is given, then all elements of the bytevector are initialized to byte, otherwise the contents of each element are unspecified.

(scheme base) procedure (make-list (k integer?) ) ⟹ list?

(scheme base) procedure (make-list (k integer?) obj ) ⟹ list?

Returns a newly allocated list of k elements. If a second argument is given, then each element is initialized to fill. Otherwise the initial contents of each element is unspecified.

(scheme base) procedure (make-string (k integer?) ) ⟹ string?

(scheme base) procedure (make-string (k integer?) (char char?) ) ⟹ string?

The make-string procedure returns a newly allocated string of length k. If char is given, then all the characters of the string are initialized to char, otherwise the contents of the string are unspecified.

(scheme base) procedure (make-vector (k integer?) ) ⟹ vector?

(scheme base) procedure (make-vector (k integer?) fill ) ⟹ vector?

Returns a newly allocated vector of k elements. If a second argument is given, then each element is initialized to fill . Otherwise the initial contents of each element is unspeci- fied.

(scheme base) procedure (map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?

(proc obj1 obj2 ... ) ⟹ *

It is an error if proc does not accept as many arguments as there are lists and return a single value. The map procedure applies proc element-wise to the elements of the lists and returns a list of the results, in order. If more than one list is given and not all lists have the same length, map terminates when the shortest list runs out. It is an error for proc to mutate any of the lists. The dynamic order in which proc is applied to the elements of the lists is unspecified. If multiple returns occur from map, the values returned by earlier returns are not mutated.

(scheme base) procedure (max (x1 real?) (x2 real?) ... ) ⟹ real?

This procedure returns the maximum of its arguments. Note: If any argument is inexact, then the result will also be inexact (unless the procedure can prove that the inaccuracy is not large enough to affect the result, which is possible only in unusual implementations). If min or max is used to compare numbers of mixed exactness, and the numerical value of the result cannot be represented as an inexact number without loss of accuracy, then the procedure may report a violation of an implementation restriction.

(scheme base) procedure (member obj (list list?) ) ⟹ #f / list? /

(scheme base) procedure (member obj (list list?) (compare procedure?) ) ⟹ #f / list? /

(compare obj1 obj2 ) ⟹ *

This procedure returns the first sublist of list whose car is obj , where the sublists of list are the non-empty lists returned by (list-tail list k) for k less than the length of list . If obj does not occur in list , then #f (not the empty list) is returned. The member procedure uses compare, if given, and equal? otherwise to compare obj with the elements of list.

(scheme base) procedure (memq obj (list list?) ) ⟹ #f / list? /

This procedure returns the first sublist of list whose car is obj , where the sublists of list are the non-empty lists returned by (list-tail list k) for k less than the length of list . If obj does not occur in list , then #f (not the empty list) is returned. The memq procedure uses eq? to compare obj with the elements of list.

(scheme base) procedure (memv obj (list list?) ) ⟹ #f / list? /

This procedure returns the first sublist of list whose car is obj , where the sublists of list are the non-empty lists returned by (list-tail list k) for k less than the length of list . If obj does not occur in list , then #f (not the empty list) is returned. The memv procedure uses eqv? to compare obj with the elements of list.

(scheme base) procedure (min (x1 real?) (x2 real?) ... ) ⟹ real?

This procedure returns the minimum of its arguments. Note: If any argument is inexact, then the result will also be inexact (unless the procedure can prove that the inaccuracy is not large enough to affect the result, which is possible only in unusual implementations). If min or max is used to compare numbers of mixed exactness, and the numerical value of the result cannot be represented as an inexact number without loss of accuracy, then the procedure may report a violation of an implementation restriction.

(scheme base) procedure (modulo (n1 integer?) (n2 integer?) ) ⟹ integer?

The modulo is equivalent to floor-remainder.

(scheme base) procedure (newline ) ⟹ undefined

(scheme base) procedure (newline (port output-port?) ) ⟹ undefined

Writes an end of line to textual output port. Returns an unspecified value.

(scheme base) procedure (not obj ) ⟹ boolean?

The not procedure returns #t if obj is false, and returns #f otherwise.

(scheme base) procedure (null? obj ) ⟹ boolean?

Returns #t if obj is the empty list, otherwise returns #f.

(scheme base) procedure (number->string (z number?) ) ⟹ string?

(scheme base) procedure (number->string (z number?) (radix integer?) ) ⟹ string?

It is an error if radix is not one of 2, 8, 10, or 16. The procedure number->string takes a number and a radix and returns as a string an external representation of the given number in the given radix. It is an error if no possible result makes this expression true. If omitted, radix defaults to 10. If z is inexact, the radix is 10, and the above expression can be satisfied by a result that contains a decimal point, then the result contains a decimal point and is expressed using the minimum number of digits (exclusive of exponent and trailing zeroes) needed to make the above expression true [4, 5]; otherwise the format of the result is unspecified. The result returned by number->string never contains an explicit radix prefix. Note: The error case can occur only when z is not a complex number or is a complex number with a non-rational real or imaginary part. Rationale: If z is an inexact number and the radix is 10, then the above expression is normally satisfied by a result containing a decimal point. The unspecified case allows for infinities, NaNs, and unusual representations.

(scheme base) procedure (numerator (q rational?) ) ⟹ integer?

This procedure returns the numerator of its argument; the result is computed as if the argument was represented as a fraction in lowest terms.

(scheme base) procedure (open-input-bytevector (bytevector bytevector?) ) ⟹ input-port?

Takes a bytevector and returns a binary input port that delivers bytes from the bytevector.

(scheme base) procedure (open-output-bytevector ) ⟹ output-port?

Returns a binary output port that will accumulate bytes for retrieval by get-output-bytevector.

(scheme base) syntax (or () ((_ test1 ...)) )

The test expressions are evaluated from left to right, and the value of the first expression that evaluates to a true value (see section 6.3) is returned. Any remaining expressions are not evaluated. If all expressions evaluate to #f or if there are no expressions, then #f is returned.

(scheme base) procedure (output-port-open? (port output-port?) ) ⟹ boolean?

Returns #t if port is still open and capable of performing output, and #f otherwise.

(scheme base) procedure (pair? obj ) ⟹ boolean?

The pair? predicate returns #t if obj is a pair, and otherwise returns #f.

(scheme base) procedure (peek-char ) ⟹ eof-object? / char? /

(scheme base) procedure (peek-char (port input-port?) ) ⟹ eof-object? / char? /

Returns the next character available from the textual input port, but without updating the port to point to the following character. If no more characters are available, an end-of-file object is returned. Note: The value returned by a call to peek-char is the same as the value that would have been returned by a call to read-char with the same port. The only diㄦence is that the very next call to read-char or peek-char on that port will return the value returned by the preceding call to peek-char. In particular, a call to peek-char on an interactive port will hang waiting for input whenever a call to read-char would have hung. (read-line) procedure

(scheme base) procedure (peek-u8 ) ⟹ eof-object? / integer? /

(scheme base) procedure (peek-u8 (port input-port?) ) ⟹ eof-object? / integer? /

Returns the next byte available from the binary input port, but without updating the port to point to the following byte. If no more bytes are available, an end-of-file object is returned.

(scheme base) procedure (procedure? obj ) ⟹ boolean?

Returns #t if obj is a procedure, otherwise returns #f.

(scheme base) syntax (quasiquote () ((_ qq-template)) )

"Quasiquote" expressions are useful for constructing a list or vector structure when some but not all of the desired structure is known in advance. If no commas appear within the qq template, the result of evaluating qq template is equivalent to the result of evaluating 'qq template. If a comma appears within the qq template, however, the expression following the comma is evaluated ("unquoted") and its result is inserted into the structure instead of the comma and the expression. If a comma appears followed without intervening whitespace by a commercial at-sign (@), then it is an error if the following expression does not evaluate to a list; the opening and closing parentheses of the list are then "stripped away" and the elements of the list are inserted in place of the comma at-sign expression sequence. A comma at-sign normally appears only within a list or vector qq template. Note: In order to unquote an identifier beginning with @, it is necessary to use either an explicit unquote or to put whitespace after the comma, to avoid colliding with the comma at-sign sequence. Quasiquote expressions can be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost quasiquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation. A quasiquote expression may return either newly allocated, mutable objects or literal structure for any structure that is constructed at run time during the evaluation of the expression. Portions that do not need to be rebuilt are always literal.

(scheme base) syntax (quote () ((_ datum)) )

(quote datum) evaluates to datum. Datum can be any external representation of a Scheme object (see section 3.3). This notation is used to include literal constants in Scheme code. (quote datum) can be abbreviated as 'datum. The two notations are equivalent in all respects. Numerical constants, string constants, character constants, vector constants, bytevector constants, and boolean constants evaluate to themselves; they need not be quoted. As noted in section 3.4, it is an error to attempt to alter a constant (i.e. the value of a literal expression) using a mutation procedure like set-car! or string-set!.

(scheme base) procedure (quotient (n1 integer?) (n2 integer?) ) ⟹ integer?

The quotient procedure is equivalent to truncate-quotient.

(scheme base) procedure (raise-continuable obj ) ⟹ undefined

Raises an exception by invoking the current exception handler on obj. The handler is called with the same dynamic environment as the call to raise-continuable, except that: (1) the current exception handler is the one that was in place when the handler being called was installed, and (2) if the handler being called returns, then it will again become the current exception handler. If the handler returns, the values it returns become the values returned by the call to raise-continuable.

(scheme base) procedure (rationalize (x real?) (y real?) ) ⟹ rational?

The rationalize procedure returns the simplest rational number differing from x by no more than y.

(scheme base) procedure (read-bytevector (k integer?) ) ⟹ bytevector?

(scheme base) procedure (read-bytevector (k integer?) (port input-port?) ) ⟹ bytevector?

Reads the next k bytes, or as many as are available before the end of file, from the binary input port into a newly allocated bytevector in left-to-right order and returns the bytevector. If no bytes are available before the end of file, an end-of-file object is returned.

(scheme base) procedure (read-bytevector! (bytevector bytevector?) ) ⟹ eof-object? / integer? /

(scheme base) procedure (read-bytevector! (bytevector bytevector?) (port input-port?) ) ⟹ eof-object? / integer? /

(scheme base) procedure (read-bytevector! (bytevector bytevector?) (port input-port?) (start integer?) ) ⟹ eof-object? / integer? /

(scheme base) procedure (read-bytevector! (bytevector bytevector?) (port input-port?) (start integer?) (end integer?) ) ⟹ eof-object? / integer? /

Reads the next end − start bytes, or as many as are available before the end of file, from the binary input port into bytevector in left-to-right order beginning at the start position. If end is not supplied, reads until the end of bytevector has been reached. If start is not supplied, reads beginning at position 0. Returns the number of bytes read. If no bytes are available, an end-of-file object is returned.

(scheme base) procedure (read-char ) ⟹ eof-object? / char? /

(scheme base) procedure (read-char (port input-port?) ) ⟹ eof-object? / char? /

Returns the next character available from the textual input port, updating the port to point to the following character. If no more characters are available, an end-of-file object is returned.

(scheme base) procedure (read-error? obj ) ⟹ boolean?

read-error?, file-error? Error type predicates. Returns #t if obj is an object raised by the read procedure or by the inability to open an input or output port on a file, respectively. Otherwise, it returns #f.

(scheme base) procedure (read-line ) ⟹ eof-object? / string? /

(scheme base) procedure (read-line (port input-port?) ) ⟹ eof-object? / string? /

Returns the next line of text available from the textual input port, updating the port to point to the following character. If an end of line is read, a string containing all of the text up to (but not including) the end of line is returned, and the port is updated to point just past the end of line. If an end of file is encountered before any end of line is read, but some characters have been read, a string containing those characters is returned. If an end of file is encountered before any characters are read, an end-of-file object is returned. For the purpose of this procedure, an end of line consists of either a linefeed character, a carriage return character, or a sequence of a carriage return character followed by a linefeed character. Implementations may also recognize other end of line characters or sequences.

(scheme base) procedure (read-string (k integer?) ) ⟹ eof-object? / string? /

(scheme base) procedure (read-string (k integer?) (port input-port?) ) ⟹ eof-object? / string? /

Reads the next k characters, or as many as are available before the end of file, from the textual input port into a newly allocated string in left-to-right order and returns the string. If no characters are available before the end of file, an end-of-file object is returned.

(scheme base) procedure (read-u8 ) ⟹ eof-object? / integer? /

(scheme base) procedure (read-u8 (port input-port?) ) ⟹ eof-object? / integer? /

Returns the next byte available from the binary input port, updating the port to point to the following byte. If no more bytes are available, an end-of-file object is returned.

(scheme base) procedure (remainder (n1 integer?) (n2 integer?) ) ⟹ integer?

The remainder procedure is equivalent to truncate-remainder.

(scheme base) procedure (reverse (list list?) ) ⟹ list?

Returns a newly allocated list consisting of the elements of list in reverse order.

(scheme base) procedure (round (x real?) ) ⟹ integer?

The round returns the closest integer to x, rounding to even when x is halfway between two integers. Rationale: The round procedure rounds to even for consistency with the default rounding mode specified by the IEEE 754 IEEE floating-point standard. Note: If the argument to one of these procedures is inexact, then the result will also be inexact. If an exact value is needed, the result can be passed to the exact procedure. If the argument is infinite or a NaN, then it is returned.

(scheme base) syntax (set! () ((_ variable expression)) )

Expression is evaluated, and the resulting value is stored in the location to which variable is bound. It is an error if variable is not bound either in some region enclosing the set! expression or else globally. The result of the set! expression is unspecified.

(scheme base) procedure (set-car! (pair pair?) obj ) ⟹ undefined

Stores obj in the car field of pair.

(scheme base) procedure (set-cdr! (pair pair?) obj ) ⟹ undefined

Stores obj in the cdr field of pair.

(scheme base) procedure (square (z number?) ) ⟹ number?

Returns the square of z. This is equivalent to (* z z).

(scheme base) procedure (string (char char?) ... ) ⟹ string?

Returns a newly allocated string composed of the arguments. It is analogous to list.

(scheme base) procedure (string->list (string string?) ) ⟹ list?

(scheme base) procedure (string->list (string string?) (start integer?) ) ⟹ list?

(scheme base) procedure (string->list (string string?) (start integer?) (end integer?) ) ⟹ list?

return ⟹ (list (c char?))

The string->list procedure returns a newly allocated list of the characters of string between start and end. The order is preserved. string->list and list->string are inverses so far as equal? is concerned.

(scheme base) procedure (string->number (string string?) ) ⟹ number?

(scheme base) procedure (string->number (string string?) (radix integer?) ) ⟹ number?

Returns a number of the maximally precise representation expressed by the given string. It is an error if radix is not 2, 8, 10, or 16. If supplied, radix is a default radix that will be overridden if an explicit radix prefix is present in string (e.g. "#o177"). If radix is not supplied, then the default radix is 10. If string is not a syntactically valid notation for a number, or would result in a number that the implementation cannot represent, then string->number returns #f. An error is never signaled due to the content of string. Note: The domain of string->number may be restricted by implementations in the following ways. If all numbers supported by an implementation are real, then string->number is permitted to return #f whenever string uses the polar or rectangular notations for complex numbers. If all numbers are integers, then string->number may return #f whenever the fractional notation is used. If all numbers are exact, then string->number may return #f whenever an exponent marker or explicit exactness prefix is used. If all inexact numbers are integers, then string->number may return #f whenever a decimal point is used. The rules used by a particular implementation for string->number must also be applied to read and to the routine that reads programs, in order to maintain consistency between internal numeric processing, I/O, and the processing of programs. As a consequence, the R5RS permission to return #f when string has an explicit radix prefix has been withdrawn.

(scheme base) procedure (string->symbol (string string?) ) ⟹ symbol?

Returns the symbol whose name is string. This procedure can create symbols with names containing special characters that would require escaping when written, but does not interpret escapes in its input.

(scheme base) procedure (string->utf8 (string string?) ) ⟹ bytevector?

(scheme base) procedure (string->utf8 (string string?) (start integer?) ) ⟹ bytevector?

(scheme base) procedure (string->utf8 (string string?) (start integer?) (end integer?) ) ⟹ bytevector?

This procedure translates between strings and bytevectors that encode those strings using the UTF-8 encoding. The string->utf8 procedure encodes the characters of a string between start and end and returns the corresponding bytevector.

(scheme base) procedure (string->vector (string string?) ) ⟹ vector?

(scheme base) procedure (string->vector (string string?) (start integer?) ) ⟹ vector?

(scheme base) procedure (string->vector (string string?) (start integer?) (end integer?) ) ⟹ vector?

return ⟹ (vector (char char?))

It is an error if any element of vector between start and end is not a character. The string->vector procedure returns a newly created vector initialized to the elements of the string string between start and end. The order is preserved.

(scheme base) procedure (string-append (string string?) ... ) ⟹ string?

Returns a newly allocated string whose characters are the concatenation of the characters in the given strings.

(scheme base) procedure (string-copy (string string?) ) ⟹ string?

(scheme base) procedure (string-copy (string string?) (start integer?) ) ⟹ string?

(scheme base) procedure (string-copy (string string?) (start integer?) (end integer?) ) ⟹ string?

Returns a newly allocated copy of the part of the given string between start and end.

(scheme base) procedure (string-copy! (to string?) (at integer?) (from string?) ) ⟹ undefined

(scheme base) procedure (string-copy! (to string?) (at integer?) (from string?) (start integer?) ) ⟹ undefined

(scheme base) procedure (string-copy! (to string?) (at integer?) (from string?) (start integer?) (end integer?) ) ⟹ undefined

It is an error if at is less than zero or greater than the length of to. It is also an error if (- (string-length to) at) is less than (- end start).

Copies the characters of string from between start and end to string to, starting at at. The order in which characters are copied is unspecified, except that if the source and destination overlap, copying takes place as if the source is first copied into a temporary string and then into the destination. This can be achieved without allocating storage by making sure to copy in the correct direction in such circumstances.

(scheme base) procedure (string-fill! (string string?) (fill char?) ) ⟹ undefined

(scheme base) procedure (string-fill! (string string?) (fill char?) (start integer?) ) ⟹ undefined

(scheme base) procedure (string-fill! (string string?) (fill char?) (start integer?) (end integer?) ) ⟹ undefined

It is an error if fill is not a character. The string-fill! procedure stores fill in the elements of string between start and end.

(scheme base) procedure (string-for-each (proc procedure?) (string1 string?) (string2 string?) ... ) ⟹ undefined

(proc (string string?) ... ) ⟹ undefined

It is an error if proc does not accept as many arguments as there are strings. The arguments to string-for-each are like the arguments to string-map, but string-for-each calls proc for its side effects rather than for its values. Unlike string-map, string-for-each is guaranteed to call proc on the elements of the lists in order from the first element(s) to the last, and the value returned by string-for-each is unspecified. If more than one string is given and not all strings have the same length, string-for-each terminates when the shortest string runs out. It is an error for proc to mutate any of the strings.

(scheme base) procedure (string-length (string string?) ) ⟹ integer?

Returns the number of characters in the given string.

(scheme base) procedure (string-map (proc procedure?) (string1 string?) (string2 string?) ... ) ⟹ string?

(proc (c1 char?) ... ) ⟹ char?

It is an error if proc does not accept as many arguments as there are strings and return a single character. The string-map procedure applies proc element-wise to the elements of the strings and returns a string of the results, in order. If more than one string is given and not all strings have the same length, string-map terminates when the shortest string runs out. The dynamic order in which proc is applied to the elements of the strings is unspecified. If multiple returns occur from string-map, the values returned by earlier returns are not mutated.

(scheme base) procedure (string-ref (string string?) (k integer?) ) ⟹ char?

It is an error if k is not a valid index of string. The string-ref procedure returns character k of string using zero-origin indexing. There is no requirement for this procedure to execute in constant time.

(scheme base) procedure (string-set! (string string?) (k integer?) (char char?) ) ⟹ undefined

It is an error if k is not a valid index of string. The string-set! procedure stores char in element k of string. There is no requirement for this procedure to execute in constant time.

(scheme base) procedure (string<=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically non-decreasing. This predicate is required to be transitive. The procedure compares strings in an implementation defined way. One approach is to make them the lexicographic extensions to strings of the corresponding orderings on characters. In that case, string<? would be the lexicographic ordering on strings induced by the ordering char<? on characters, and if the two strings differ in length but are the same up to the length of the shorter string, the shorter string would be considered to be lexicographically less than the longer string. However, it is also permitted to use the natural ordering imposed by the implementation’s internal representation of strings, or a more complex locale-specific ordering. In all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, and must satisfy string<=? if and only if they do not satisfy string>? and string>=? if and only if they do not satisfy string<?.

(scheme base) procedure (string<? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically increasing. This predicate is required to be transitive. The procedure compares strings in an implementation defined way. One approach is to make them the lexicographic extensions to strings of the corresponding orderings on characters. In that case, string<? would be the lexicographic ordering on strings induced by the ordering char<? on characters, and if the two strings differ in length but are the same up to the length of the shorter string, the shorter string would be considered to be lexicographically less than the longer string. However, it is also permitted to use the natural ordering imposed by the implementation’s internal representation of strings, or a more complex locale-specific ordering. In all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, and must satisfy string<=? if and only if they do not satisfy string>? and string>=? if and only if they do not satisfy string<?.

(scheme base) procedure (string=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

Returns #t if all the strings are the same length and contain exactly the same characters in the same positions, otherwise returns #f.

(scheme base) procedure (string>=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically non-increasing. This predicate is required to be transitive. The procedure compares strings in an implementation defined way. One approach is to make them the lexicographic extensions to strings of the corresponding orderings on characters. In that case, string<? would be the lexicographic ordering on strings induced by the ordering char<? on characters, and if the two strings differ in length but are the same up to the length of the shorter string, the shorter string would be considered to be lexicographically less than the longer string. However, it is also permitted to use the natural ordering imposed by the implementation’s internal representation of strings, or a more complex locale-specific ordering. In all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, and must satisfy string<=? if and only if they do not satisfy string>? and string>=? if and only if they do not satisfy string<?.

(scheme base) procedure (string>? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically decreasing. This predicate is required to be transitive. The procedure compares strings in an implementation defined way. One approach is to make them the lexicographic extensions to strings of the corresponding orderings on characters. In that case, string<? would be the lexicographic ordering on strings induced by the ordering char<? on characters, and if the two strings differ in length but are the same up to the length of the shorter string, the shorter string would be considered to be lexicographically less than the longer string. However, it is also permitted to use the natural ordering imposed by the implementation’s internal representation of strings, or a more complex locale-specific ordering. In all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, and must satisfy string<=? if and only if they do not satisfy string>? and string>=? if and only if they do not satisfy string<?.

(scheme base) procedure (string? obj ) ⟹ boolean?

Returns #t if obj is a string, otherwise returns #f.

(scheme base) procedure (substring (string string?) (start integer?) (end integer?) ) ⟹ string?

The substring procedure returns a newly allocated string formed from the characters of string beginning with index start and ending with index end. This is equivalent to calling string-copy with the same arguments, but is provided for backward compatibility and stylistic flexibility.

(scheme base) procedure (symbol->string (symbol symbol?) ) ⟹ string?

Returns the name of symbol as a string, but without adding escapes. It is an error to apply mutation procedures like string-set! to strings returned by this procedure.

(scheme base) procedure (symbol=? (symbol1 symbol?) (symbol2 symbol?) (symbol3 symbol?) ... ) ⟹ boolean?

Returns #t if all the arguments are symbols and all have the same names in the sense of string=?. Note: The definition above assumes that none of the arguments are uninterned symbols.

(scheme base) procedure (symbol? obj ) ⟹ boolean?

Returns #t if obj is a symbol, otherwise returns #f.

(scheme base) syntax (syntax-error () ((_ message args ...)) )

syntax-error behaves similarly to error (6.11) except that implementations with an expansion pass separate from evaluation should signal an error as soon as syntax-error is expanded. This can be used as a syntax-rules template for a pattern that is an invalid use of the macro, which can provide more descriptive error messages. message is a string literal, and args arbitrary expressions providing additional information. Applications cannot count on being able to catch syntax errors with exception handlers or guards.

(scheme base) syntax (syntax-rules (_ ) ((_ (literal ...) syntax-rule ...) transformer-spec) ((_ ellipsis (literal ...) syntax-rule ...) transformer-spec) )

(pattern template)

_ identifier constant (pattern ...) (pattern pattern ... . pattern) (pattern ... pattern ellipsis pattern ...) (pattern ... pattern ellipsis pattern ... . pattern) #(pattern ...) #(pattern ... pattern ellipsis pattern ...)

identifier constant (element ...) (element element ... . template) (ellipsis template) #(element ...)

template template ellipsis

An instance of syntax-rules produces a new macro transformer by specifying a sequence of hygienic rewrite rules. A use of a macro whose keyword is associated with a transformer specified by syntax-rules is matched against the patterns contained in the syntax rulei, beginning with the leftmost syntax rule. When a match is found, the macro use is transcribed hygienically according to the template. An identifier appearing within a pattern can be an underscore (_), a literal identifier listed in the list of literali, or the ellipsis. All other identifiers appearing within a pattern are pattern variables. The keyword at the beginning of the pattern in a syntax rule is not involved in the matching and is considered neither a pattern variable nor a literal identifier. Pattern variables match arbitrary input elements and are used to refer to elements of the input in the template. It is an error for the same pattern variable to appear more than once in a pattern. Underscores also match arbitrary input elements but are not pattern variables and so cannot be used to refer to those elements. If an underscore appears in the literal list, then that takes precedence and underscores in the pattern match as literals. Multiple underscores can appear in a pattern. Identifiers that appear in (literal ...) are interpreted as literal identifiers to be matched against corresponding elements of the input. An element in the input matches a literal identifier if and only if it is an identifier and either both its occurrence in the macro expression and its occurrence in the macro definition have the same lexical binding, or the two identifiers are the same and both have no lexical binding. A subpattern followed by ellipsis can match zero or more elements of the input, unless ellipsis appears in the literals, in which case it is matched as a literal. It is an error to use a macro keyword, within the scope of its binding, in an expression that does not match any of the patterns. When a macro use is transcribed according to the template of the matching hsyntax rulei, pattern variables that occur in the template are replaced by the elements they match in the input. Pattern variables that occur in subpatterns followed by one or more instances of the identifier ellipsis are allowed only in subtemplates that are followed by as many instances of ellipsis. They are replaced in the output by all of the elements they match in the input, distributed as indicated. It is an error if the output cannot be built up as specified. Identifiers that appear in the template but are not pattern variables or the identifier ellipsis are inserted into the output as literal identifiers. If a literal identifier is inserted as a free identifier then it refers to the binding of that identifier within whose scope the instance of syntax-rules appears. If a literal identifier is inserted as a bound identifier then it is in effect renamed to prevent inadvertent captures of free identifiers. A template of the form (ellipsis template) is identical to template, except that ellipses within the template have no special meaning. That is, any ellipses contained within template are treated as ordinary identifiers. In particular, the template (ellipsis ellipsis) produces a single ellipsis. This allows syntactic abstractions to expand into code containing ellipses.

(scheme base) procedure (truncate (x real?) ) ⟹ integer?

The truncate procedure returns the integer closest to x whose absolute value is not larger than the absolute value of x. Note: If the argument to this procedure is inexact, then the result will also be inexact. If an exact value is needed, the result can be passed to the exact procedure. If the argument is infinite or a NaN, then it is returned.

(scheme base) procedure (truncate-quotient (n1 integer?) (n2 integer?) ) ⟹ integer?

This procedure implements number-theoretic (integer) division. It is an error if n2 is zero. The procedure computes a quotient nq and remainder nr such that n1 = n2 * nq + nr.

(scheme base) procedure (truncate-remainder (n1 integer?) (n2 integer?) ) ⟹ integer?

This procedure implements number-theoretic (integer) division. It is an error if n2 is zero. The procedure computes a quotient nq and remainder nr such that n1 = n2 * nq + nr.

(scheme base) procedure (truncate/ (n1 integer?) (n2 integer?) ) ⟹ (values integer?integer?)

This procedure implements number-theoretic (integer) division. It is an error if n2 is zero. The procedure computes a quotient nq and remainder nr such that n1 = n2 * nq + nr.

(scheme base) procedure (u8-ready? ) ⟹ boolean?

(scheme base) procedure (u8-ready? (port input-port?) ) ⟹ boolean?

Returns #t if a byte is ready on the binary input port and returns #f otherwise. If u8-ready? returns #t then the next read-u8 operation on the given port is guaranteed not to hang. If the port is at end of file then u8-ready? returns #t.

(scheme base) syntax (unless () ((_ test expression1 expression2 ...)) )

The test is evaluated, and if it evaluates to #f, the expressions are evaluated in order. The result of the unless expression is unspecified.

(scheme base) syntax (unquote () ((_ expression)) )

"Quasiquote" expressions are useful for constructing a list or vector structure when some but not all of the desired structure is known in advance. If no commas appear within the qq template, the result of evaluating qq template is equivalent to the result of evaluating 'qq template. If a comma appears within the qq template, however, the expression following the comma is evaluated ("unquoted") and its result is inserted into the structure instead of the comma and the expression. If a comma appears followed without intervening whitespace by a commercial at-sign (@), then it is an error if the following expression does not evaluate to a list; the opening and closing parentheses of the list are then "stripped away" and the elements of the list are inserted in place of the comma at-sign expression sequence. A comma at-sign normally appears only within a list or vector qq template. Note: In order to unquote an identifier beginning with @, it is necessary to use either an explicit unquote or to put whitespace after the comma, to avoid colliding with the comma at-sign sequence. Quasiquote expressions can be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost quasiquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation. A quasiquote expression may return either newly allocated, mutable objects or literal structure for any structure that is constructed at run time during the evaluation of the expression. Portions that do not need to be rebuilt are always literal.

(scheme base) syntax (unquote-splicing () ((_ expression)) )

"Quasiquote" expressions are useful for constructing a list or vector structure when some but not all of the desired structure is known in advance. If no commas appear within the qq template, the result of evaluating qq template is equivalent to the result of evaluating 'qq template. If a comma appears within the qq template, however, the expression following the comma is evaluated ("unquoted") and its result is inserted into the structure instead of the comma and the expression. If a comma appears followed without intervening whitespace by a commercial at-sign (@), then it is an error if the following expression does not evaluate to a list; the opening and closing parentheses of the list are then "stripped away" and the elements of the list are inserted in place of the comma at-sign expression sequence. A comma at-sign normally appears only within a list or vector qq template. Note: In order to unquote an identifier beginning with @, it is necessary to use either an explicit unquote or to put whitespace after the comma, to avoid colliding with the comma at-sign sequence. Quasiquote expressions can be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost quasiquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation. A quasiquote expression may return either newly allocated, mutable objects or literal structure for any structure that is constructed at run time during the evaluation of the expression. Portions that do not need to be rebuilt are always literal.

(scheme base) procedure (utf8->string (bytevector bytevector?) ) ⟹ string?

(scheme base) procedure (utf8->string (bytevector bytevector?) (start integer?) ) ⟹ string?

(scheme base) procedure (utf8->string (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ string?

It is an error for bytevector to contain invalid UTF-8 byte sequences. This procedure translates between strings and bytevectors that encode those strings using the UTF-8 encoding. The utf8->string procedure decodes the bytes of a bytevector between start and end and returns the corresponding string.

(scheme base) procedure (values obj ... ) ⟹ (values *...)

Delivers all of its arguments to its continuation.

(scheme base) procedure (vector obj ... ) ⟹ vector?

Returns a newly allocated vector whose elements contain the given arguments. It is analogous to list.

(scheme base) procedure (vector->list (vector vector?) ) ⟹ list?

(scheme base) procedure (vector->list (vector vector?) (start integer?) ) ⟹ list?

(scheme base) procedure (vector->list (vector vector?) (start integer?) (end integer?) ) ⟹ list?

The vector->list procedure returns a newly allocated list of the objects contained in the elements of vector between start and end. The order is preserved.

(scheme base) procedure (vector->string (vector vector?) ) ⟹ string?

(scheme base) procedure (vector->string (vector vector?) (start integer?) ) ⟹ string?

(scheme base) procedure (vector->string (vector vector?) (start integer?) (end integer?) ) ⟹ string?

vector ⟹ (vector (char char?))

It is an error if any element of vector between start and end is not a character. The vector->string procedure returns a newly allocated string of the objects contained in the elements of vector between start and end. The order is preserved.

(scheme base) procedure (vector-append (vector vector?) ... ) ⟹ vector?

Returns a newly allocated vector whose elements are the concatenation of the elements of the given vectors.

(scheme base) procedure (vector-copy (vector vector?) ) ⟹ vector?

(scheme base) procedure (vector-copy (vector vector?) (start integer?) ) ⟹ vector?

(scheme base) procedure (vector-copy (vector vector?) (start integer?) (end integer?) ) ⟹ vector?

Returns a newly allocated copy of the elements of the given vector between start and end. The elements of the new vector are the same (in the sense of eqv?) as the elements of the old.

(scheme base) procedure (vector-copy! (to vector?) (at integer?) (from vector?) ) ⟹ undefined

(scheme base) procedure (vector-copy! (to vector?) (at integer?) (from vector?) (start integer?) ) ⟹ undefined

(scheme base) procedure (vector-copy! (to vector?) (at integer?) (from vector?) (start integer?) (end integer?) ) ⟹ undefined

It is an error if at is less than zero or greater than the length of to. It is also an error if (- (vector-length to) at) is less than (- end start). Copies the elements of vector from between start and end to vector to, starting at at. The order in which elements are copied is unspecified, except that if the source and destination overlap, copying takes place as if the source is first copied into a temporary vector and then into the destination. This can be achieved without allocating storage by making sure to copy in the correct direction in such circumstances

(scheme base) procedure (vector-fill! (vector vector?) fill ) ⟹ undefined

(scheme base) procedure (vector-fill! (vector vector?) fill (start integer?) ) ⟹ undefined

(scheme base) procedure (vector-fill! (vector vector?) fill (start integer?) (end integer?) ) ⟹ undefined

The vector-fill! procedure stores fill in the elements of vector between start and end.

(scheme base) procedure (vector-for-each (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ undefined

(proc obj ... ) ⟹ undefined

It is an error if proc does not accept as many arguments as there are vectors. The arguments to vector-for-each are like the arguments to vector-map, but vector-for-each calls proc for its side effects rather than for its values. Unlike vector-map, vector-for-each is guaranteed to call proc on the elements of the vector s in order from the first element(s) to the last, and the value returned by vector-for-each is unspecified. If more than one vector is given and not all vectors have the same length, vector-for-each terminates when the shortest vector runs out. It is an error for proc to mutate any of the vectors.

(scheme base) procedure (vector-length (vector vector?) ) ⟹ integer?

Returns the number of elements in vector as an exact integer.

(scheme base) procedure (vector-map (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ vector?

(proc obj ... ) ⟹ *

It is an error if proc does not accept as many arguments as there are vectors and return a single value. The vector-map procedure applies proc element-wise to the elements of the vector s and returns a vector of the results, in order. If more than one vector is given and not all vectors have the same length, vector-map terminates when the shortest vector runs out. The dynamic order in which proc is applied to the elements of the vector s is unspecified. If multiple returns occur from vector-map, the values returned by earlier returns are not mutated.

(scheme base) procedure (vector-ref (vector vector?) (k integer?) ) ⟹ *

It is an error if k is not a valid index of vector. The vector-ref procedure returns the contents of element k of vector.

(scheme base) procedure (vector-set! (vector vector?) (k integer?) obj ) ⟹ undefined

It is an error if k is not a valid index of vector. The vector-set! procedure stores obj in element k of vector.

(scheme base) procedure (vector? obj ) ⟹ boolean?

Returns #t if obj is a vector; otherwise returns #f.

(scheme base) syntax (when () ((_ test expression1 expression2 ...)) )

The test is evaluated, and if it evaluates to a true value, the expressions are evaluated in order. The result of the when expression is unspecified.

(scheme base) procedure (write-bytevector (bytevector bytevector?) ) ⟹ undefined

(scheme base) procedure (write-bytevector (bytevector bytevector?) (port output-port?) ) ⟹ undefined

(scheme base) procedure (write-bytevector (bytevector bytevector?) (port output-port?) (start integer?) ) ⟹ undefined

(scheme base) procedure (write-bytevector (bytevector bytevector?) (port output-port?) (start integer?) (end integer?) ) ⟹ undefined

Writes the bytes of bytevector from start to end in left-toright order to the binary output port.

(scheme base) procedure (write-char (char char?) ) ⟹ undefined

(scheme base) procedure (write-char (char char?) (port output-port?) ) ⟹ undefined

Writes the character char (not an external representation of the character) to the given textual output port and returns an unspecified value.

(scheme base) procedure (write-string (string string?) ) ⟹ undefined

(scheme base) procedure (write-string (string string?) (port output-port?) ) ⟹ undefined

(scheme base) procedure (write-string (string string?) (port output-port?) (start integer?) ) ⟹ undefined

(scheme base) procedure (write-string (string string?) (port output-port?) (start integer?) (end integer?) ) ⟹ undefined

Writes the characters of string from start to end in left-toright order to the textual output port.

(scheme base) procedure (write-u8 (byte integer?) ) ⟹ undefined

(scheme base) procedure (write-u8 (byte integer?) (port output-port?) ) ⟹ undefined

Writes the byte to the given binary output port and returns an unspecified value.

(scheme base) procedure (current-error-port ) ⟹ output-port?

(scheme base) procedure (current-input-port ) ⟹ input-port?

(scheme base) procedure (current-output-port ) ⟹ output-port?

Returns the current default input port, output port, or error port (an output port), respectively. These procedures are parameter objects, which can be overridden with parameterize (see section 4.2.6). The initial bindings for these are implementation-defined textual ports.

(scheme base) procedure (number? obj ) ⟹ boolean?

(scheme base) procedure (complex? obj ) ⟹ boolean?

(scheme base) procedure (real? obj ) ⟹ boolean?

(scheme base) procedure (rational? obj ) ⟹ boolean?

(scheme base) procedure (integer? obj ) ⟹ boolean?

These numerical type predicates can be applied to any kind of argument, including non-numbers. They return #t if the object is of the named type, and otherwise they return #f. In general, if a type predicate is true of a number then all higher type predicates are also true of that number. Consequently, if a type predicate is false of a number, then all lower type predicates are also false of that number. If z is a complex number, then (real? z) is true if and only if (zero? (imag-part z)) is true. If x is an inexact real number, then (integer? x) is true if and only if (= x (round x)). The numbers +inf.0, -inf.0, and +nan.0 are real but not rational.

(scheme base) procedure (zero? (z number?) ) ⟹ boolean?

(scheme base) procedure (positive? (x real?) ) ⟹ boolean?

(scheme base) procedure (negative? (x real?) ) ⟹ boolean?

(scheme base) procedure (odd? (n integer?) ) ⟹ boolean?

(scheme base) procedure (even? (n integer?) ) ⟹ boolean?

These numerical predicates test a number for a particular property, returning #t or #f.

(scheme base) procedure (input-port? obj ) ⟹ boolean?

(scheme base) procedure (output-port? obj ) ⟹ boolean?

(scheme base) procedure (textual-port? obj ) ⟹ boolean?

(scheme base) procedure (binary-port? obj ) ⟹ boolean?

(scheme base) procedure (port? obj ) ⟹ boolean?

These procedures return #t if obj is an input port, output port, textual port, binary port, or any kind of port, respectively. Otherwise they return #f.

library (scheme base)

(scheme base) syntax (cond-expand (library and or not else ) ((_ ce-clause1 ce-clause2 ...)) )

(feature-requirement expression ...) (else expression)

feature-identifier (library library-name) (and feature-requirement ...) (or feature-requirement ...) (not feature-requirement)

The cond-expand form tests for the existence of features at macro-expansion time. It either expands into the body of one of its clauses or signals an error during syntactic processing. cond-expand expands into the body of the first clause whose feature requirement is currently satisfied (the else clause, if present, is selected if none of the previous clauses is selected). A feature requirement has an obvious interpretation as a logical formula, where the <feature identifier> variables have meaning TRUE if the feature corresponding to the feature identifier, as specified in the SRFI registry, is in effect at the location of the cond-expand form, and FALSE otherwise. A feature requirement is satisfied if its formula is true under this interpretation.

library (scheme base)

(scheme base) procedure (open-input-string (string string?) ) ⟹ input-port?

Takes a string and returns a textual input port that delivers characters from the string. If the string is modified, the effect is unspecified.

(scheme base) procedure (open-output-string ) ⟹ output-port?

Returns a textual output port that will accumulate characters for retrieval by get-output-string.

(scheme base) procedure (get-output-string (port output-port?) ) ⟹ string?

It is an error if port was not created with open-output-string. Returns a string consisting of the characters that have been output to the port so far in the order they were output. If the result string is modified, the effect is unspecified.

library (scheme base)

(scheme base) syntax (define-record-type () ((_ name constructor pred field ...)) )

(constructor-name field-name ...)

(field-name accessor-name) (field-name accessor-name modifier-name)

It is an error for the same identifier to occur more than once as a field name. It is also an error for the same identifier to occur more than once as an accessor or mutator name. The define-record-type construct is generative: each use creates a new record type that is distinct from all existing types, including Scheme’s predefined types and other record types — even record types of the same name or structure. An instance of define-record-type is equivalent to the following definitions. <name> is bound to a representation of the record type itself. This may be a run-time object or a purely syntactic representation. The representation is not utilized in this report, but it serves as a means to identify the record type for use by further language extensions. <constructor name> is bound to a procedure that takes as many arguments as there are <field name>s in the (<constructor name> ...) subexpression and returns a new record of type <name>. Fields whose names are listed with <constructor name> have the corresponding argument as their initial value. The initial values of all other fields are unspecified. It is an error for a field name to appear in <constructor> but not as a <field name>. <pred> is bound to a predicate that returns #t when given a value returned by the procedure bound to <constructor name> and #f for everything else. Each <accessor name> is bound to a procedure that takes a record of type <name> and returns the current value of the corresponding field. It is an error to pass an accessor a value which is not a record of the appropriate type. Each <modifier name> is bound to a procedure that takes a record of type <name> and a value which becomes the new value of the corresponding field; an unspecified value is returned. It is an error to pass a modifier a first argument which is not a record of the appropriate type.

library (scheme base)

(scheme base) syntax (let*-values () ((_ mv-binding-spec body)) )

((formals1 init1) ...)

(variable1 ...) variable (variable1 ... variable_n . variable_n+1)

The let*-values construct is similar to let-values, but the <init>s are evaluated and bindings created sequentially from left to right, with the region of the bindings of each <formals> including the <init>s to its right as well as <body>. Thus the second <init> is evaluated in an environment in which the first set of bindings is visible and initialized, and so on.

(scheme base) syntax (let-values () ((_ mv-binding-spec body)) )

((formals1 init1) ...)

(variable1 ...) variable (variable1 ... variable_n . variable_n+1)

The <init>s are evaluated in the current environment (in some unspecified order) as if by invoking call-with-values, and the variables occurring in the <formals> are bound to fresh locations holding the values returned by the <init>s, where the <formals> are matched to the return values in the same way that the <formals> in a lambda expression are matched to the arguments in a procedure call. Then, the <body> is evaluated in the extended environment, and the values of the last expression of <body> are returned. Each binding of a <variable> has <body> as its region. It is an error if the <formals> do not match the number of values returned by the corresponding <init>.

library (scheme base)

(scheme base) procedure (error (message string?) obj ... ) ⟹ undefined

Message should be a string. Raises an exception as if by calling raise on a newly allocated implementation-defined object which encapsulates the information provided by message, as well as any objs, known as the irritants. The procedure error-object? must return #t on such objects.

library (scheme base)

(scheme base) procedure (raise obj ) ⟹ undefined

Raises an exception by invoking the current exception handler on obj. The handler is called with the same dynamic environment as that of the call to raise, except that the current exception handler is the one that was in place when the handler being called was installed. If the handler returns, a secondary exception is raised in the same dynamic environment as the handler. The relationship between obj and the object raised by the secondary exception is unspecified.

(scheme base) syntax (guard (=> else ) ((_ (variable cond-clause1 cond-clause2 ...) body)) )

(test expression1 ...) (test => expression) (else expression1 expression2 ...)

The <body> is evaluated with an exception handler that binds the raised object (see raise in section 6.11) to <variable> and, within the scope of that binding, evaluates the clauses as if they were the clauses of a cond expression. That implicit cond expression is evaluated with the continuation and dynamic environment of the guard expression. If every <cond clause>’s <test> evaluates to #f and there is no else clause, then raise-continuable is invoked on the raised object within the dynamic environment of the original call to raise or raise-continuable, except that the current exception handler is that of the guard expression. See section 6.11 for a more complete discussion of exceptions.

(scheme base) procedure (with-exception-handler (handler procedure?) (thunk procedure?) ) ⟹ *

(handler obj ) ⟹ *

(thunk ) ⟹ *

It is an error if handler does not accept one argument. It is also an error if thunk does not accept zero arguments. The with-exception-handler procedure returns the results of invoking thunk. Handler is installed as the current exception handler in the dynamic environment used for the invocation of thunk.

library (scheme base)

(scheme base) procedure (make-parameter obj ) ⟹ procedure?

(scheme base) procedure (make-parameter obj (converter procedure?) ) ⟹ procedure?

(converter obj ) ⟹ *

Returns a newly allocated parameter object, which is a procedure that accepts zero arguments and returns the value associated with the parameter object. Initially, this value is the value of (converter init), or of init if the conversion procedure converter is not specified. The associated value can be temporarily changed using parameterize, which is described below. The effect of passing arguments to a parameter object is implementation-dependent.

(scheme base) syntax (parameterize () ((_ ((param1 value1) ...) body)) )

A parameterize expression is used to change the values returned by specified parameter objects during the evaluation of the body. The <param> and <value> expressions are evaluated in an unspecified order. The <body> is evaluated in a dynamic environment in which calls to the parameters return the results of passing the corresponding values to the conversion procedure specified when the parameters were created. Then the previous values of the parameters are restored without passing them to the conversion procedure. The results of the last expression in the <body> are returned as the results of the entire parameterize expression. Note: If the conversion procedure is not idempotent, the results of (parameterize ((x (x))) ...), which appears to bind the parameter x to its current value, might not be what the user expects. If an implementation supports multiple threads of execution, then parameterize must not change the associated values of any parameters in any thread other than the current thread and threads created inside <body>. Parameter objects can be used to specify configurable settings for a computation without the need to pass the value to every procedure in the call chain explicitly.

library (scheme case-lambda)

(scheme case-lambda) syntax (case-lambda () ((_ clause ...) procedure?) )

(formals body)

(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>.

library (scheme complex)

(scheme complex) procedure (angle (z complex?) ) ⟹ real?

(scheme complex) procedure (imag-part (z complex?) ) ⟹ real?

(scheme complex) procedure (magnitude (z complex?) ) ⟹ real?

(scheme complex) procedure (make-polar (x3 real?) (x4 real?) ) ⟹ complex?

(scheme complex) procedure (make-rectangular (x1 real?) (x2 real?) ) ⟹ complex?

(scheme complex) procedure (real-part (z complex?) ) ⟹ real?

Let x1, x2, x3, and x4 be real numbers and z be a complex number such that

z = x1 + x2i = x3 * e^(i*x4)

Then all of

(make-rectangular x1 x2) => z

(make-polar x3 x4) => z

(real-part z) => x1

(imag-part z) => x2

(magnitude z) => |x3|

(angle z) =⇒ x_angle

are true, where -pi <= x_angle <= pi with x_angle = x4 + 2*pi*n for some integer n.

The make-polar procedure may return an inexact complex number even if its arguments are exact. The real-part and imag-part procedures may return exact real numbers when applied to an inexact complex number if the corresponding argument passed to make-rectangular was exact.

library (scheme char)

(scheme char) procedure (char-alphabetic? (char char?) ) ⟹ boolean?

char-alpabetic?, char-numeric?, char-whitespace? char-upper-case?, char-lower-case? These procedures return #t if their arguments are alphabetic, numeric, whitespace, upper case, or lower case characters, respectively, otherwise they return #f. Specifically, they must return #t when applied to characters with the Unicode properties Alphabetic, Numeric Digit, White Space, Uppercase, and Lowercase respectively, and #f when applied to any other Unicode characters. Note that many Unicode characters are alphabetic but neither upper nor lower case.

(scheme char) procedure (char-ci<=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

char-ci=?, char-ci<?, char-ci>?, char-ci<=?, char-ci>=? These procedures are similar to char=? et cetera, but they treat upper case and lower case letters as the same. For example, (char-ci=? #\A #\a) returns #t. Specifically, these procedures behave as if char-foldcase were applied to their arguments before they were compared.

(scheme char) procedure (char-ci<? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

char-ci=?, char-ci<?, char-ci>?, char-ci<=?, char-ci>=? These procedures are similar to char=? et cetera, but they treat upper case and lower case letters as the same. For example, (char-ci=? #\A #\a) returns #t. Specifically, these procedures behave as if char-foldcase were applied to their arguments before they were compared.

(scheme char) procedure (char-ci=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

char-ci=?, char-ci<?, char-ci>?, char-ci<=?, char-ci>=? These procedures are similar to char=? et cetera, but they treat upper case and lower case letters as the same. For example, (char-ci=? #\A #\a) returns #t. Specifically, these procedures behave as if char-foldcase were applied to their arguments before they were compared.

(scheme char) procedure (char-ci>=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

char-ci=?, char-ci<?, char-ci>?, char-ci<=?, char-ci>=? These procedures are similar to char=? et cetera, but they treat upper case and lower case letters as the same. For example, (char-ci=? #\A #\a) returns #t. Specifically, these procedures behave as if char-foldcase were applied to their arguments before they were compared.

(scheme char) procedure (char-ci>? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

char-ci=?, char-ci<?, char-ci>?, char-ci<=?, char-ci>=? These procedures are similar to char=? et cetera, but they treat upper case and lower case letters as the same. For example, (char-ci=? #\A #\a) returns #t. Specifically, these procedures behave as if char-foldcase were applied to their arguments before they were compared.

(scheme char) procedure (char-downcase (char char?) ) ⟹ char?

The char-downcase procedure, given an argument that is the uppercase part of a Unicode casing pair, returns the lowercase member of the pair, provided that both characters are supported by the Scheme implementation. Note that language-sensitive casing pairs are not used. If the argument is not the uppercase member of such a pair, it is returned.

(scheme char) procedure (char-foldcase (char char?) ) ⟹ char?

The char-foldcase procedure applies the Unicode simple case-folding algorithm to its argument and returns the result. Note that language-sensitive folding is not used. If the argument is an uppercase letter, the result will be either a lowercase letter or the same as the argument if the lowercase letter does not exist or is not supported by the implementation. See UAX #29 [11] (part of the Unicode Standard) for details.

(scheme char) procedure (char-lower-case? (char char?) ) ⟹ boolean?

char-alpabetic?, char-numeric?, char-whitespace? char-upper-case?, char-lower-case? These procedures return #t if their arguments are alphabetic, numeric, whitespace, upper case, or lower case characters, respectively, otherwise they return #f. Specifically, they must return #t when applied to characters with the Unicode properties Alphabetic, Numeric Digit, White Space, Uppercase, and Lowercase respectively, and #f when applied to any other Unicode characters. Note that many Unicode characters are alphabetic but neither upper nor lower case.

(scheme char) procedure (char-numeric? (char char?) ) ⟹ boolean?

char-alpabetic?, char-numeric?, char-whitespace? char-upper-case?, char-lower-case? These procedures return #t if their arguments are alphabetic, numeric, whitespace, upper case, or lower case characters, respectively, otherwise they return #f. Specifically, they must return #t when applied to characters with the Unicode properties Alphabetic, Numeric Digit, White Space, Uppercase, and Lowercase respectively, and #f when applied to any other Unicode characters. Note that many Unicode characters are alphabetic but neither upper nor lower case.

(scheme char) procedure (char-upcase (char char?) ) ⟹ char?

The char-upcase procedure, given an argument that is the lowercase part of a Unicode casing pair, returns the uppercase member of the pair, provided that both characters are supported by the Scheme implementation. Note that language-sensitive casing pairs are not used. If the argument is not the lowercase member of such a pair, it is returned.

(scheme char) procedure (char-upper-case? (char char?) ) ⟹ boolean?

char-alpabetic?, char-numeric?, char-whitespace? char-upper-case?, char-lower-case? These procedures return #t if their arguments are alphabetic, numeric, whitespace, upper case, or lower case characters, respectively, otherwise they return #f. Specifically, they must return #t when applied to characters with the Unicode properties Alphabetic, Numeric Digit, White Space, Uppercase, and Lowercase respectively, and #f when applied to any other Unicode characters. Note that many Unicode characters are alphabetic but neither upper nor lower case.

(scheme char) procedure (char-whitespace? (char char?) ) ⟹ boolean?

char-alpabetic?, char-numeric?, char-whitespace? char-upper-case?, char-lower-case? These procedures return #t if their arguments are alphabetic, numeric, whitespace, upper case, or lower case characters, respectively, otherwise they return #f. Specifically, they must return #t when applied to characters with the Unicode properties Alphabetic, Numeric Digit, White Space, Uppercase, and Lowercase respectively, and #f when applied to any other Unicode characters. Note that many Unicode characters are alphabetic but neither upper nor lower case.

(scheme char) procedure (digit-value (char char?) ) ⟹ #f / integer? /

This procedure returns the numeric value (0 to 9) of its argument if it is a numeric digit (that is, if char-numeric? returns #t), or #f on any other character.

(scheme char) procedure (string-ci<=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

string<?, string-ci<?, string>?, string-ci>?, string<=?, string-ci<=?, string=>?, string-ci=>? These procedures return #t if their arguments are (respectively): monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically nonincreasing. These predicates are required to be transitive. These procedures compare strings in an implementationdefined way. One approach is to make them the lexicographic extensions to strings of the corresponding orderings on characters. In that case, string<? would be the lexicographic ordering on strings induced by the ordering char<? on characters, and if the two strings differ in length but are the same up to the length of the shorter string, the shorter string would be considered to be lexicographically less than the longer string. However, it is also permitted to use the natural ordering imposed by the implementation’s internal representation of strings, or a more complex locale-specific ordering. In all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, and must satisfy string<=? if and only if they do not satisfy string>? and string>=? if and only if they do not satisfy string<?. The "-ci" procedures behave as if they applied string-foldcase to their arguments before invoking the corresponding procedures without "-ci".

(scheme char) procedure (string-ci<? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

string<?, string-ci<?, string>?, string-ci>?, string<=?, string-ci<=?, string=>?, string-ci=>? These procedures return #t if their arguments are (respectively): monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically nonincreasing. These predicates are required to be transitive. These procedures compare strings in an implementationdefined way. One approach is to make them the lexicographic extensions to strings of the corresponding orderings on characters. In that case, string<? would be the lexicographic ordering on strings induced by the ordering char<? on characters, and if the two strings differ in length but are the same up to the length of the shorter string, the shorter string would be considered to be lexicographically less than the longer string. However, it is also permitted to use the natural ordering imposed by the implementation’s internal representation of strings, or a more complex locale-specific ordering. In all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, and must satisfy string<=? if and only if they do not satisfy string>? and string>=? if and only if they do not satisfy string<?. The "-ci" procedures behave as if they applied string-foldcase to their arguments before invoking the corresponding procedures without "-ci".

(scheme char) procedure (string-ci=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

Returns #t if, after case-folding, all the strings are the same length and contain the same characters in the same positions, otherwise returns #f. Specifically, these procedures behave as if string-foldcase were applied to their arguments before comparing them.

(scheme char) procedure (string-ci>=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

string<?, string-ci<?, string>?, string-ci>?, string<=?, string-ci<=?, string=>?, string-ci=>? These procedures return #t if their arguments are (respectively): monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically nonincreasing. These predicates are required to be transitive. These procedures compare strings in an implementationdefined way. One approach is to make them the lexicographic extensions to strings of the corresponding orderings on characters. In that case, string<? would be the lexicographic ordering on strings induced by the ordering char<? on characters, and if the two strings differ in length but are the same up to the length of the shorter string, the shorter string would be considered to be lexicographically less than the longer string. However, it is also permitted to use the natural ordering imposed by the implementation’s internal representation of strings, or a more complex locale-specific ordering. In all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, and must satisfy string<=? if and only if they do not satisfy string>? and string>=? if and only if they do not satisfy string<?. The "-ci" procedures behave as if they applied string-foldcase to their arguments before invoking the corresponding procedures without "-ci".

(scheme char) procedure (string-ci>? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?

string<?, string-ci<?, string>?, string-ci>?, string<=?, string-ci<=?, string=>?, string-ci=>? These procedures return #t if their arguments are (respectively): monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically nonincreasing. These predicates are required to be transitive. These procedures compare strings in an implementationdefined way. One approach is to make them the lexicographic extensions to strings of the corresponding orderings on characters. In that case, string<? would be the lexicographic ordering on strings induced by the ordering char<? on characters, and if the two strings differ in length but are the same up to the length of the shorter string, the shorter string would be considered to be lexicographically less than the longer string. However, it is also permitted to use the natural ordering imposed by the implementation’s internal representation of strings, or a more complex locale-specific ordering. In all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, and must satisfy string<=? if and only if they do not satisfy string>? and string>=? if and only if they do not satisfy string<?. The "-ci" procedures behave as if they applied string-foldcase to their arguments before invoking the corresponding procedures without "-ci".

(scheme char) procedure (string-downcase (string string?) ) ⟹ string?

string-upcase, string-downcase, string-foldcase These procedures apply the Unicode full string uppercasing, lowercasing, and case-folding algorithms to their arguments and return the result. In certain cases, the result differs in length from the argument. If the result is equal to the argument in the sense of string=?, the argument may be returned. Note that language-sensitive mappings and foldings are not used. The Unicode Standard prescribes special treatment of the Greek letter Σ, whose normal lower-case form is σ but which becomes ς at the end of a word. See UAX #29 [11] (part of the Unicode Standard) for details. However, implementations of string-downcase are not required to provide this behavior, and may choose to change Σ to σ in all cases.

(scheme char) procedure (string-foldcase (string string?) ) ⟹ string?

string-upcase, string-downcase, string-foldcase These procedures apply the Unicode full string uppercasing, lowercasing, and case-folding algorithms to their arguments and return the result. In certain cases, the result differs in length from the argument. If the result is equal to the argument in the sense of string=?, the argument may be returned. Note that language-sensitive mappings and foldings are not used. The Unicode Standard prescribes special treatment of the Greek letter Σ, whose normal lower-case form is σ but which becomes ς at the end of a word. See UAX #29 [11] (part of the Unicode Standard) for details. However, implementations of string-downcase are not required to provide this behavior, and may choose to change Σ to σ in all cases.

(scheme char) procedure (string-upcase (string string?) ) ⟹ string?

string-upcase, string-downcase, string-foldcase These procedures apply the Unicode full string uppercasing, lowercasing, and case-folding algorithms to their arguments and return the result. In certain cases, the result differs in length from the argument. If the result is equal to the argument in the sense of string=?, the argument may be returned. Note that language-sensitive mappings and foldings are not used. The Unicode Standard prescribes special treatment of the Greek letter Σ, whose normal lower-case form is σ but which becomes ς at the end of a word. See UAX #29 [11] (part of the Unicode Standard) for details. However, implementations of string-downcase are not required to provide this behavior, and may choose to change Σ to σ in all cases.

library (scheme cxr)

(scheme cxr) procedure (caaaar (pair pair?) ) ⟹ *

Composition of car, car, car, car.

(scheme cxr) procedure (caaadr (pair pair?) ) ⟹ *

Composition of car, car, car, cdr.

(scheme cxr) procedure (caaar (pair pair?) ) ⟹ *

Composition of car, car, car.

(scheme cxr) procedure (caadar (pair pair?) ) ⟹ *

Composition of car, car, cdr, car.

(scheme cxr) procedure (caaddr (pair pair?) ) ⟹ *

Composition of car, car, cdr, cdr.

(scheme cxr) procedure (caadr (pair pair?) ) ⟹ *

Composition of car, car, cdr.

(scheme cxr) procedure (cadaar (pair pair?) ) ⟹ *

Composition of car, cdr, car, car.

(scheme cxr) procedure (cadadr (pair pair?) ) ⟹ *

Composition of car, cdr, car, cdr.

(scheme cxr) procedure (cadar (pair pair?) ) ⟹ *

Composition of car, cdr, car.

(scheme cxr) procedure (caddar (pair pair?) ) ⟹ *

Composition of car, cdr, cdr, car.

(scheme cxr) procedure (cadddr (pair pair?) ) ⟹ *

Composition of car, cdr, cdr, cdr.

(scheme cxr) procedure (caddr (pair pair?) ) ⟹ *

Composition of car, cdr, cdr.

(scheme cxr) procedure (cdaaar (pair pair?) ) ⟹ *

Composition of cdr, car, car, car.

(scheme cxr) procedure (cdaadr (pair pair?) ) ⟹ *

Composition of cdr, car, car, cdr.

(scheme cxr) procedure (cdaar (pair pair?) ) ⟹ *

Composition of cdr, car, car.

(scheme cxr) procedure (cdadar (pair pair?) ) ⟹ *

Composition of cdr, car, cdr, car.

(scheme cxr) procedure (cdaddr (pair pair?) ) ⟹ *

Composition of cdr, car, cdr, cdr.

(scheme cxr) procedure (cdadr (pair pair?) ) ⟹ *

Composition of cdr, car, cdr.

(scheme cxr) procedure (cddaar (pair pair?) ) ⟹ *

Composition of cdr, cdr, car, car.

(scheme cxr) procedure (cddadr (pair pair?) ) ⟹ *

Composition of cdr, cdr, car, cdr.

(scheme cxr) procedure (cddar (pair pair?) ) ⟹ *

Composition of cdr, cdr, car.

(scheme cxr) procedure (cdddar (pair pair?) ) ⟹ *

Composition of cdr, cdr, cdr, car.

(scheme cxr) procedure (cddddr (pair pair?) ) ⟹ *

Composition of cdr, cdr, cdr, cdr.

(scheme cxr) procedure (cdddr (pair pair?) ) ⟹ *

Composition of cdr, cdr, cdr.

library (scheme eval)

(scheme eval) procedure (environment (list1 list?) ... ) ⟹ environment

This procedure returns a specifier for the environment that results by starting with an empty environment and then importing each list, considered as an import set, into it. (See section 5.6 for a description of import sets.) The bindings of the environment represented by the specifier are immutable, as is the environment itself.

(scheme eval) procedure (eval expr-or-def (environment-specifier environment) ) ⟹ *

If expr-or-def is an expression, it is evaluated in the specified environment and its values are returned. If it is a definition, the specified identifier(s) are defined in the specified environment, provided the environment is not immutable. Implementations may extend eval to allow other objects.

library (scheme file)

(scheme file) procedure (call-with-input-file (string string?) (proc procedure?) ) ⟹ *

(proc (port input-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.

(scheme file) procedure (call-with-output-file (string string?) (proc procedure?) ) ⟹ *

(proc (port output-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.

(scheme file) procedure (delete-file (filename string?) ) ⟹ undefined

It is an error if filename is not a string. The delete-file procedure deletes the named file if it exists and can be deleted, and returns an unspecified value. If the file does not exist or cannot be deleted, an error that satisfies file-error? is signaled.

(scheme file) procedure (file-exists? (filename string?) ) ⟹ boolean?

The file-exists? procedure returns #t if the named file exists at the time the procedure is called, and #f otherwise.

(scheme file) procedure (open-binary-input-file (string string?) ) ⟹ input-port?

open-input-file, open-binary-input-file Takes a string for an existing file and returns a textual input port or binary input port that is capable of delivering data from the file. If the file does not exist or cannot be opened, an error that satisfies file-error? is signaled.

(scheme file) procedure (open-binary-output-file (string string?) ) ⟹ output-port?

open-output-file, open-binary-output-file Takes a string naming an output file to be created and returns a textual output port or binary output port that is capable of writing data to a new file by that name. If a file with the given name already exists, the effect is unspecified. If the file cannot be opened, an error that satisfies file-error? is signaled.

(scheme file) procedure (open-input-file (string string?) ) ⟹ input-port?

open-input-file, open-binary-input-file Takes a string for an existing file and returns a textual input port or binary input port that is capable of delivering data from the file. If the file does not exist or cannot be opened, an error that satisfies file-error? is signaled.

(scheme file) procedure (open-output-file (string string?) ) ⟹ output-port?

open-output-file, open-binary-output-file Takes a string naming an output file to be created and returns a textual output port or binary output port that is capable of writing data to a new file by that name. If a file with the given name already exists, the effect is unspecified. If the file cannot be opened, an error that satisfies file-error? is signaled.

(scheme file) procedure (with-input-from-file (string string?) (thunk procedure?) ) ⟹ *

(thunk ) ⟹ *

with-input-from-file, with-output-to-file The file is opened for input or output as if by open-input-file or open-output-file, and the new port is made to be the value returned by current-input-port or current-output-port (as used by (read), (write obj ), and so forth). The thunk is then called with no arguments. When the thunk returns, the port is closed and the previous default is restored. It is an error if thunk does not accept zero arguments. Both procedures return the values yielded by thunk . If an escape procedure is used to escape from the continuation of these procedures, they behave exactly as if the current input or output port had been bound dynamically with parameterize.

(scheme file) procedure (with-output-to-file (string string?) (thunk procedure?) ) ⟹ *

(thunk ) ⟹ *

with-input-from-file, with-output-to-file The file is opened for input or output as if by open-input-file or open-output-file, and the new port is made to be the value returned by current-input-port or current-output-port (as used by (read), (write obj ), and so forth). The thunk is then called with no arguments. When the thunk returns, the port is closed and the previous default is restored. It is an error if thunk does not accept zero arguments. Both procedures return the values yielded by thunk . If an escape procedure is used to escape from the continuation of these procedures, they behave exactly as if the current input or output port had been bound dynamically with parameterize.

library (scheme inexact)

(scheme inexact) procedure (acos (z number?) ) ⟹ number?

(scheme inexact) procedure (asin (z number?) ) ⟹ number?

(scheme inexact) procedure (atan (z number?) ) ⟹ number?

(scheme inexact) procedure (atan (y real?) (x real?) ) ⟹ number?

(scheme inexact) procedure (cos (z number?) ) ⟹ number?

(scheme inexact) procedure (exp (z number?) ) ⟹ number?

(scheme inexact) procedure (log (z number?) ) ⟹ number?

(scheme inexact) procedure (log (z1 number?) (z2 number?) ) ⟹ number?

(scheme inexact) procedure (sin (z number?) ) ⟹ number?

(scheme inexact) procedure (tan (z number?) ) ⟹ number?

These procedures compute the usual transcendental functions. The log procedure computes the natural logarithm of z (not the base ten logarithm) if a single argument is given, or the base-z2 logarithm of z1 if two arguments are given. The asin, acos, and atan procedures compute arcsine (sin−1), arc-cosine (cos−1), and arctangent (tan−1), respectively. The two-argument variant of atan computes (angle (make-rectangular x y)) (see below), even in implementations that don’t support complex numbers.

In general, the mathematical functions log, arcsine, arccosine, and arctangent are multiply defined. The value of log z is defined to be the one whose imaginary part lies in the range from −π (inclusive if -0.0 is distinguished, exclusive otherwise) to π (inclusive). The value of log 0 is mathematically undefined. With log defined this way, the values of sin−1 z, cos−1 z, and tan−1 z are according to the following formulæ:

sin^-1 z = -i log(iz + (1 - z^2)^0.5)

cos^-1 z = pi/2 - sin^-1 z

tan^-1 z = (log(1 + iz) - log(1 - iz)) / (2i)

(scheme inexact) procedure (sqrt (z number?) ) ⟹ number?

Returns the principal square root of z. The result will have either a positive real part, or a zero real part and a non-negative imaginary part.

(scheme inexact) procedure (finite? (z number?) ) ⟹ boolean?

The finite? procedure returns #t on all real numbers except +inf.0, -inf.0, and +nan.0, and on complex numbers if their real and imaginary parts are both finite. Otherwise it returns #f.

(scheme inexact) procedure (infinite? (z number?) ) ⟹ boolean?

The infinite? procedure returns #t on the real numbers +inf.0 and -inf.0, and on complex numbers if their real or imaginary parts or both are infinite. Otherwise it returns #f.

(scheme inexact) procedure (nan? (z number?) ) ⟹ boolean?

The nan? procedure returns #t on +nan.0, and on complex numbers if their real or imaginary parts or both are +nan.0. Otherwise it returns #f.

library (scheme lazy)

(scheme lazy) syntax (delay () ((_ expression) promise?) )

Semantics: The delay construct is used together with the procedure force to implement lazy evaluation or call by need. (delay 〈expression〉) returns an object called a promise which at some point in the future can be asked (by the force procedure) to evaluate 〈expression〉, and deliver the resulting value. The effect of 〈expression〉 returning multiple values is unspecified.

(scheme lazy) syntax (delay-force () ((_ expression) promise?) )

Semantics: The expression (delay-force expression) is conceptually similar to (delay (force expression)), with the difference that forcing the result of delay-force will in effect result in a tail call to (force expression), while forcing the result of (delay (force expression)) might not. Thus iterative lazy algorithms that might result in a long series of chains of delay and force can be rewritten using delay-force to prevent consuming unbounded space during evaluation.

(scheme lazy) procedure (force (promise promise?) ) ⟹ *

The force procedure forces the value of a promise created by delay, delay-force, or make-promise. If no value has been computed for the promise, then a value is computed and returned. The value of the promise must be cached (or “memoized”) so that if it is forced a second time, the previously computed value is returned. Consequently, a delayed expression is evaluated using the parameter values and exception handler of the call to force which first requested its value. If promise is not a promise, it may be returned unchanged.

(scheme lazy) procedure (make-promise obj ) ⟹ promise?

The make-promise procedure returns a promise which,when forced, will return obj . It is similar to delay, but does not delay its argument: it is a procedure rather than syntax. If obj is already a promise, it is returned.

(scheme lazy) procedure (promise? obj ) ⟹ boolean?

The promise? procedure returns #t if its argument is a promise, and #f otherwise. Note that promises are not necessarily disjoint from other Scheme types such as procedures.

library (scheme load)

(scheme load) procedure (load (filename string?) ) ⟹ undefined

(scheme load) procedure (load (filename string?) environment-specifier ) ⟹ undefined

It is an error if filename is not a string. An implementation-dependent operation is used to transform filename into the name of an existing file containing Scheme source code. The load procedure reads expressions and definitions from the file and evaluates them sequentially in the environment specified by environment-specifier . If environment-specifier is omitted, (interaction-environment) is assumed. It is unspecified whether the results of the expressions are printed. The load procedure does not affect the values returned by current-input-port and current-output-port. It returns an unspecified value. Rationale: For portability, load must operate on source files. Its operation on other kinds of files necessarily varies among implementations

library (scheme process-context)

(scheme process-context) procedure (command-line ) ⟹ list?

Returns the command line passed to the process as a list of strings. The first string corresponds to the command name, and is implementation-dependent. It is an error to mutate any of these strings.

(scheme process-context) procedure (emergency-exit ) ⟹ undefined

(scheme process-context) procedure (emergency-exit obj ) ⟹ undefined

Terminates the program without running any outstanding dynamic-wind after procedures and communicates an exit value to the operating system in the same manner as exit. Note: The emergency-exit procedure corresponds to the exit procedure in Windows and Posix.

(scheme process-context) procedure (exit ) ⟹ undefined

(scheme process-context) procedure (exit obj ) ⟹ undefined

Runs all outstanding dynamic-wind after procedures, terminates the running program, and communicates an exit value to the operating system. If no argument is supplied, or if obj is #t, the exit procedure should communicate to the operating system that the program exited normally. If obj is #f, the exit procedure should communicate to the operating system that the program exited abnormally. Otherwise, exit should translate obj into an appropriate exit value for the operating system, if possible. The exit procedure must not signal an exception or return to its continuation. Note: Because of the requirement to run handlers, this procedure is not just the operating system’s exit procedure.

(scheme process-context) procedure (get-environment-variable (name string?) ) ⟹ string? / #f /

Many operating systems provide each running process with an environment consisting of environment variables. (This environment is not to be confused with the Scheme environments that can be passed to eval: see section 6.12.) Both the name and value of an environment variable are strings. The procedure get-environment-variable returns the value of the environment variable name, or #f if the named environment variable is not found. It may use locale information to encode the name and decode the value of the environment variable. It is an error if get-environment-variable can’t decode the value. It is also an error to mutate the resulting string.

(scheme process-context) procedure (get-environment-variables ) ⟹ list?

return ⟹ (alist (envname string?) : (value string?))

Returns the names and values of all the environment variables as an alist, where the car of each entry is the name of an environment variable and the cdr is its value, both as strings. The order of the list is unspecified. It is an error to mutate any of these strings or the alist itself.

library (scheme read)

(scheme read) procedure (read ) ⟹ *

(scheme read) procedure (read (port input-port?) ) ⟹ *

The read procedure converts external representations of Scheme objects into the objects themselves. That is, it is a parser for the non-terminal 〈datum〉 (see sections 7.1.2 and 6.4). It returns the next object parsable from the given textual input port, updating port to point to the first character past the end of the external representation of the object. Implementations may support extended syntax to represent record types or other types that do not have datum representations. If an end of file is encountered in the input before any characters are found that can begin an object, then an end-of-file object is returned. The port remains open, and further attempts to read will also return an end-of-file object. If an end of file is encountered after the beginning of an object’s external representation, but the external representation is incomplete and therefore not parsable, an error that satisfies read-error? is signaled.

library (scheme repl)

(scheme repl) procedure (interaction-environment ) ⟹ *

This procedure returns a specifier for a mutable environment that contains an implementation-defined set of bindings, typically a superset of those exported by (scheme base). The intent is that this procedure will return the environment in which the implementation would evaluate expressions entered by the user into a REPL.

library (scheme time)

(scheme time) procedure (current-jiffy ) ⟹ integer?

Returns the number of jiffies as an exact integer that have elapsed since an arbitrary, implementation-defined epoch. A jiffy is an implementation-defined fraction of a second which is defined by the return value of the jiffies-per-second procedure. The starting epoch is guaranteed to be constant during a run of the program, but may vary between runs. Rationale: Jiffies are allowed to be implementation-dependent so that current-jiffy can execute with minimum overhead. It should be very likely that a compactly represented integer will suffice as the returned value. Any particular jiffy size will be inappropriate for some implementations: a microsecond is too long for a very fast machine, while a much smaller unit would force many implementations to return integers which have to be allocated for most calls, rendering current-jiffy less useful for accurate timing measurements.

(scheme time) procedure (current-second ) ⟹ real?

Returns an inexact number representing the current time on the International Atomic Time (TAI) scale. The value 0.0 represents midnight on January 1, 1970 TAI (equivalent to ten seconds before midnight Universal Time) and the value 1.0 represents one TAI second later. Neither high accuracy nor high precision are required; in particular, returning Coordinated Universal Time plus a suitable constant might be the best an implementation can do.

(scheme time) procedure (jiffies-per-second ) ⟹ integer?

Returns an exact integer representing the number of jiffies per SI second. This value is an implementation-specified constant.

library (scheme write)

(scheme write) procedure (display obj ) ⟹ undefined

(scheme write) procedure (display obj (port output-port?) ) ⟹ undefined

Writes a representation of obj to the given textual output port. Strings that appear in the written representation are output as if by write-string instead of by write. Symbols are not escaped. Character objects appear in the representation as if written by write-char instead of by write. The display representation of other objects is unspecified. However, display must not loop forever on self-referencing pairs, vectors, or records. Thus if the normal write representation is used, datum labels are needed to represent cycles as in write. Implementations may support extended syntax to represent record types or other types that do not have datum representations. The display procedure returns an unspecified value. Rationale: The write procedure is intended for producing machine-readable output and display for producing human-readable output.

(scheme write) procedure (write obj ) ⟹ undefined

(scheme write) procedure (write obj (port output-port?) ) ⟹ undefined

Writes a representation of obj to the given textual output port. Strings that appear in the written representation are enclosed in quotation marks, and within those strings backslash and quotation mark characters are escaped by backslashes. Symbols that contain non-ASCII characters are escaped with vertical lines. Character objects are written using the #\ notation. If obj contains cycles which would cause an infinite loop using the normal written representation, then at least the objects that form part of the cycle must be represented using datum labels as described in section 2.4. Datum labels must not be used if there are no cycles. Implementations may support extended syntax to represent record types or other types that do not have datum representations.

(scheme write) procedure (write-shared obj ) ⟹ undefined

(scheme write) procedure (write-shared obj (port output-port?) ) ⟹ undefined

The write-shared procedure is the same as write, except that shared structure must be represented using datum labels for all pairs and vectors that appear more than once in the output.

(scheme write) procedure (write-simple obj ) ⟹ undefined

(scheme write) procedure (write-simple obj (port output-port?) ) ⟹ undefined

The write-simple procedure is the same as write, except that shared structure is never represented using datum labels. This can cause write-simple not to terminate if obj contains circular structure.

library (scheme r5rs)

(scheme r5rs) procedure (* (z number?) ... ) ⟹ number?

This procedure returns the product of its arguments.

(scheme r5rs) procedure (+ (z number?) ... ) ⟹ number?

This procedure returns the sum of its arguments.

(scheme r5rs) procedure (- (z number?) ... ) ⟹ number?

With two or more arguments, this procedure returns the difference of its arguments, associating to the left. With one argument, however, it returns the additive inverse of its argument.

(scheme r5rs) procedure (/ (z1 number?) (z2 number?) ... ) ⟹ number?

With two or more arguments, this procedure returns the quotient of its arguments, associating to the left. With one argument, however, it returns the multiplicative inverse of its argument.

(scheme r5rs) procedure (< (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically increasing.

(scheme r5rs) procedure (<= (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically non-decreasing.

(scheme r5rs) procedure (= (z1 number?) (z2 number?) (z3 number?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are equal.

(scheme r5rs) procedure (> (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically decreasing.

(scheme r5rs) procedure (>= (x1 real?) (x2 real?) (x3 real?) ... ) ⟹ boolean?

This procedure returns #t if its arguments are monotonically non-increasing.

(scheme r5rs) procedure (abs (x real?) ) ⟹ number?

Abs returns the absolute value of its argument.

(scheme r5rs) syntax (and () ((_ test1 ...)) )

The 〈test〉 expressions are evaluated from left to right, and the value of the first expression that evaluates to a false value (see section 6.3.1) is returned. Any remaining ex- pressions 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.

(scheme r5rs) procedure (append (list list?) ... ) ⟹ list?

(scheme r5rs) procedure (append (list list?) ... obj ) ⟹ *

eturns a list consisting of the elements of the first list followed by the elements of the other lists.

The resulting list is always newly allocated, except that it shares structure with the last list argument. The last argument may actually be any object; an improper list results if the last argument is not a proper list.

(scheme r5rs) procedure (apply (proc procedure?) arg1 ... (args list?) ) ⟹ *

Proc must be a procedure and args must be a list. Calls proc with the elements of the list (append (list arg1 . . . ) args) as the actual arguments.

(scheme r5rs) procedure (assoc obj (alist list?) ) ⟹ pair? / #f /

Alist (for "association list") must be a list of pairs. These procedures find the first pair in alist whose car field is obj, and returns that pair. If no pair in alist has obj as its car,then #f (not the empty list) is returned. Assoc uses equal? to compare obj with the car fields of the pairs in alist.

(scheme r5rs) procedure (assq obj (alist list?) ) ⟹ pair? / #f /

Alist (for "association list") must be a list of pairs. These procedures find the first pair in alist whose car field is obj, and returns that pair. If no pair in alist has obj as its car,then #f (not the empty list) is returned. Assq uses eq? to compare obj with the car fields of the pairs in alist.

(scheme r5rs) procedure (assv obj (alist list?) ) ⟹ pair? / #f /

Alist (for "association list") must be a list of pairs. These procedures find the first pair in alist whose car field is obj, and returns that pair. If no pair in alist has obj as its car,then #f (not the empty list) is returned. Assv uses eqv? to compare obj with the car fields of the pairs in alist.

(scheme r5rs) syntax (begin () ((_ expression-or-definition ...)) )

The 〈expression〉s are evaluated sequentially from left to right, and the value(s) of the last 〈expression〉 is(are) returned. This expression type is used to sequence side effects such as input and output.

(scheme r5rs) procedure (boolean? obj ) ⟹ boolean?

Boolean? returns #t if obj is either #t or #f and returns #f otherwise.

(scheme r5rs) procedure (caar (pair pair?) ) ⟹ *

Composition of car and car.

(scheme r5rs) procedure (cadr (pair pair?) ) ⟹ *

Composition of car and cdr.

(scheme r5rs) procedure (call-with-current-continuation (proc procedure?) ) ⟹ *

(proc (k procedure?) ) ⟹ *

The procedure call-with-current-continuation packages up 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 effect at that later time and will instead use the continuation that was in effect when the escape procedure was created. Calling the escape procedure may 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. Except for continuations created by the call-with-values procedure, all continuations take exactly one value. The effect of passing no value or more than one value to continuations that were not created by call-with-values is unspecified.

The escape procedure that is passed to proc has unlimited extent just like any other procedure in Scheme. It may be stored in variables or data structures and may be called as many times as desired.

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 extremely useful for implementing a wide variety of advanced control structures.

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 top level, 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 top level 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 may need to deal with continuations explicitly. Call-with-current-continuation allows Scheme programmers to do that by creating a procedure that acts just like the current continuation.

Most programming languages incorporate one or more special purpose escape constructs with names like exit, return, or even goto. In 1965, however, Peter Landin [16] invented a general purpose escape operator called the J-operator. John Reynolds [24] described a simpler but equally powerful construct in 1972. The catch special form described by Sussman and Steele in the 1975 report on Scheme is exactly the same as Reynolds’s construct, though its name came from a less general construct in MacLisp. Several Scheme implementors noticed that the full power of the catch construct could be provided by a procedure instead of by a special syntactic construct, and the name call-with-current-continuation was coined in 1982. This name is descriptive, but opinions differ on the merits of such a long name, and some people use the name call/cc instead.

(scheme r5rs) procedure (call-with-values (producer procedure?) (consumer procedure?) ) ⟹ *

(producer ) ⟹ *

(consumer obj ... ) ⟹ *

Calls its producer argument with no values 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.

(scheme r5rs) procedure (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.

(scheme r5rs) syntax (case (else ) ((_ key clause1 clause2 ...)) )

((datum1 ...) expression1 expression2 ...) (else expression1 expression2 ...)

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 equivalent (in the sense of eqv?; see section 6.1) to a 〈datum〉, then the expressions in the corresponding 〈clause〉 are evaluated from left to right and the result(s) of the last expression in the 〈clause〉 is(are) returned as the result(s) 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 result(s) of the last is(are) the result(s) of the case expression; otherwise the result of the case expression is unspecified.

(scheme r5rs) procedure (cdar (pair pair?) ) ⟹ *

Composition of cdr and car

(scheme r5rs) procedure (cddr (pair pair?) ) ⟹ *

Composition of cdr and cdr

(scheme r5rs) procedure (cdr (pair pair?) ) ⟹ *

Returns the contents of the cdr field of pair . Note that it is an error to take the cdr of the empty list.

(scheme r5rs) procedure (ceiling (x real?) ) ⟹ real?

Ceiling returns the smallest integer not smaller than x. Note: If the argument to one of these procedures is inexact,then the result will also be inexact. If an exact value is needed, the result should be passed to the inexact->exact procedure.

(scheme r5rs) procedure (char->integer (char char?) ) ⟹ integer?

Given a character, char->integer returns an exact integer representation of the character. This procedure implements order-preserving isomorphisms between the set of characters under the char<=? ordering and some subset of the integers under the <= ordering

(scheme r5rs) procedure (char-ready? ) ⟹ boolean?

(scheme r5rs) procedure (char-ready? (port input-port?) ) ⟹ boolean?

Returns #t if a character is ready on the input port and returns #f otherwise. If char-ready returns #t then the next read-char operation on the given port is guaranteed not to hang. If the port is at end of file then char-ready? returns #t. Port may be omitted, in which case it defaults to the value returned by current-input-port.

Rationale: Char-ready? exists to make it possible for a program to accept characters from interactive ports without getting stuck waiting for input. Any input editors associated with such ports must ensure that characters whose existence has been asserted by char-ready? cannot be rubbed out. If char-ready? were to return #f at end of file, a port at end of file would be indistinguishable from an interactive port that has no ready characters.

(scheme r5rs) procedure (char<=? (char1 char?) (char2 char?) ) ⟹ boolean?

This procedure imposes a total ordering on the set of characters. It is guaranteed that under this ordering:

  • The upper case characters are in order.
  • The lower case characters are in order.
  • The digits are in order.
  • Either all the digits precede all the upper case letters,
  • or vice versa.

  • Either all the digits precede all the lower case letters,
  • or vice versa.

    Some implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicate.

    (scheme r5rs) procedure (char<? (char1 char?) (char2 char?) ) ⟹ boolean?

    This procedure imposes a total ordering on the set of characters. It is guaranteed that under this ordering:

  • The upper case characters are in order.
  • The lower case characters are in order.
  • The digits are in order.
  • Either all the digits precede all the upper case letters,
  • or vice versa.

  • Either all the digits precede all the lower case letters,
  • or vice versa.

    Some implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicate.

    (scheme r5rs) procedure (char=? (char1 char?) (char2 char?) ) ⟹ boolean?

    This procedure imposes a total ordering on the set of characters. It is guaranteed that under this ordering:

  • The upper case characters are in order.
  • The lower case characters are in order.
  • The digits are in order.
  • Either all the digits precede all the upper case letters,
  • or vice versa.

  • Either all the digits precede all the lower case letters,
  • or vice versa.

    Some implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicate.

    (scheme r5rs) procedure (char>=? (char1 char?) (char2 char?) ) ⟹ boolean?

    This procedure imposes a total ordering on the set of characters. It is guaranteed that under this ordering:

  • The upper case characters are in order.
  • The lower case characters are in order.
  • The digits are in order.
  • Either all the digits precede all the upper case letters,
  • or vice versa.

  • Either all the digits precede all the lower case letters,
  • or vice versa.

    Some implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicate.

    (scheme r5rs) procedure (char>? (char1 char?) (char2 char?) ) ⟹ boolean?

    This procedure imposes a total ordering on the set of characters. It is guaranteed that under this ordering:

  • The upper case characters are in order.
  • The lower case characters are in order.
  • The digits are in order.
  • Either all the digits precede all the upper case letters,
  • or vice versa.

  • Either all the digits precede all the lower case letters,
  • or vice versa.

    Some implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicate.

    (scheme r5rs) procedure (char? obj ) ⟹ boolean?

    Returns #t if obj is a character, otherwise returns #f.

    (scheme r5rs) procedure (close-input-port (port input-port?) ) ⟹ undefined

    Closes the file associated with port, rendering the port incapable of delivering characters. These routine has no effect if the file has already been closed.

    (scheme r5rs) procedure (close-output-port (port output-port?) ) ⟹ undefined

    Closes the file associated with port, rendering the port incapable of accepting characters. These routine has no effect if the file has already been closed.

    (scheme r5rs) syntax (cond (else => ) ((_ clause1 clause2 ...)) )

    (test expression1 ...) (test => receiver) (else expression1 expression2 ...)

    receiver ⟹ procedure?

    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 (see section 6.3.1). When a 〈test〉 evaluates to a true value, then the remaining 〈expression〉s in its 〈clause〉 are evaluated in order,and the result(s) of the last 〈expression〉 in the 〈clause〉 is(are) returned as the result(s) 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. Its value must be a procedure that accepts one argument; this procedure is then called on the value of the 〈test〉 and the value(s) returned by this procedure is(are) returned by the cond expression. If all 〈test〉s evaluate to false values, 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, and the value(s) of the last one is(are) returned.

    (scheme r5rs) procedure (cons obj1 obj2 ) ⟹ pair?

    Returns a newly allocated pair whose car is obj1 and whose cdr is obj2. The pair is guaranteed to be different (in the sense of eqv?) from every existing object.

    (scheme r5rs) procedure (current-input-port ) ⟹ input-port?

    Returns the current default input port.

    (scheme r5rs) procedure (current-output-port ) ⟹ output-port?

    Returns the current default output port.

    (scheme r5rs) syntax (define () ((_ variable expression)) ((_ (variable parameter1 ...) body)) ((_ (variable parameter1 ... . parameter) body)) )

    At the top level of a program, a definition (define 〈variable〉 〈expression〉) has essentially the same effect as the assignment expression (set! 〈variable〉 〈expression〉) if 〈variable〉 is bound. If 〈variable〉 is not bound, however, then the definition will bind 〈variable〉 to a new location before performing the assignment, whereas it would be an error to perform a set! on an unbound variable.

    Some implementations of Scheme use an initial environment in which all possible variables are bound to locations, most of which contain undefined values. Top level definitions in such an implementation are truly equivalent to assignments.

    (scheme r5rs) syntax (define-syntax () ((_ keyword transformer-spec)) )

    transformer-spec ⟹ transformer-spec

    Syntax definitions are valid only at the top level of a 〈program〉. 〈Keyword〉 is an identifier, and the 〈transformer spec〉 should be an instance of syntax-rules. The top-level syntactic environment is extended by binding the 〈keyword〉 to the specified transformer. There is no define-syntax analogue of internal definitions. Although macros may expand into definitions and syntax definitions in any context that permits them, it is an error for a definition or syntax definition to shadow a syntactic keyword whose meaning is needed to determine whether some form in the group of forms that contains the shadowing definition is in fact a definition, or, for internal definitions, is needed to determine the boundary between the group and the expressions that follow the group.

    (scheme r5rs) procedure (denominator (q rational?) ) ⟹ integer?

    This procedure returns the denominator of its argument; the result is computed as if the argument was represented as a fraction in lowest terms. The denominator is always positive. The denominator of 0 is defined to be 1.

    (scheme r5rs) syntax (do () ((_ (variable-decl1 ...) (test expression ...) command ...)) )

    (variable init step) (variable init)

    Do is an iteration construct. It specifies a set of variables to be bound, how they are to be initialized at the start, and how they are to be updated on each iteration. When a termination condition is met, the loop exits after evaluating the 〈expression〉s.

    Do expressions are evaluated as follows: The 〈init〉 expressions are evaluated (in some unspecified order), the 〈variable〉s are bound to fresh locations, the results of the 〈init〉 expressions are stored in the bindings of the 〈variable〉s, and then the iteration phase begins.

    Each iteration begins by evaluating 〈test〉; if the result is false (see section 6.3.1), then the 〈command〉 expressions are evaluated in order for effect, the 〈step〉 expressions are evaluated in some unspecified order, the 〈variable〉s are bound to fresh locations, the results of the 〈step〉s are stored in the bindings of the 〈variable〉s, and the next iteration begins.

    If 〈test〉 evaluates to a true value, then the 〈expression〉s are evaluated from left to right and the value(s) of the last 〈expression〉 is(are) returned. If no 〈expression〉s are present, then the value of the do expression is unspecified.

    The region of the binding of a 〈variable〉 consists of the entire do expression except for the 〈init〉s. It is an error for a 〈variable〉 to appear more than once in the list of do variables.

    A 〈step〉 may be omitted, in which case the effect is the same as if (〈variable〉 〈init〉 〈variable〉) had been written instead of (〈variable〉 〈init〉).

    (scheme r5rs) procedure (dynamic-wind (before procedure?) (thunk procedure?) (after procedure?) ) ⟹ *

    (before ) ⟹ undefined

    (thunk ) ⟹ *

    (after ) ⟹ undefined

    Calls thunk without arguments, returning the result(s) of this call. Before and after are called, also without arguments, as required by the following rules (note that in the absence of calls to continuations captured using call-with-current-continuation the three arguments are called once each, in order). Before is called whenever execution enters the dynamic extent of the call to thunk and after is called whenever it exits that dynamic extent. The dynamic extent of a procedure call is the period between when the call is initiated and when it returns. In Scheme, because of call-with-current-continuation,the dynamic extent of a call may not be a single, connected time period. It is defined as follows:

  • The dynamic extent is entered when execution of the body of the called procedure begins.
  • The dynamic extent is also entered when execution is not within the dynamic extent and a continuation is invoked that was captured (using call-with-current-continuation) during the dynamic extent.
  • It is exited when the called procedure returns.
  • It is also exited when execution is within the dynamic extent and a continuation is invoked that was captured while not within the dynamic extent.
  • If a second call to dynamic-wind occurs within the dynamic extent of the call to thunk and then a continuation is invoked in such a way that the after s from these two invocations of dynamic-wind are both to be called, then the after associated with the second (inner) call to dynamic-wind is called first.

    If a second call to dynamic-wind occurs within the dynamic extent of the call to thunk and then a continuation is invoked in such a way that the befores from these two invocations of dynamic-wind are both to be called, then the before associated with the first (outer) call to dynamic-wind is called first.

    If invoking a continuation requires calling the before from one call to dynamic-wind and the after from another, then the after is called first.

    The effect of using a captured continuation to enter or exit the dynamic extent of a call to before or after is undefined.

    (scheme r5rs) procedure (eof-object? obj ) ⟹ boolean?

    Returns #t if obj is an end of file object, otherwise returns #f. The precise set of end of file objects will vary among implementations, but in any case no end of file object will ever be an object that can be read in using read.

    (scheme r5rs) procedure (eq? obj1 obj2 ) ⟹ boolean?

    Eq? is similar to eqv? except that in some cases it is capable of discerning distinctions finer than those detectable by eqv?.

    Eq? and eqv? are guaranteed to have the same behavior on symbols, booleans, the empty list, pairs, procedures, and non-empty strings and vectors. Eq?’s behavior on numbers and characters is implementation-dependent, but it will always return either true or false, and will return true only when eqv? would also return true. Eq? may also behave differently from eqv? on empty vectors and empty strings.

    Rationale: It will usually be possible to implement eq? much more efficiently than eqv?, for example, as a simple pointer comparison instead of as some more complicated operation. One reason is that it may not be possible to compute eqv? of two numbers in constant time, whereas eq? implemented as pointer comparison will always finish in constant time. Eq? may be used like eqv? in applications using procedures to implement objects with state since it obeys the same constraints as eqv?.

    (scheme r5rs) procedure (equal? obj1 obj2 ) ⟹ boolean?

    Equal? recursively compares the contents of pairs, vectors, and strings, applying eqv? on other objects such as numbers and symbols. A rule of thumb is that objects are generally equal? if they print the same. Equal? may fail to terminate if its arguments are circular data structures.

    (scheme r5rs) procedure (eqv? obj1 obj2 ) ⟹ boolean?

    The eqv? procedure defines a useful equivalence relation on objects. Briefly, it returns #t if obj1 and obj2 should normally be regarded as the same object. This relation is left slightly open to interpretation, but the following partial specification of eqv? holds for all implementations of Scheme. The eqv? procedure returns #t if:

  • obj1 and obj2 are both #t or both #f.
  • obj1 and obj2 are both symbols and (string=? (symbol->string obj1) (symbol->string obj2)) => #t. Note: This assumes that neither obj1 nor obj2 is an "uninterned symbol" as alluded to in section 6.3.3. This report does not presume to specify the behavior of eqv? on implementation-dependent extensions.
  • obj1 and obj2 are both numbers, are numerically equal (see =, section 6.2), and are either both exact or both inexact.
  • obj1 and obj2 are both characters and are the same character according to the char=? procedure (section 6.3.4).
  • both obj1 and obj2 are the empty list.
  • obj1 and obj2 are pairs, vectors, or strings that denote the same locations in the store (section 3.4).
  • obj1 and obj2 are procedures whose location tags are equal (section 4.1.4).
  • The eqv? procedure returns #f if:

  • obj1 and obj2 are of different types (section 3.2).
  • one of obj1 and obj2 is #t but the other is #f.
  • obj1 and obj2 are symbols but (string=? (symbol->string obj1) (symbol->string obj2)) => #f
  • one of obj1 and obj2 is an exact number but the other is an inexact number.
  • obj1 and obj2 are numbers for which the = procedure returns #f.
  • obj1 and obj2 are characters for which the char=? procedure returns #f.
  • one of obj1 and obj2 is the empty list but the other is not.
  • obj1 and obj2 are pairs, vectors, or strings that denote distinct locations.
  • obj1 and obj2 are procedures that would behave differently (return different value(s) or have different side effects) for some arguments.
  • (scheme r5rs) procedure (inexact->exact (z number?) ) ⟹ exact?

    Inexact->exact returns an exact representation of z. The value returned is the exact number that is numerically closest to the argument. If an inexact argument has no reasonably close exact equivalent, then a violation of an implementation restriction may be reported.

    The procedure implements the natural one-to-one correspondence between exact and inexact integers throughout an implementation-dependent range. See section 6.2.3.

    (scheme r5rs) procedure (exact? (z number?) ) ⟹ boolean?

    This numerical predicate provides test for the exactness of a quantity. For any Scheme number, precisely one of exact?, inexact? predicates is true.

    (scheme r5rs) procedure (expt (z1 number?) (z2 number?) ) ⟹ number?

    Returns z1 raised to the power z2. 0^z is 1 if z = 0 and 0 otherwise.

    (scheme r5rs) procedure (floor (x real?) ) ⟹ integer?

    Floor returns the largest integer not larger than x. Note: If the argument to the procedure is inexact, then the result will also be inexact. If an exact value is needed, the result should be passed to the inexact->exact procedure.

    (scheme r5rs) procedure (for-each (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ undefined

    (proc obj1 obj2 ... ) ⟹ undefined

    The arguments to for-each are like the arguments to map, but for-each calls proc for its side effects rather than for its values. Unlike map, for-each is guaranteed to call proc on the elements of the lists in order from the first element(s) to the last, and the value returned by for-each is unspecified.

    (scheme r5rs) procedure (gcd (n integer?) ... ) ⟹ integer?

    The procedure returns the greatest common divisor of its arguments. The result is always non-negative.

    (scheme r5rs) syntax (if () ((_ test consequent)) ((_ test consequent alternate)) )

    An if expression is evaluated as follows: first,〈test〉 is evaluated. If it yields a true value (see section 6.3.1), then 〈consequent〉 is evaluated and its value(s) is(are) returned. Otherwise 〈alternate〉 is evaluated and its value(s) is(are) returned. If 〈test〉 yields a false value and no 〈alternate〉 is specified, then the result of the expression is unspecified.

    (scheme r5rs) procedure (exact->inexact (z number?) ) ⟹ inexact?

    Exact->inexact returns an inexact representation of z. The value returned is the inexact number that is numerically closest to the argument. If an exact argument has no reasonably close inexact equivalent, then a violation of an implementation restriction may be reported.

    (scheme r5rs) procedure (inexact? (z number?) ) ⟹ boolean?

    This numerical predicate provides test for the exactness of a quantity. For any Scheme number, precisely one of exact?, inexact? predicates is true.

    (scheme r5rs) procedure (input-port? obj ) ⟹ boolean?

    Returns #t if obj is an input port, otherwise returns #f

    (scheme r5rs) procedure (integer->char (n integer?) ) ⟹ char?

    Given an exact integer that is the image of a character under char->integer,integer->char returns that character. The procedure implements order-preserving isomorphisms between the set of characters under the char<=? ordering and some subset of the integers under the <= ordering

    (scheme r5rs) syntax (lambda () ((_ formals body) procedure?) )

    (variable1 ...) variable (variable1 ... variable_n . variable_n+1)

    A lambda expression evaluates to a procedure. The environment in effect when the lambda expression was evaluated is remembered as part of the procedure. When the procedure is later called with some actual arguments, the environment in which the lambda expression was evaluated will be extended by binding the variables in the formal argument list to fresh locations, the corresponding actual argument values will be stored in those locations, and the expressions in the body of the lambda expression will be evaluated sequentially in the extended environment. The result(s) of the last expression in the body will be returned as the result(s) of the procedure call.

    〈Formals〉 should have one of the following forms:

  • (〈variable1〉 . . . ): The procedure takes a fixed number of arguments; when the procedure is called, the arguments will be stored in the bindings of the corresponding variables.
  • 〈variable〉: The procedure takes any number of arguments; when the procedure is called, the sequence of actual arguments is converted into a newly allocated list, and the list is stored in the binding of the 〈variable〉.
  • (〈variable1〉 . . . 〈variablen〉 . 〈variablen+1〉): If a space-delimited period precedes the last variable, then the procedure takes n or more arguments, where n is the number of formal arguments before the period (there must be at least one). The value stored in the binding of the last variable will be a newly allocated list of the actual arguments left over after all the other actual arguments have been matched up against the other formal arguments.
  • It is an error for a 〈variable〉 to appear more than once in 〈formals〉. Each procedure created as the result of evaluating a lambda expression is (conceptually) tagged with a storage location, in order to make eqv? and eq? work on procedures (see section 6.1).

    (scheme r5rs) procedure (lcm (n integer?) ... ) ⟹ integer?

    This procedure returns the least common multiple of its arguments. The result is always non-negative.

    (scheme r5rs) procedure (length (list list?) ) ⟹ integer?

    Returns the length of list.

    (scheme r5rs) syntax (let () ((_ bindings body)) ((_ variable bindings body)) )

    ((variable1 init1) ...)

    The 〈init〉s are evaluated in the current environment (in some unspecified order), the 〈variable〉s are bound to fresh locations holding the results, the 〈body〉 is evaluated in the extended environment, and the value(s) of the last expression of 〈body〉 is(are) returned. Each bind ing of a 〈variable〉 has 〈body〉 as its region.

    "Named let" is a variant on the syntax of let which provides a more general looping construct than do and may also be used to express recursions. It has the same syntax and semantics as ordinary let except that 〈variable〉 is bound within 〈body〉 to a procedure whose formal arguments are the bound variables and whose body is 〈body〉. Thus the execution of 〈body〉 may be repeated by invoking the procedure named by 〈variable〉.

    (scheme r5rs) syntax (let* () ((_ bindings body)) )

    ((variable1 init1) ...)

    Let* is similar to let, but the bindings are performed sequentially from left to right, and the region of a binding indicated by (〈variable〉 〈init〉) is that part of the let* expression to the right of the binding. Thus the second binding is done in an environment in which the first binding is visible, and so on.

    (scheme r5rs) syntax (let-syntax () ((_ bindings body)) )

    ((keyword transformer-spec) ...)

    transformer-spec ⟹ transformer-spec

    Each 〈keyword〉 is an identifier, each 〈transformer spec〉 is an instance of syntax-rules, and 〈body〉 should be a sequence of one or more expressions. It is an error for a 〈keyword〉 to appear more than once in the list of keywords being bound.

    Semantics: The 〈body〉 is expanded in the syntactic environment obtained by extending the syntactic environment of the let-syntax expression with macros whose keywords are the 〈keyword〉s, bound to the specified transformers. Each binding of a 〈keyword〉 has 〈body〉 as its region.

    (scheme r5rs) syntax (letrec () ((_ bindings body)) )

    ((variable1 init1) ...)

    The 〈variable〉s are bound to fresh locations holding undefined values, the 〈init〉s 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 〈variable〉. If this restriction is violated, then it is an error. The restriction is necessary because Scheme passes arguments by value rather than by name. In the most common uses of letrec, all the 〈init〉s are lambda expressions and the restriction is satisfied automatically.

    (scheme r5rs) syntax (letrec-syntax () ((_ bindings body)) )

    ((keyword transformer-spec) ...)

    The 〈body〉 is expanded in the syntactic environment obtained by extending the syntactic environment of the letrec-syntax expression with macros whose key- words are the 〈keyword〉s, bound to the specified transformers. Each binding of a 〈keyword〉 has the 〈bindings〉 as well as the 〈body〉 within its region, so the transformers can transcribe expressions into uses of the macros introduced by the letrec-syntax expression.

    (scheme r5rs) procedure (list obj ... ) ⟹ list?

    Returns a newly allocated list of its arguments.

    (scheme r5rs) procedure (list->string (list list?) ) ⟹ string?

    List->string returns a newly allocated string formed from the characters in the list list, which must be a list of characters. String->list and list->string are inverses so far as equal? is concerned.

    (scheme r5rs) procedure (list->vector (list list?) ) ⟹ vector?

    List->vector returns a newly created vector initialized to the elements of the list list.

    (scheme r5rs) procedure (list-ref (list list?) (k integer?) ) ⟹ *

    Returns the kth element of list. (This is the same as the car of (list-tail list k).) It is an error if list has fewer than k elements.

    (scheme r5rs) procedure (list-tail (list list?) (k integer?) ) ⟹ list?

    Returns the sublist of list obtained by omitting the first k elements. It is an error if list has fewer than k elements.

    (scheme r5rs) procedure (list? obj ) ⟹ boolean?

    Returns #t if obj is a list, otherwise returns #f. By definition, all lists have finite length and are terminated by the empty list.

    (scheme r5rs) procedure (make-string (k integer?) ) ⟹ string?

    (scheme r5rs) procedure (make-string (k integer?) (char char?) ) ⟹ string?

    Make-string returns a newly allocated string of length k. If char is given, then all elements of the string are initialized to char, otherwise the contents of the string are unspecified

    (scheme r5rs) procedure (make-vector (k integer?) ) ⟹ vector?

    (scheme r5rs) procedure (make-vector (k integer?) fill ) ⟹ vector?

    Returns a newly allocated vector of k elements. If a second argument is given, then each element is initialized to fill. Otherwise the initial contents of each element is unspecified.

    (scheme r5rs) procedure (map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?

    (proc obj1 obj2 ... ) ⟹ *

    The lists must be lists, and proc must be a procedure taking as many arguments as there are lists and returning a single value. If more than one list is given, then they must all be the same length. Map applies proc element-wise to the elements of the lists and returns a list of the results, in order. The dynamic order in which proc is applied to the elements of the lists is unspecified.

    (scheme r5rs) procedure (max (x1 real?) (x2 real?) ... ) ⟹ real?

    This procedure returns the maximum of its arguments. Note: If any argument is inexact, then the result will also be inexact (unless the procedure can prove that the inaccuracy is not large enough to affect the result, which is possible only in unusual implementations). If min or max is used to compare numbers of mixed exactness, and the numerical value of the result cannot be represented as an inexact number without loss of accuracy, then the procedure may report a violation of an implementation restriction.

    (scheme r5rs) procedure (member obj (list list?) ) ⟹ #f / list? /

    This procedure returns the first sublist of list whose car is obj , where the sublists of list are the non-empty lists returned by (list-tail list k ) for k less than the length of list. If obj does not occur in list, then #f (not the empty list) is returned. Member uses equal? to compare obj with the elements of list.

    (scheme r5rs) procedure (memq obj (list list?) ) ⟹ #f / list? /

    This procedure returns the first sublist of list whose car is obj , where the sublists of list are the non-empty lists returned by (list-tail list k ) for k less than the length of list. If obj does not occur in list, then #f (not the empty list) is returned. Memq uses eq? to compare obj with the elements of list.

    (scheme r5rs) procedure (memv obj (list list?) ) ⟹ #f / list? /

    This procedure returns the first sublist of list whose car is obj , where the sublists of list are the non-empty lists returned by (list-tail list k ) for k less than the length of list. If obj does not occur in list, then #f (not the empty list) is returned. Memv uses eqv? to compare obj with the elements of list.

    (scheme r5rs) procedure (min (x1 real?) (x2 real?) ... ) ⟹ real?

    This procedure returns the minimum of its arguments. Note: If any argument is inexact, then the result will also be inexact (unless the procedure can prove that the inaccuracy is not large enough to affect the result, which is possible only in unusual implementations). If min or max is used to compare numbers of mixed exactness, and the numerical value of the result cannot be represented as an inexact number without loss of accuracy, then the procedure may report a violation of an implementation restriction.

    (scheme r5rs) procedure (modulo (n1 integer?) (n2 integer?) ) ⟹ integer?

    Number-theoretic (integer) division. n2 should be non-zero.

    (scheme r5rs) procedure (newline ) ⟹ undefined

    (scheme r5rs) procedure (newline (port output-port?) ) ⟹ undefined

    Writes an end of line to port. Exactly how this is done differs from one operating system to another. Returns an unspecified value. The port argument may be omitted, in which case it defaults to the value returned by current-output-port.

    (scheme r5rs) procedure (not obj ) ⟹ boolean?

    Not returns #t if obj is false, and returns #f otherwise.

    (scheme r5rs) procedure (null? obj ) ⟹ boolean?

    Returns #t if obj is the empty list, otherwise returns #f

    (scheme r5rs) procedure (number->string (z number?) ) ⟹ string?

    (scheme r5rs) procedure (number->string (z number?) (radix integer?) ) ⟹ string?

    Radix must be an exact integer, either 2, 8, 10, or 16. If omitted, radix defaults to 10. The procedure number-> string takes a number and a radix and returns as a string an external representation of the given number in the given radix such that

    (let ((number number) (radix radix)) (eqv? number (string->number (number->string number radix) radix)))

    is true. It is an error if no possible result makes this expression true.

    If z is inexact, the radix is 10, and the above expression can be satisfied by a result that contains a decimal point, then the result contains a decimal point and is expressed using the minimum number of digits (exclusive of exponent and trailing zeroes) needed to make the above expression true [3, 5]; otherwise the format of the result is unspecified. The result returned by number->string never contains an explicit radix prefix.

    Note: The error case can occur only when z is not a complex number or is a complex number with a non-rational real or imaginary part.

    Rationale: If z is an inexact number represented using flonums,and the radix is 10, then the above expression is normally satisfied by a result containing a decimal point. The unspecified case allows for infinities, NaNs, and non-flonum representations.

    (scheme r5rs) procedure (numerator (q rational?) ) ⟹ integer?

    This procedure returns the numerator of its argument; the result is computed as if the argument was represented as a fraction in lowest terms.

    (scheme r5rs) syntax (or () ((_ test1 ...)) )

    The 〈test〉 expressions are evaluated from left to right, and the value of the first expression that evaluates to a true value (see section 6.3.1) is returned. Any remaining expressions are not evaluated. If all expressions evaluate to false values, the value of the last expression is returned. If there are no expressions then #f is returned.

    (scheme r5rs) procedure (output-port? obj ) ⟹ boolean?

    Returns #t if obj is an output port, otherwise returns #f.

    (scheme r5rs) procedure (pair? obj ) ⟹ boolean?

    Pair? returns #t if obj is a pair, and otherwise returns #f.

    (scheme r5rs) procedure (peek-char ) ⟹ eof-object? / char? /

    (scheme r5rs) procedure (peek-char (port input-port?) ) ⟹ eof-object? / char? /

    Returns the next character available from the input port, without updating the port to point to the following character. If no more characters are available, an end of file object is returned. Port may be omitted, in which case it defaults to the value returned by current-input-port.

    Note: The value returned by a call to peek-char is the same as the value that would have been returned by a call to read-char with the same port. The only difference is that the very next call to read-char or peek-char on that port will return the value returned by the preceding call to peek-char. In particular, a call to peek-char on an interactive port will hang waiting for input whenever a call to read-char would have hung.

    (scheme r5rs) procedure (procedure? obj ) ⟹ boolean?

    Returns #t if obj is a procedure, otherwise returns #f.

    (scheme r5rs) syntax (quasiquote () ((_ qq-template)) )

    "Backquote" or "quasiquote" expressions are useful for constructing a list or vector structure when most but not all of the desired structure is known in advance. If no commas appear within the 〈qq template〉, the result of evaluating `〈qq template〉 is equivalent to the result of evaluating ’〈qq template〉. If a comma appears within the 〈qq template〉, however, the expression following the comma is evaluated ("unquoted") and its result is inserted into the structure instead of the comma and the expression. If a comma appears followed immediately by an at-sign (@), then the following expression must evaluate to a list; the opening and closing parentheses of the list are then “stripped away” and the elements of the list are inserted in place of the comma at-sign expression sequence. A comma at-sign should only appear within a list or vector 〈qq template〉.

    Quasiquote forms may be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost backquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation.

    The two notations `〈qq template〉 and (quasiquote 〈qq template〉) are identical in all respects. ,〈expression〉 is identical to (unquote 〈expression〉), and ,@〈expression〉 is identical to (unquote-splicing 〈expression〉). The external syntax generated by write for two-element lists whose car is one of these symbols may vary between implementations.

    Unpredictable behavior can result if any of the symbols quasiquote, unquote, or unquote-splicing appear in positions within a 〈qq template〉 otherwise than as described above.

    (scheme r5rs) syntax (quote () ((_ datum)) )

    (quote 〈datum〉) evaluates to 〈datum〉. 〈Datum〉 may be any external representation of a Scheme object (see section 3.3). This notation is used to include literal constants in Scheme code.

    (quote 〈datum〉) may be abbreviated as ’〈datum〉. The two notations are equivalent in all respects.

    Numerical constants, string constants, character constants,and boolean constants evaluate "to themselves"; they need not be quoted.

    As noted in section 3.4, it is an error to alter a constant (i.e. the value of a literal expression) using a mutation procedure like set-car! or string-set!.

    (scheme r5rs) procedure (quotient (n1 integer?) (n2 integer?) ) ⟹ integer?

    Implements number-theoretic (integer) division. n2 should be non-zero

    (scheme r5rs) procedure (rationalize (x real?) (y real?) ) ⟹ rational?

    Rationalize returns the simplest rational number differing from x by no more than y.

    (scheme r5rs) procedure (read-char ) ⟹ eof-object? / char? /

    (scheme r5rs) procedure (read-char (port input-port?) ) ⟹ eof-object? / char? /

    Returns the next character available from the input port, updating the port to point to the following character. If no more characters are available, an end of file object is returned. Port may be omitted, in which case it defaults to the value returned by current-input-port.

    (scheme r5rs) procedure (remainder (n1 integer?) (n2 integer?) ) ⟹ integer?

    Implements number-theoretic (integer) division. n2 should be non-zero

    (scheme r5rs) procedure (reverse (list list?) ) ⟹ list?

    Returns a newly allocated list consisting of the elements of list in reverse order.

    (scheme r5rs) procedure (round (x real?) ) ⟹ integer?

    Round returns the closest integer to x, rounding to even when x is halfway between two integers.

    Rationale: Round rounds to even for consistency with the default rounding mode specified by the IEEE floating point standard.

    Note: If the argument to the procedure is inexact, then the result will also be inexact. If an exact value is needed, the result should be passed to the inexact->exact procedure.

    (scheme r5rs) syntax (set! () ((_ variable expression)) )

    〈Expression〉 is evaluated, and the resulting value is stored in the location to which 〈variable〉 is bound. 〈Variable〉 must be bound either in some region enclosing the set! expression or at top level. The result of the set! expression is unspecified.

    (scheme r5rs) procedure (set-car! (pair pair?) obj ) ⟹ undefined

    Stores obj in the car field of pair.

    (scheme r5rs) procedure (set-cdr! (pair pair?) obj ) ⟹ undefined

    Stores obj in the cdr field of pair.

    (scheme r5rs) procedure (string (char char?) ... ) ⟹ string?

    Returns a newly allocated string composed of the arguments.

    (scheme r5rs) procedure (string->list (string string?) ) ⟹ list?

    String->list returns a newly allocated list of the characters that make up the given string. String->list and list->string are inverses so far as equal? is concerned.

    (scheme r5rs) procedure (string->number (string string?) ) ⟹ number? / #f /

    (scheme r5rs) procedure (string->number (string string?) (radix integer?) ) ⟹ number? / #f /

    Returns a number of the maximally precise representation expressed by the given string. Radix must be an exact integer, either 2, 8, 10, or 16. If supplied, radix is a default radix that may be overridden by an explicit radix prefix in string (e.g. "#o177"). If radix is not supplied, then the default radix is 10. If string is not a syntactically valid notation for a number, then string->number returns #f.

    Note: The domain of string->number may be restricted by implementations in the following ways. String->number is permitted to return #f whenever string contains an explicit radix prefix. If all numbers supported by an implementation are real, then string->number is permitted to return #f whenever string uses the polar or rectangular notations for complex numbers. If all numbers are integers, then string->number may return #f whenever the fractional notation is used. If all numbers are exact, then string->number may return #f whenever an exponent marker or explicit exactness prefix is used, or if a # appears in place of a digit. If all inexact numbers are integers, then string->number may return #f whenever a decimal point is used.

    (scheme r5rs) procedure (string->symbol (string string?) ) ⟹ symbol?

    Returns the symbol whose name is string. This procedure can create symbols with names containing special characters or letters in the non-standard case, but it is usually a bad idea to create such symbols because in some implementations of Scheme they cannot be read as themselves. See symbol->string.

    (scheme r5rs) procedure (string-append (string string?) ... ) ⟹ string?

    Returns a newly allocated string whose characters form the concatenation of the given strings.

    (scheme r5rs) procedure (string-copy (string string?) ) ⟹ string?

    Returns a newly allocated copy of the given string.

    (scheme r5rs) procedure (string-fill! (string string?) (fill char?) ) ⟹ undefined

    Stores char in every element of the given string and returns an unspecified value.

    (scheme r5rs) procedure (string-length (string string?) ) ⟹ integer?

    Returns the number of characters in the given string.

    (scheme r5rs) procedure (string-ref (string string?) (k integer?) ) ⟹ char?

    k must be a valid index of string. String-ref returns character k of string using zero-origin indexing.

    (scheme r5rs) procedure (string-set! (string string?) (k integer?) (char char?) ) ⟹ undefined

    k must be a valid index of string. String-set! stores char in element k of string and returns an unspecified value.

    (scheme r5rs) procedure (string<=? (string1 string?) (string2 string?) ) ⟹ boolean?

    string<=? is the lexicographic ordering on strings induced by the ordering char<=? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. Implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicates.

    (scheme r5rs) procedure (string<? (string1 string?) (string2 string?) ) ⟹ boolean?

    string<? is the lexicographic ordering on strings induced by the ordering char<? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. Implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicates.

    (scheme r5rs) procedure (string=? (string1 string?) (string2 string?) ) ⟹ boolean?

    Returns #t if the two strings are the same length and contain the same characters in the same positions, otherwise returns #f.

    (scheme r5rs) procedure (string>=? (string1 string?) (string2 string?) ) ⟹ boolean?

    string>=? is the lexicographic ordering on strings induced by the ordering char>=? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. Implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicates.

    (scheme r5rs) procedure (string>? (string1 string?) (string2 string?) ) ⟹ boolean?

    string>? is the lexicographic ordering on strings induced by the ordering char>? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. Implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicates.

    (scheme r5rs) procedure (string? obj ) ⟹ boolean?

    Returns #t if obj is a string, otherwise returns #f

    (scheme r5rs) procedure (substring (string string?) (start integer?) (end integer?) ) ⟹ string?

    Substring returns a newly allocated string formed from the characters of string beginning with index start (inclusive) and ending with index end (exclusive).

    (scheme r5rs) procedure (symbol->string (symbol symbol?) ) ⟹ string?

    Returns the name of symbol as a string. If the symbol was part of an object returned as the value of a literal expression (section 4.1.2) or by a call to the read procedure, and its name contains alphabetic characters, then the string returned will contain characters in the implementation’s preferred standard case—some implementations will prefer upper case, others lower case. If the symbol was returned by string->symbol, the case of characters in the string returned will be the same as the case in the string that was passed to string->symbol. It is an error to apply mutation procedures like string-set! to strings returned by this procedure.

    (scheme r5rs) procedure (symbol? obj ) ⟹ boolean?

    Returns #t if obj is a symbol, otherwise returns #f.

    (scheme r5rs) syntax (syntax-rules (_ ) ((_ (literal ...) syntax-rule ...) transformer-spec) )

    (pattern template)

    _ identifier constant (pattern ...) (pattern pattern ... . pattern) (pattern ... pattern ellipsis pattern ...) (pattern ... pattern ellipsis pattern ... . pattern) #(pattern ...) #(pattern ... pattern ellipsis pattern ...)

    identifier constant (element ...) (element element ... . template) (ellipsis template) #(element ...)

    template template ellipsis

    An instance of syntax-rules produces a new macro transformer by specifying a sequence of hygienic rewrite rules. A use of a macro whose keyword is associated with a transformer specified by syntax-rules is matched against the patterns contained in the 〈syntax rule〉s, beginning with the leftmost 〈syntax rule〉. When a match is found, the macro use is transcribed hygienically according to the template.

    An identifier that appears in the pattern of a 〈syntax rule〉 is a pattern variable, unless it is the keyword that begins the pattern, is listed in 〈literals〉, or is the identifier “...”. Pattern variables match arbitrary input elements and are used to refer to elements of the input in the template. It is an error for the same pattern variable to appear more than once in a 〈pattern〉.

    The keyword at the beginning of the pattern in a 〈syntax rule〉 is not involved in the matching and is not considered a pattern variable or literal identifier.

    Rationale: The scope of the keyword is determined by the expression or syntax definition that binds it to the associated macro transformer. If the keyword were a pattern variable or literal identifier, then the template that follows the pattern would be within its scope regardless of whether the keyword were bound by let-syntax or by letrec-syntax.

    Identifiers that appear in 〈literals〉 are interpreted as literal identifiers to be matched against corresponding subforms of the input. A subform in the input matches a literal identifier if and only if it is an identifier and either both its occurrence in the macro expression and its occurrence in the macro definition have the same lexical binding, or the two identifiers are equal and both have no lexical binding.

    A subpattern followed by ... can match zero or more elements of the input. It is an error for ... to appear in 〈literals〉. Within a pattern the identifier ... must follow the last element of a nonempty sequence of subpatterns.

    More formally, an input form F matches a pattern P if and only if:

  • P is a non-literal identifier; or
  • P is a literal identifier and F is an identifier with the same binding; or
  • P is a list (P1 . . . Pn) and F is a list of n forms that match P1 through Pn, respectively; or
  • P is an improper list (P1 P2 . . . Pn . Pn+1) and F is a list or improper list of n or more forms that match P1 through Pn, respectively, and whose nth "cdr" matches Pn+1; or
  • P is of the form (P1 . . . Pn Pn+1 〈ellipsis〉) where 〈ellipsis〉 is the identifier ... and F is a proper list of at least n forms, the first n of which match P1 through Pn, respectively, and each remaining element of F matches Pn+1; or
  • P is a vector of the form #(P1 . . . Pn) and F is a vector of n forms that match P1 through Pn; or
  • P is of the form #(P1 . . . Pn Pn+1 〈ellipsis〉) where 〈ellipsis〉 is the identifier ... and F is a vector of n or more forms the first n of which match P1 through Pn, respectively, and each remaining element of F matches Pn+1; or
  • P is a datum and F is equal to P in the sense of the equal? procedure.
  • It is an error to use a macro keyword, within the scope of its binding, in an expression that does not match any of the patterns.

    When a macro use is transcribed according to the template of the matching 〈syntax rule〉, pattern variables that occur in the template are replaced by the subforms they match in the input. Pattern variables that occur in subpatterns followed by one or more instances of the identifier ... are allowed only in subtemplates that are followed by as many instances of .... They are replaced in the output by all of the subforms they match in the input, distributed as indicated. It is an error if the output cannot be built up as specified.

    Identifiers that appear in the template but are not pattern variables or the identifier ... are inserted into the output as literal identifiers. If a literal identifier is inserted as a free identifier then it refers to the binding of that identifier within whose scope the instance of syntax-rules appears. If a literal identifier is inserted as a bound identifier then it is in effect renamed to prevent inadvertent captures of free identifiers.

    (scheme r5rs) procedure (truncate (x real?) ) ⟹ integer?

    Truncate returns the integer closest to x whose absolute value is not larger than the absolute value of x. Note: If the argument to the procedure is inexact, then the result will also be inexact. If an exact value is needed, the result should be passed to the inexact->exact procedure.

    (scheme r5rs) syntax (unquote () ((_ expression)) )

    "Backquote" or "quasiquote" expressions are useful for constructing a list or vector structure when most but not all of the desired structure is known in advance. If no commas appear within the 〈qq template〉, the result of evaluating `〈qq template〉 is equivalent to the result of evaluating ’〈qq template〉. If a comma appears within the 〈qq template〉, however, the expression following the comma is evaluated ("unquoted") and its result is inserted into the structure instead of the comma and the expression. If a comma appears followed immediately by an at-sign (@), then the following expression must evaluate to a list; the opening and closing parentheses of the list are then “stripped away” and the elements of the list are inserted in place of the comma at-sign expression sequence. A comma at-sign should only appear within a list or vector 〈qq template〉.

    Quasiquote forms may be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost backquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation.

    The two notations `〈qq template〉 and (quasiquote 〈qq template〉) are identical in all respects. ,〈expression〉 is identical to (unquote 〈expression〉), and ,@〈expression〉 is identical to (unquote-splicing 〈expression〉). The external syntax generated by write for two-element lists whose car is one of these symbols may vary between implementations.

    Unpredictable behavior can result if any of the symbols quasiquote, unquote, or unquote-splicing appear in positions within a 〈qq template〉 otherwise than as described above.

    (scheme r5rs) syntax (unquote-splicing () ((_ expression)) )

    "Backquote" or "quasiquote" expressions are useful for constructing a list or vector structure when most but not all of the desired structure is known in advance. If no commas appear within the 〈qq template〉, the result of evaluating `〈qq template〉 is equivalent to the result of evaluating ’〈qq template〉. If a comma appears within the 〈qq template〉, however, the expression following the comma is evaluated ("unquoted") and its result is inserted into the structure instead of the comma and the expression. If a comma appears followed immediately by an at-sign (@), then the following expression must evaluate to a list; the opening and closing parentheses of the list are then “stripped away” and the elements of the list are inserted in place of the comma at-sign expression sequence. A comma at-sign should only appear within a list or vector 〈qq template〉.

    Quasiquote forms may be nested. Substitutions are made only for unquoted components appearing at the same nesting level as the outermost backquote. The nesting level increases by one inside each successive quasiquotation, and decreases by one inside each unquotation.

    The two notations `〈qq template〉 and (quasiquote 〈qq template〉) are identical in all respects. ,〈expression〉 is identical to (unquote 〈expression〉), and ,@〈expression〉 is identical to (unquote-splicing 〈expression〉). The external syntax generated by write for two-element lists whose car is one of these symbols may vary between implementations.

    Unpredictable behavior can result if any of the symbols quasiquote, unquote, or unquote-splicing appear in positions within a 〈qq template〉 otherwise than as described above.

    (scheme r5rs) procedure (values obj ... ) ⟹ (values *...)

    Delivers all of its arguments to its continuation. Except for continuations created by the call-with-values procedure, all continuations take exactly one value.

    (scheme r5rs) procedure (vector obj ... ) ⟹ vector?

    Returns a newly allocated vector whose elements contain the given arguments. Analogous to list.

    (scheme r5rs) procedure (vector->list (vector vector?) ) ⟹ list?

    Vector->list returns a newly allocated list of the objects contained in the elements of vector.

    (scheme r5rs) procedure (vector-fill! (vector vector?) fill ) ⟹ undefined

    Stores fill in every element of vector . The value returned by vector-fill! is unspecified.

    (scheme r5rs) procedure (vector-length (vector vector?) ) ⟹ integer?

    Returns the number of elements in vector as an exact integer.

    (scheme r5rs) procedure (vector-ref (vector vector?) (k integer?) ) ⟹ *

    k must be a valid index of vector . Vector-ref returns the contents of element k of vector .

    (scheme r5rs) procedure (vector-set! (vector vector?) (k integer?) obj ) ⟹ undefined

    k must be a valid index of vector . Vector-set! stores obj in element k of vector . The value returned by vector-set! is unspecified.

    (scheme r5rs) procedure (vector? obj ) ⟹ boolean?

    Returns #t if obj is a vector, otherwise returns #f.

    (scheme r5rs) procedure (write-char (char char?) ) ⟹ undefined

    (scheme r5rs) procedure (write-char (char char?) (port output-port?) ) ⟹ undefined

    Writes the character char (not an external representation of the character) to the given port and returns an unspecified value. The port argument may be omitted, in which case it defaults to the value returned by current-output-port.

    (scheme r5rs) procedure (char-ci<=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    The procedure is similar to char<=?, but treats upper case and lower case letters as the same.

    (scheme r5rs) procedure (char-ci<? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    The procedure is similar to char<?, but treats upper case and lower case letters as the same.

    (scheme r5rs) procedure (char-ci=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    The procedure is similar to char=?, but treats upper case and lower case letters as the same.

    (scheme r5rs) procedure (char-ci>=? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    The procedure is similar to char>=?, but treats upper case and lower case letters as the same.

    (scheme r5rs) procedure (char-ci>? (char1 char?) (char2 char?) (char3 char?) ... ) ⟹ boolean?

    The procedure is similar to char>?, but treats upper case and lower case letters as the same.

    (scheme r5rs) procedure (char-downcase (char char?) ) ⟹ char?

    The procedure returns a character char2 such that (char-ci=? char char2). In addition, if char is alphabetic, then the result of char-downcase is lower case.

    (scheme r5rs) procedure (char-upcase (char char?) ) ⟹ char?

    The procedure returns a character char2 such that (char-ci=? char char2). In addition, if char is alphabetic, then the result of char-upcase is upper case.

    (scheme r5rs) procedure (string-ci<=? (string1 string?) (string2 string?) ) ⟹ boolean?

    string-ci<=? is the lexicographic ordering on strings induced by the ordering char-ci<=? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. Implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicates.

    (scheme r5rs) procedure (string-ci<? (string1 string?) (string2 string?) ) ⟹ boolean?

    string-ci<? is the lexicographic ordering on strings induced by the ordering char-ci<? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. Implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicates.

    (scheme r5rs) procedure (string-ci=? (string1 string?) (string2 string?) ) ⟹ boolean?

    Returns #t if the two strings are the same length and contain the same characters in the same positions, otherwise returns #f. String-ci=? treats upper and lower case letters as though they were the same character.

    (scheme r5rs) procedure (string-ci>=? (string1 string?) (string2 string?) ) ⟹ boolean?

    string-ci>=? is the lexicographic ordering on strings induced by the ordering char-ci>=? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. Implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicates.

    (scheme r5rs) procedure (string-ci>? (string1 string?) (string2 string?) ) ⟹ boolean?

    string-ci>? is the lexicographic ordering on strings induced by the ordering char-ci>? on characters. If two strings differ in length but are the same up to the length of the shorter string, the shorter string is considered to be lexicographically less than the longer string. Implementations may generalize the procedure to take more than two arguments, as with the corresponding numerical predicates.

    (scheme r5rs) procedure (caaaar (pair pair?) ) ⟹ *

    Composition of car, car, car, car.

    (scheme r5rs) procedure (caaadr (pair pair?) ) ⟹ *

    Composition of car, car, car, cdr.

    (scheme r5rs) procedure (caaar (pair pair?) ) ⟹ *

    Composition of car, car, car.

    (scheme r5rs) procedure (caadar (pair pair?) ) ⟹ *

    Composition of car, car, cdr, car.

    (scheme r5rs) procedure (caaddr (pair pair?) ) ⟹ *

    Composition of car, car, cdr, cdr.

    (scheme r5rs) procedure (caadr (pair pair?) ) ⟹ *

    Composition of car, car, cdr.

    (scheme r5rs) procedure (cadaar (pair pair?) ) ⟹ *

    Composition of car, cdr, car, car.

    (scheme r5rs) procedure (cadadr (pair pair?) ) ⟹ *

    Composition of car, cdr, car, cdr.

    (scheme r5rs) procedure (cadar (pair pair?) ) ⟹ *

    Composition of car, cdr, car.

    (scheme r5rs) procedure (caddar (pair pair?) ) ⟹ *

    Composition of car, cdr, cdr, car.

    (scheme r5rs) procedure (cadddr (pair pair?) ) ⟹ *

    Composition of car, cdr, cdr, cdr.

    (scheme r5rs) procedure (caddr (pair pair?) ) ⟹ *

    Composition of car, cdr, cdr.

    (scheme r5rs) procedure (cdaaar (pair pair?) ) ⟹ *

    Composition of cdr, car, car, car.

    (scheme r5rs) procedure (cdaadr (pair pair?) ) ⟹ *

    Composition of cdr, car, car, cdr.

    (scheme r5rs) procedure (cdaar (pair pair?) ) ⟹ *

    Composition of cdr, car, car.

    (scheme r5rs) procedure (cdadar (pair pair?) ) ⟹ *

    Composition of cdr, car, cdr, car.

    (scheme r5rs) procedure (cdaddr (pair pair?) ) ⟹ *

    Composition of cdr, car, cdr, cdr.

    (scheme r5rs) procedure (cdadr (pair pair?) ) ⟹ *

    Composition of cdr, car, cdr.

    (scheme r5rs) procedure (cddaar (pair pair?) ) ⟹ *

    Composition of cdr, cdr, car, car.

    (scheme r5rs) procedure (cddadr (pair pair?) ) ⟹ *

    Composition of cdr, cdr, car, cdr.

    (scheme r5rs) procedure (cddar (pair pair?) ) ⟹ *

    Composition of cdr, cdr, car.

    (scheme r5rs) procedure (cdddar (pair pair?) ) ⟹ *

    Composition of cdr, cdr, cdr, car.

    (scheme r5rs) procedure (cddddr (pair pair?) ) ⟹ *

    Composition of cdr, cdr, cdr, cdr.

    (scheme r5rs) procedure (cdddr (pair pair?) ) ⟹ *

    Composition of cdr, cdr, cdr.

    (scheme r5rs) procedure (eval expr-or-def (environment-specifier environment) ) ⟹ *

    Evaluates expression in the specified environment and returns its value. Expression must be a valid Scheme expression represented as data, and environment-specifier must be a value returned by one of the three procedures described below. Implementations may extend eval to allow non-expression programs (definitions) as the first argument and to allow other values as environments, with the restriction that eval is not allowed to create new bindings in the environments associated with null-environment or scheme-report-environment.

    (scheme r5rs) procedure (scheme-report-environment (version integer?) ) ⟹ environment

    Version must be the exact integer 5, corresponding to this revision of the Scheme report (the Revised5 Report on Scheme). Scheme-report-environment returns a specifier for an environment that is empty except for all bindings defined in this report that are either required or both optional and supported by the implementation.

    Other values of version can be used to specify environments matching past revisions of this report, but their support is not required. An implementation will signal an error if version is neither 5 nor another value supported by the implementation.

    The effect of assigning (through the use of eval) a variable bound in a scheme-report-environment (for example car) is unspecified. Thus the environments specified by scheme-report-environment may be immutable.

    (scheme r5rs) procedure (null-environment (version integer?) ) ⟹ environment

    Version must be the exact integer 5, corresponding to this revision of the Scheme report (the Revised5 Report on Scheme).

    Null-environment returns a specifier for an environment that is empty except for the (syntactic) bindings for all syntactic keywords defined in this report that are either required or both optional and supported by the implementation.

    (scheme r5rs) procedure (sqrt (z number?) ) ⟹ number?

    Returns the principal square root of z. The result will have either positive real part, or zero real part and non-negative imaginary part.

    (scheme r5rs) procedure (call-with-input-file (string string?) (proc procedure?) ) ⟹ *

    (proc (port input-port?) ) ⟹ *

    String should be a string naming a file, and proc should be a procedure that accepts one argument. For call-with-input-file, the file should already exist. The procedure calls proc with one argument: the port obtained by opening the named file for input. If the file cannot be opened, an error is signalled. If proc returns, then the port is closed automatically and the value(s) yielded by the proc is(are) returned. If proc does not return, then the port will not be closed automatically unless it is possible to prove that the port will never again be used for a read or write operation.

    (scheme r5rs) procedure (call-with-output-file (string string?) (proc procedure?) ) ⟹ *

    (proc (port output-port?) ) ⟹ *

    String should be a string naming a file, and proc should be a procedure that accepts one argument. For call-with-output-file, the effect is unspecified if the file already exists. The procedure calls proc with one argument: the port obtained by opening the named file for output. If the file cannot be opened, an error is signalled. If proc returns, then the port is closed automatically and the value(s) yielded by the proc is(are) returned. If proc does not return, then the port will not be closed automatically unless it is possible to prove that the port will never again be used for a read or write operation.

    (scheme r5rs) procedure (open-input-file (string string?) ) ⟹ input-port?

    Takes a string naming an existing file and returns an input port capable of delivering characters from the file. If the file cannot be opened, an error is signalled.

    (scheme r5rs) procedure (open-output-file (string string?) ) ⟹ output-port?

    Takes a string naming an output file to be created and returns an output port capable of writing characters to a new file by that name. If the file cannot be opened, an error is signalled. If a file with the given name already exists, the effect is unspecified.

    (scheme r5rs) procedure (with-input-from-file (string string?) (thunk procedure?) ) ⟹ *

    (thunk ) ⟹ *

    String should be a string naming a file, and proc should be a procedure that accepts one argument. For call-with-input-file, the file should already exist. The file is opened for input, an input port connected to it is made the default value returned by current-input-port, and the thunk is called with no arguments. When the thunk returns, the port is closed and the previous default is restored. With-input-from-file returns the value(s) yielded by thunk . If an escape procedure is used to escape from the continuation of the procedure, its behavior is implementation dependent.

    (scheme r5rs) procedure (with-output-to-file (string string?) (thunk procedure?) ) ⟹ *

    (thunk ) ⟹ *

    String should be a string naming a file, and proc should be a procedure that accepts one argument. For call-with-output-file, the effect is unspecified if the file already exists. The file is opened for output, an output port connected to it is made the default value returned by current-output-port, and the thunk is called with no arguments. When the thunk returns, the port is closed and the previous default is restored. With-output-from-file returns the value(s) yielded by thunk . If an escape procedure is used to escape from the continuation of the procedure, its behavior is implementation dependent.

    (scheme r5rs) syntax (delay () ((_ expression) promise?) )

    The delay construct is used together with the procedure force to implement lazy evaluation or call by need. (delay 〈expression〉) returns an object called a promise which at some point in the future may be asked (by the force procedure) to evaluate 〈expression〉, and deliver the resulting value. The effect of 〈expression〉 returning multiple values is unspecified.

    (scheme r5rs) procedure (force (promise promise?) ) ⟹ *

    Forces the value of promise (see delay, section 4.2.5). If no value has been computed for the promise, then a value is computed and returned. The value of the promise is cached (or “memoized”) so that if it is forced a second time, the previously computed value is returned.

    (scheme r5rs) procedure (load (filename string?) ) ⟹ undefined

    Filename should be a string naming an existing file containing Scheme source code. The load procedure reads expressions and definitions from the file and evaluates them sequentially. It is unspecified whether the results of the expressions are printed. The load procedure does not affect the values returned by current-input-port and current-output-port. Load returns an unspecified value.

    Rationale: For portability, load must operate on source files. Its operation on other kinds of files necessarily varies among implementations.

    (scheme r5rs) procedure (read ) ⟹ *

    (scheme r5rs) procedure (read (port input-port?) ) ⟹ *

    Read converts external representations of Scheme objects into the objects themselves. That is, it is a parser for the nonterminal <datum> (see sections 7.1.2 and 6.3.2). Read returns the next object parsable from the given input port, updating port to point to the first character past the end of the external representation of the object.

    If an end of file is encountered in the input before any characters are found that can begin an object, then an end of file object is returned. The port remains open, and further attempts to read will also return an end of file object. If an end of file is encountered after the beginning of an object’s external representation, but the external representation is incomplete and therefore not parsable, an error is signalled.

    The port argument may be omitted, in which case it defaults to the value returned by current-input-port. It is an error to read from a closed port.

    (scheme r5rs) procedure (transcript-on (filename string?) ) ⟹ undefined

    Filename must be a string naming an output file to be created. The effect of transcript-on is to open the named file for output, and to cause a transcript of subsequent interaction between the user and the Scheme system to be written to the file. The transcript is ended by a call to transcript-off, which closes the transcript file. Only one transcript may be in progress at any time, though some implementations may relax this restriction. The values returned by these procedures are unspecified.

    (scheme r5rs) procedure (transcript-off ) ⟹ undefined

    Ends transcript and closes transcript file. See transcript-on.

    (scheme r5rs) procedure (display obj ) ⟹ undefined

    (scheme r5rs) procedure (display obj (port output-port?) ) ⟹ undefined

    Writes a representation of obj to the given port. Strings that appear in the written representation are not enclosed in doublequotes, and no characters are escaped within those strings. Character objects appear in the representation as if written by write-char instead of by write. Display returns an unspecified value. The port argument may be omitted, in which case it defaults to the value returned by current-output-port.

    Rationale: Write is intended for producing machine-readable output and display is for producing human-readable output. Implementations that allow “slashification” within symbols will probably want write but not display to slashify funny characters in symbols.

    (scheme r5rs) procedure (write obj ) ⟹ undefined

    (scheme r5rs) procedure (write obj (port output-port?) ) ⟹ undefined

    Writes a written representation of obj to the given port. Strings that appear in the written representation are enclosed in doublequotes, and within those strings backslash and doublequote characters are escaped by backslashes. Character objects are written using the #\ notation. Write returns an unspecified value. The port argument may be omitted, in which case it defaults to the value returned by current-output-port.

    (scheme r5rs) procedure (even? (n integer?) ) ⟹ boolean?

    (scheme r5rs) procedure (odd? (n integer?) ) ⟹ boolean?

    (scheme r5rs) procedure (zero? (z number?) ) ⟹ boolean?

    (scheme r5rs) procedure (positive? (x real?) ) ⟹ boolean?

    (scheme r5rs) procedure (negative? (x real?) ) ⟹ boolean?

    These numerical predicates test a number for a particular property, returning #t or #f.

    (scheme r5rs) procedure (acos (z number?) ) ⟹ number?

    (scheme r5rs) procedure (asin (z number?) ) ⟹ number?

    (scheme r5rs) procedure (atan (z number?) ) ⟹ number?

    (scheme r5rs) procedure (atan (y real?) (x real?) ) ⟹ number?

    (scheme r5rs) procedure (cos (z number?) ) ⟹ number?

    (scheme r5rs) procedure (exp (z number?) ) ⟹ number?

    (scheme r5rs) procedure (log (z number?) ) ⟹ number?

    (scheme r5rs) procedure (sin (z number?) ) ⟹ number?

    (scheme r5rs) procedure (tan (z number?) ) ⟹ number?

    These procedures compute the usual transcendental functions. The log procedure computes the natural logarithm of z (not the base ten logarithm) if a single argument is given, or the base-z2 logarithm of z1 if two arguments are given. The asin, acos, and atan procedures compute arcsine (sin−1), arc-cosine (cos−1), and arctangent (tan−1), respectively. The two-argument variant of atan computes (angle (make-rectangular x y)) (see below), even in implementations that don’t support complex numbers.

    In general, the mathematical functions log, arcsine, arccosine, and arctangent are multiply defined. The value of log z is defined to be the one whose imaginary part lies in the range from −π (inclusive if -0.0 is distinguished, exclusive otherwise) to π (inclusive). The value of log 0 is mathematically undefined. With log defined this way, the values of sin−1 z, cos−1 z, and tan−1 z are according to the following formulæ:

    sin^-1 z = -i log(iz + (1 - z^2)^0.5)

    cos^-1 z = pi/2 - sin^-1 z

    tan^-1 z = (log(1 + iz) - log(1 - iz)) / (2i)

    (scheme r5rs) procedure (number? obj ) ⟹ boolean?

    (scheme r5rs) procedure (complex? obj ) ⟹ boolean?

    (scheme r5rs) procedure (real? obj ) ⟹ boolean?

    (scheme r5rs) procedure (rational? obj ) ⟹ boolean?

    (scheme r5rs) procedure (integer? obj ) ⟹ boolean?

    These numerical type predicates can be applied to any kind of argument, including non-numbers. They return #t if the object is of the named type, and otherwise they return #f. In general, if a type predicate is true of a number then all higher type predicates are also true of that number. Consequently, if a type predicate is false of a number, then all lower type predicates are also false of that number. If z is an inexact complex number, then (real? z) is true if and only if (zero? (imag-part z)) is true. If x is an inexact real number, then (integer? x) is true if and only if (= x (round x)).

    (scheme r5rs) procedure (angle (z complex?) ) ⟹ real?

    (scheme r5rs) procedure (imag-part (z complex?) ) ⟹ real?

    (scheme r5rs) procedure (magnitude (z complex?) ) ⟹ real?

    (scheme r5rs) procedure (make-polar (x3 real?) (x4 real?) ) ⟹ complex?

    (scheme r5rs) procedure (make-rectangular (x1 real?) (x2 real?) ) ⟹ complex?

    (scheme r5rs) procedure (real-part (z complex?) ) ⟹ real?

    Let x1, x2, x3, and x4 be real numbers and z be a complex number such that

    z = x1 + x2i = x3 * e^(i*x4)

    Then all of

    (make-rectangular x1 x2) => z

    (make-polar x3 x4) => z

    (real-part z) => x1

    (imag-part z) => x2

    (magnitude z) => |x3|

    (angle z) =⇒ x_angle

    are true, where -pi <= x_angle <= pi with x_angle = x4 + 2*pi*n for some integer n.

    The make-polar procedure may return an inexact complex number even if its arguments are exact. The real-part and imag-part procedures may return exact real numbers when applied to an inexact complex number if the corresponding argument passed to make-rectangular was exact.

    (scheme r5rs) procedure (char-alphabetic? (char char?) ) ⟹ boolean?

    (scheme r5rs) procedure (char-numeric? (char char?) ) ⟹ boolean?

    (scheme r5rs) procedure (char-whitespace? (char char?) ) ⟹ boolean?

    (scheme r5rs) procedure (char-upper-case? (char char?) ) ⟹ boolean?

    (scheme r5rs) procedure (char-lower-case? (char char?) ) ⟹ boolean?

    These procedures return #t if their arguments are alphabetic, numeric, whitespace, upper case, or lower case characters, respectively, otherwise they return #f. The following remarks, which are specific to the ASCII character set, are intended only as a guide: The alphabetic characters are the 52 upper and lower case letters. The numeric characters are the ten decimal digits. The whitespace characters are space, tab, line feed, form feed, and carriage return.