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:
- Search across all entries: just use browser search.
- Selection by predicates / types: might add, but don’t consider essential.
- Purity and predicate-ness of procedures: mostly unnecessary, as procedure names tell that already.
- Slide out sidebar: distracting JS-only antipattern. A single view is much more predictable and useable.
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-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:
or vice versa.
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:
or vice versa.
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:
or vice versa.
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:
or vice versa.
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:
or vice versa.
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:
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:
The eqv? procedure returns #f if:
(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:
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:
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.
library (scheme box)
(scheme box) procedure (box value ) ⟹ box?
Constructor. Returns a newly allocated box initialized to value.
(scheme box) procedure (box? object ) ⟹ boolean?
Predicate. Returns #t if object is a box, and #f otherwise.
(scheme box) procedure (unbox (box box?) ) ⟹ *
Accessor. Returns the current value of box.
(scheme box) procedure (set-box! (box box?) value ) ⟹ undefined
Mutator. Changes box to hold value.
library (scheme comparator)
(scheme comparator) procedure (comparator? obj ) ⟹ boolean?
Returns #t if obj is a comparator, and #f otherwise.
(scheme comparator) procedure (comparator-ordered? (comparator comparator?) ) ⟹ boolean?
Returns #t if comparator has a supplied ordering predicate, and #f otherwise.
(scheme comparator) procedure (comparator-hashable? (comparator comparator?) ) ⟹ boolean?
Returns #t if comparator has a supplied hash function, and #f otherwise.
(scheme comparator) procedure (make-comparator (type-test procedure?) (equality procedure?) (ordering (or procedure?#f)) (hash (or procedure?#f)) ) ⟹ comparator?
(type-test obj ) ⟹ boolean?
(equality obj1 obj2 ) ⟹ boolean?
(ordering obj1 obj2 ) ⟹ boolean?
(hash obj ) ⟹ integer?
Returns a comparator which bundles the type-test, equality, ordering, and hash procedures provided. However, if ordering or hash is #f, a procedure is provided that signals an error on application. The predicates comparator-ordered? and/or comparator-hashable?, respectively, will return #f in these cases.
(scheme comparator) procedure (make-pair-comparator (car-comparator comparator?) (cdr-comparator comparator?) ) ⟹ comparator?
This procedure returns comparators whose functions behave as follows.
1 The type test returns #t if its argument is a pair, if the car satisfies the type test predicate of car-comparator, and the cdr satisfies the type test predicate of cdr-comparator.
2 The equality function returns #t if the cars are equal according to car-comparator and the cdrs are equal according to cdr-comparator, and #f otherwise.
3 The ordering function first compares the cars of its pairs using the equality predicate of car-comparator. If they are not equal, then the ordering predicate of car-comparator is applied to the cars and its value is returned. Otherwise, the predicate compares the cdrs using the equality predicate of cdr-comparator. If they are not equal, then the ordering predicate of cdr-comparator is applied to the cdrs and its value is returned.
4 The hash function computes the hash values of the car and the cdr using the hash functions of car-comparator and cdr-comparator respectively and then hashes them together in an implementation-defined way.
(scheme comparator) procedure (make-list-comparator (element-comparator comparator?) (type-test procedure?) (empty? procedure?) (head procedure?) (tail procedure?) ) ⟹ comparator?
(type-test obj ) ⟹ boolean?
(empty? obj ) ⟹ boolean?
(head obj ) ⟹ *
(tail obj ) ⟹ *
This procedure returns comparators whose functions behave as follows:
1 The type test returns #t if its argument satisfies type-test and the elements satisfy the type test predicate of element-comparator.
2 The total order defined by the equality and ordering functions is as follows (known as lexicographic order):
2.1 The empty sequence, as determined by calling empty?, compares equal to itself.
2.2 The empty sequence compares less than any non-empty sequence.
2.3 Two non-empty sequences are compared by calling the head procedure on each. If the heads are not equal when compared using element-comparator, the result is the result of that comparison. Otherwise, the results of calling the tail procedure are compared recursively.
3 The hash function computes the hash values of the elements using the hash function of element-comparator and then hashes them together in an implementation-defined way.
(scheme comparator) procedure (make-vector-comparator (element-comparator comparator?) (type-test procedure?) (length procedure?) (ref procedure?) ) ⟹ comparator?
(type-test obj ) ⟹ boolean?
(length obj ) ⟹ integer?
(ref vec (index integer?) ) ⟹ *
This procedure returns comparators whose functions behave as follows:
1 The type test returns #t if its argument satisfies type-test and the elements satisfy the type test predicate of element-comparator.
2 The equality predicate returns #t if both of the following tests are satisfied in order: the lengths of the vectors are the same in the sense of =, and the elements of the vectors are the same in the sense of the equality predicate of element-comparator.
3 The ordering predicate returns #t if the results of applying length to the first vector is less than the result of applying length to the second vector. If the lengths are equal, then the elements are examined pairwise using the ordering predicate of element-comparator. If any pair of elements returns #t, then that is the result of the list comparator's ordering predicate; otherwise the result is #f
4 The hash function computes the hash values of the elements using the hash function of element-comparator and then hashes them together in an implementation-defined way.
(scheme comparator) procedure (make-eq-comparator ) ⟹ comparator?
make-eq-comparator, make-eqv-comparator, make-equal-comparator These procedures return comparators whose functions behave as follows:
1 The type test returns #t in all cases.
2 The equality functions are eq?, eqv?, and equal? respectively.
3 The ordering function is implementation-defined, except that it must conform to the rules for ordering functions. It may signal an error instead.
4 The hash function is default-hash.
(scheme comparator) procedure (make-eqv-comparator ) ⟹ comparator?
make-eq-comparator, make-eqv-comparator, make-equal-comparator These procedures return comparators whose functions behave as follows:
1 The type test returns #t in all cases.
2 The equality functions are eq?, eqv?, and equal? respectively.
3 The ordering function is implementation-defined, except that it must conform to the rules for ordering functions. It may signal an error instead.
4 The hash function is default-hash.
(scheme comparator) procedure (make-equal-comparator ) ⟹ comparator?
make-eq-comparator, make-eqv-comparator, make-equal-comparator These procedures return comparators whose functions behave as follows:
1 The type test returns #t in all cases.
2 The equality functions are eq?, eqv?, and equal? respectively.
3 The ordering function is implementation-defined, except that it must conform to the rules for ordering functions. It may signal an error instead.
4 The hash function is default-hash.
(scheme comparator) procedure (boolean-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(scheme comparator) procedure (char-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(scheme comparator) procedure (char-ci-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(scheme comparator) procedure (string-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(scheme comparator) procedure (string-ci-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(scheme comparator) procedure (symbol-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(scheme comparator) procedure (number-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(scheme comparator) syntax (hash-bound () ((_) integer? ) )
Hash functions should be written so as to return a number between 0 and the largest reasonable number of elements (such as hash buckets) a data structure in the implementation might have. What that value is depends on the implementation. This value provides the current bound as a positive exact integer, typically for use by user-written hash functions. However, they are not required to bound their results in this way.
(scheme comparator) syntax (hash-salt () ((_) integer? ) )
A salt is random data in the form of a non-negative exact integer used as an additional input to a hash function in order to defend against dictionary attacks, or (when used in hash tables) against denial-of-service attacks that overcrowd certain hash buckets, increasing the amortized O(1) lookup time to O(n). Salt can also be used to specify which of a family of hash functions should be used for purposes such as cuckoo hashing. This macro provides the current value of the salt, typically for use by user-written hash functions. However, they are not required to make use of the current salt.
The initial value is implementation-dependent, but must be less than the value of (hash-bound), and should be distinct for distinct runs of a program unless otherwise specified by the implementation. Implementations may provide a means to specify the salt value to be used by a particular invocation of a hash function.
(scheme comparator) procedure (make-default-comparator ) ⟹ comparator?
Returns a comparator known as a default comparator that accepts Scheme values and orders them in some implementation-defined way, subject to the following conditions:
1 Given disjoint types a and b, one of three conditions must hold:
1.1 All objects of type a compare less than all objects of type b.
1.2 All objects of type a compare greater than all objects of type b.
1.3 All objects of both type a and type b compare equal to each other. This is not permitted for any of the Scheme types mentioned below.
2 The empty list must be ordered before all pairs.
3 When comparing booleans, it must use the total order #f < #t.
4 When comparing characters, it must use char=? and char<?. Note: In R5RS, this is an implementation-dependent order that is typically the same as Unicode codepoint order; in R6RS and R7RS, it is Unicode codepoint order.
5 When comparing pairs, it must behave the same as a comparator returned by make-pair-comparator with default comparators as arguments.
6 When comparing symbols, it must use an implementation-dependent total order. One possibility is to use the order obtained by applying symbol->string to the symbols and comparing them using the total order implied by string<?.
7 When comparing bytevectors, it must behave the same as a comparator created by the expression (make-vector-comparator (make-comparator bytevector? = < number-hash) bytevector? bytevector-length bytevector-u8-ref).
8 When comparing numbers where either number is complex, since non-real numbers cannot be compared with <, the following least-surprising ordering is defined: If the real parts are < or >, so are the numbers; otherwise, the numbers are ordered by their imaginary parts. This can still produce somewhat surprising results if one real part is exact and the other is inexact.
9 When comparing real numbers, it must use = and <.
10 When comparing strings, it must use string=? and string<?. Note: In R5RS, this is lexicographic order on the implementation-dependent order defined by char<?; in R6RS it is lexicographic order on Unicode codepoint order; in R7RS it is an implementation-defined order.
11 When comparing vectors, it must behave the same as a comparator returned by (make-vector-comparator (make-default-comparator) vector? vector-length vector-ref).
12 When comparing members of types registered with comparator-register-default!, it must behave in the same way as the comparator registered using that function.
Default comparators use default-hash as their hash function.
(scheme comparator) procedure (default-hash obj ) ⟹ integer?
This is the hash function used by default comparators, which accepts a Scheme value and hashes it in some implementation-defined way, subject to the following conditions:
1 When applied to a pair, it must return the result of hashing together the values returned by default-hash when applied to the car and the cdr.
2 When applied to a boolean, character, string, symbol, or number, it must return the same result as boolean-hash, char-hash, string-hash, symbol-hash, or number-hash respectively.
3 When applied to a list or vector, it must return the result of hashing together the values returned by default-hash when applied to each of the elements.
(scheme comparator) procedure (comparator-register-default! (comparator comparator?) ) ⟹ undefined
Registers comparator for use by default comparators, such that if the objects being compared both satisfy the type test predicate of comparator, it will be employed by default comparators to compare them. Returns an unspecified value. It is an error if any value satisfies both the type test predicate of comparator and any of the following type test predicates: boolean?, char?, null?, pair?, symbol?, bytevector?, number?, string?, vector?, or the type test predicate of a comparator that has already been registered.
This procedure is intended only to extend default comparators into territory that would otherwise be undefined, not to override their existing behavior. In general, the ordering of calls to comparator-register-default! should be irrelevant. However, implementations that support inheritance of record types may wish to ensure that default comparators always check subtypes before supertypes.
This SRFI recommends (but does not require) that libraries which expose comparators do not register them with this procedure, because the default comparator (which is meant mostly for ad hoc programming) is meant to be under the control of the program author rather than the library author. It is the program author's responsibility to ensure that the registered comparators do not conflict with each other.
(scheme comparator) procedure (comparator-type-test-predicate (comparator comparator?) ) ⟹ procedure?
(return obj ) ⟹ boolean?
(scheme comparator) procedure (comparator-equality-predicate (comparator comparator?) ) ⟹ procedure?
(return obj1 obj2 ) ⟹ boolean?
(scheme comparator) procedure (comparator-ordering-predicate (comparator comparator?) ) ⟹ #f / procedure? /
(return obj1 obj2 ) ⟹ boolean?
(scheme comparator) procedure (comparator-hash-function (comparator comparator?) ) ⟹ #f / procedure? /
(return obj ) ⟹ integer?
Return the four procedures of comparator.
(scheme comparator) procedure (comparator-test-type (comparator comparator?) obj ) ⟹ boolean?
Invokes the type test predicate of comparator on obj and returns what it returns. More convenient than comparator-type-test-predicate, but less efficient when the predicate is called repeatedly.
(scheme comparator) procedure (comparator-check-type (comparator comparator?) obj ) ⟹ boolean?
Invokes the type test predicate of comparator on obj and returns true if it returns true, but signals an error otherwise. More convenient than comparator-type-test-predicate, but less efficient when the predicate is called repeatedly.
(scheme comparator) procedure (comparator-hash (comparator comparator?) obj ) ⟹ integer?
Invokes the hash function of comparator on obj and returns what it returns. More convenient than comparator-hash-function, but less efficient when the function is called repeatedly. Note: No invokers are required for the equality and ordering predicates, because =? and <? serve this function.
(scheme comparator) procedure (=? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(scheme comparator) procedure (<? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(scheme comparator) procedure (>? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(scheme comparator) procedure (<=? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(scheme comparator) procedure (>=? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(scheme comparator) syntax (comparator-if<=> () ((_ comparator object1 object2 less-than equal-to greater-than)) ((_ object1 object2 less-than equal-to greater-than)) )
comparator ⟹ comparator?
It is an error unless <comparator> evaluates to a comparator and <object1> and <object2> evaluate to objects that the comparator can handle. If the ordering predicate returns true when applied to the values of <object1> and <object2> in that order, then <less-than> is evaluated and its value returned. If the equality predicate returns true when applied in the same way, then <equal-to> is evaluated and its value returned. If neither returns true, <greater-than> is evaluated and its value returned.
If <comparator> is omitted, a default comparator is used.
library (scheme charset)
(scheme charset) procedure (char-set? obj ) ⟹ boolean?
Is the object obj a character set?
(scheme charset) procedure (char-set= (cs1 char-set?) ... ) ⟹ boolean?
Are the character sets equal?
Boundary cases:
(char-set=) => true
(char-set= cs) => true
Rationale: transitive binary relations are generally extended to n-ary relations in Scheme, which enables clearer, more concise code to be written. While the zero-argument and one-argument cases will almost certainly not arise in first-order uses of such relations, they may well arise in higher-order cases or macro-generated code. E.g., consider
(apply char-set= cset-list)
This is well-defined if the list is empty or a singleton list. Hence we extend these relations to any number of arguments. Implementors have reported actual uses of n-ary relations in higher-order cases allowing for fewer than two arguments. The way of Scheme is to handle the general case; we provide the fully general extension.
A counter-argument to this extension is that R5RS's transitive binary arithmetic relations (=, <, etc.) require at least two arguments, hence this decision is a break with the prior convention -- although it is at least one that is backwards-compatible.
(scheme charset) procedure (char-set<= (cs1 char-set?) ... ) ⟹ boolean?
Returns true if every character set csi is a subset of character set csi+1.
Boundary cases:
(char-set<=) => true
(char-set<= cs) => true
Rationale: See char-set= for discussion of zero- and one-argument applications. Consider testing a list of char-sets for monotonicity with
(apply char-set<= cset-list)
(scheme charset) procedure (char-set-hash (cs char-set?) ) ⟹ integer?
(scheme charset) procedure (char-set-hash (cs char-set?) (bound integer?) ) ⟹ integer?
Compute a hash value for the character set cs. Bound is a non-negative exact integer specifying the range of the hash function. A positive value restricts the return value to the range [0,bound).
If bound is either zero or not given, the implementation may use an implementation-specific default value, chosen to be as large as is efficiently practical. For instance, the default range might be chosen for a given implementation to map all strings into the range of integers that can be represented with a single machine word.
Invariant:
(char-set= cs1 cs2) => (= (char-set-hash cs1 b) (char-set-hash cs2 b))
A legal but nonetheless discouraged implementation:
(define (char-set-hash cs . maybe-bound) 1)
Rationale: allowing the user to specify an explicit bound simplifies user code by removing the mod operation that typically accompanies every hash computation, and also may allow the implementation of the hash function to exploit a reduced range to efficiently compute the hash value. E.g., for small bounds, the hash function may be computed in a fashion such that intermediate values never overflow into bignum integers, allowing the implementor to provide a fixnum-specific "fast path" for computing the common cases very rapidly.
(scheme charset) procedure (char-set-cursor (cset char-set?) ) ⟹ *
(shared description for char-set-cursor, char-set-ref, char-set-cursor-next, end-of-char-set?)
Cursors are a low-level facility for iterating over the characters in a set. A cursor is a value that indexes a character in a char set. char-set-cursor produces a new cursor for a given char set. The set element indexed by the cursor is fetched with char-set-ref. A cursor index is incremented with char-set-cursor-next; in this way, code can step through every character in a char set. Stepping a cursor "past the end" of a char set produces a cursor that answers true to end-of-char-set?. It is an error to pass such a cursor to char-set-ref or to char-set-cursor-next.
A cursor value may not be used in conjunction with a different character set; if it is passed to char-set-ref or char-set-cursor-next with a character set other than the one used to create it, the results and effects are undefined.
Cursor values are not necessarily distinct from other types. They may be integers, linked lists, records, procedures or other values. This license is granted to allow cursors to be very "lightweight" values suitable for tight iteration, even in fairly simple implementations.
Note that these primitives are necessary to export an iteration facility for char sets to loop macros.
Rationale: Note that the cursor API's four functions "fit" the functional protocol used by the unfolders provided by the list, string and char-set SRFIs (see the example above). By way of contrast, here is a simpler, two-function API that was rejected for failing this criterion. Besides char-set-cursor, it provided a single function that mapped a cursor and a character set to two values, the indexed character and the next cursor. If the cursor had exhausted the character set, then this function returned false instead of the character value, and another end-of-char-set cursor. In this way, the other three functions of the current API were combined together.
(scheme charset) procedure (char-set-ref (cset char-set?) cursor ) ⟹ char?
(shared description for char-set-cursor, char-set-ref, char-set-cursor-next, end-of-char-set?)
Cursors are a low-level facility for iterating over the characters in a set. A cursor is a value that indexes a character in a char set. char-set-cursor produces a new cursor for a given char set. The set element indexed by the cursor is fetched with char-set-ref. A cursor index is incremented with char-set-cursor-next; in this way, code can step through every character in a char set. Stepping a cursor "past the end" of a char set produces a cursor that answers true to end-of-char-set?. It is an error to pass such a cursor to char-set-ref or to char-set-cursor-next.
A cursor value may not be used in conjunction with a different character set; if it is passed to char-set-ref or char-set-cursor-next with a character set other than the one used to create it, the results and effects are undefined.
Cursor values are not necessarily distinct from other types. They may be integers, linked lists, records, procedures or other values. This license is granted to allow cursors to be very "lightweight" values suitable for tight iteration, even in fairly simple implementations.
Note that these primitives are necessary to export an iteration facility for char sets to loop macros.
Rationale: Note that the cursor API's four functions "fit" the functional protocol used by the unfolders provided by the list, string and char-set SRFIs (see the example above). By way of contrast, here is a simpler, two-function API that was rejected for failing this criterion. Besides char-set-cursor, it provided a single function that mapped a cursor and a character set to two values, the indexed character and the next cursor. If the cursor had exhausted the character set, then this function returned false instead of the character value, and another end-of-char-set cursor. In this way, the other three functions of the current API were combined together.
(scheme charset) procedure (char-set-cursor-next (cset char-set?) cursor ) ⟹ *
(shared description for char-set-cursor, char-set-ref, char-set-cursor-next, end-of-char-set?)
Cursors are a low-level facility for iterating over the characters in a set. A cursor is a value that indexes a character in a char set. char-set-cursor produces a new cursor for a given char set. The set element indexed by the cursor is fetched with char-set-ref. A cursor index is incremented with char-set-cursor-next; in this way, code can step through every character in a char set. Stepping a cursor "past the end" of a char set produces a cursor that answers true to end-of-char-set?. It is an error to pass such a cursor to char-set-ref or to char-set-cursor-next.
A cursor value may not be used in conjunction with a different character set; if it is passed to char-set-ref or char-set-cursor-next with a character set other than the one used to create it, the results and effects are undefined.
Cursor values are not necessarily distinct from other types. They may be integers, linked lists, records, procedures or other values. This license is granted to allow cursors to be very "lightweight" values suitable for tight iteration, even in fairly simple implementations.
Note that these primitives are necessary to export an iteration facility for char sets to loop macros.
Rationale: Note that the cursor API's four functions "fit" the functional protocol used by the unfolders provided by the list, string and char-set SRFIs (see the example above). By way of contrast, here is a simpler, two-function API that was rejected for failing this criterion. Besides char-set-cursor, it provided a single function that mapped a cursor and a character set to two values, the indexed character and the next cursor. If the cursor had exhausted the character set, then this function returned false instead of the character value, and another end-of-char-set cursor. In this way, the other three functions of the current API were combined together.
(scheme charset) procedure (end-of-char-set? cursor ) ⟹ boolean?
(shared description for char-set-cursor, char-set-ref, char-set-cursor-next, end-of-char-set?)
Cursors are a low-level facility for iterating over the characters in a set. A cursor is a value that indexes a character in a char set. char-set-cursor produces a new cursor for a given char set. The set element indexed by the cursor is fetched with char-set-ref. A cursor index is incremented with char-set-cursor-next; in this way, code can step through every character in a char set. Stepping a cursor "past the end" of a char set produces a cursor that answers true to end-of-char-set?. It is an error to pass such a cursor to char-set-ref or to char-set-cursor-next.
A cursor value may not be used in conjunction with a different character set; if it is passed to char-set-ref or char-set-cursor-next with a character set other than the one used to create it, the results and effects are undefined.
Cursor values are not necessarily distinct from other types. They may be integers, linked lists, records, procedures or other values. This license is granted to allow cursors to be very "lightweight" values suitable for tight iteration, even in fairly simple implementations.
Note that these primitives are necessary to export an iteration facility for char sets to loop macros.
Rationale: Note that the cursor API's four functions "fit" the functional protocol used by the unfolders provided by the list, string and char-set SRFIs (see the example above). By way of contrast, here is a simpler, two-function API that was rejected for failing this criterion. Besides char-set-cursor, it provided a single function that mapped a cursor and a character set to two values, the indexed character and the next cursor. If the cursor had exhausted the character set, then this function returned false instead of the character value, and another end-of-char-set cursor. In this way, the other three functions of the current API were combined together.
(scheme charset) procedure (char-set-fold (kons procedure?) knil (cs char-set?) ) ⟹ *
(kons (c char?) state ) ⟹ *
This is the fundamental iterator for character sets. Applies the function kons across the character set cs using initial state value knil. That is, if cs is the empty set, the procedure returns knil. Otherwise, some element c of cs is chosen; let cs' be the remaining, unchosen characters. The procedure returns
(char-set-fold kons (kons c knil) cs')
(scheme charset) procedure (char-set-unfold (f procedure?) (p procedure?) (g procedure?) seed ) ⟹ char-set?
(scheme charset) procedure (char-set-unfold (f procedure?) (p procedure?) (g procedure?) seed (base-cs char-set?) ) ⟹ char-set?
(f seed ) ⟹ char?
(p seed ) ⟹ boolean?
(g seed ) ⟹ *
(shared description for char-set-unfold, char-set-unfold!) This is a fundamental constructor for char-sets.
(scheme charset) procedure (char-set-unfold! (f procedure?) (p procedure?) (g procedure?) seed (base-cs char-set?) ) ⟹ char-set?
(f seed ) ⟹ char?
(p seed ) ⟹ boolean?
(g seed ) ⟹ *
(shared description for char-set-unfold, char-set-unfold!) This is a fundamental constructor for char-sets.
(scheme charset) procedure (char-set-for-each (proc procedure?) (cs char-set?) ) ⟹ undefined
(proc (c char?) ) ⟹ undefined
Apply procedure proc to each character in the character set cs. Note that the order in which proc is applied to the characters in the set is not specified, and may even change from one procedure application to another.
Nothing at all is specified about the value returned by this procedure; it is not even required to be consistent from call to call. It is simply required to be a value (or values) that may be passed to a command continuation, e.g. as the value of an expression appearing as a non-terminal subform of a begin expression. Note that in R5RS, this restricts the procedure to returning a single value; non-R5RS systems may not even provide this restriction.
(scheme charset) procedure (char-set-map (proc procedure?) (cs char-set?) ) ⟹ char-set?
(proc (c char?) ) ⟹ char?
proc is a char->char procedure. Apply it to all the characters in the char-set cs, and collect the results into a new character set.
Essentially lifts proc from a char->char procedure to a char-set -> char-set procedure.
(scheme charset) procedure (char-set-copy (cs char-set?) ) ⟹ char-set?
Returns a copy of the character set cs. "Copy" means that if either the input parameter or the result value of this procedure is passed to one of the linear-update procedures described below, the other character set is guaranteed not to be altered.
A system that provides pure-functional implementations of the linear-operator suite could implement this procedure as the identity function -- so copies are not guaranteed to be distinct by eq?.
(scheme charset) procedure (char-set (char1 char?) ... ) ⟹ char-set?
Return a character set containing the given characters.
(scheme charset) procedure (list->char-set (char-list list?) ) ⟹ char-set?
(scheme charset) procedure (list->char-set (char-list list?) (base-cs char-set?) ) ⟹ char-set?
(shared description for list->char-set, list->char-set!) Return a character set containing the characters in the list of characters char-list.
If character set base-cs is provided, the characters from char-list are added to it. list->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; list->char-set produces a fresh character set.
(scheme charset) procedure (list->char-set! (char-list list?) (base-cs char-set?) ) ⟹ char-set?
(shared description for list->char-set, list->char-set!) Return a character set containing the characters in the list of characters char-list.
If character set base-cs is provided, the characters from char-list are added to it. list->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; list->char-set produces a fresh character set.
(scheme charset) procedure (string->char-set (s string?) ) ⟹ char-set?
(scheme charset) procedure (string->char-set (s string?) (base-cs char-set?) ) ⟹ char-set?
(shared description for string->char-set, string->char-set!) Return a character set containing the characters in the string s.
If character set base-cs is provided, the characters from s are added to it. string->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; string->char-set produces a fresh character set.
(scheme charset) procedure (string->char-set! (s string?) (base-cs char-set?) ) ⟹ char-set?
(shared description for string->char-set, string->char-set!) Return a character set containing the characters in the string s.
If character set base-cs is provided, the characters from s are added to it. string->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; string->char-set produces a fresh character set.
(scheme charset) procedure (char-set-filter (pred procedure?) (cs char-set?) ) ⟹ char-set?
(scheme charset) procedure (char-set-filter (pred procedure?) (cs char-set?) (base-cs char-set?) ) ⟹ char-set?
(pred (c char?) ) ⟹ boolean?
(shared description for char-set-filter, char-set-filter!) Returns a character set containing every character c in cs such that (pred c) returns true.
If character set base-cs is provided, the characters specified by pred are added to it. char-set-filter! is allowed, but not required, to side-effect and reuse the storage in base-cs; char-set-filter produces a fresh character set.
An implementation may not save away a reference to pred and invoke it after char-set-filter or char-set-filter! returns -- that is, "lazy", on-demand implementations are not allowed, as pred may have external dependencies on mutable data or have other side-effects.
Rationale: This procedure provides a means of converting a character predicate into its equivalent character set; the cs parameter allows the programmer to bound the predicate's domain. Programmers should be aware that filtering a character set such as char-set:full could be a very expensive operation in an implementation that provided an extremely large character type, such as 32-bit Unicode. An earlier draft of this library provided a simple predicate->char-set procedure, which was rejected in favor of char-set-filter for this reason.
(scheme charset) procedure (char-set-filter! (pred procedure?) (cs char-set?) (base-cs char-set?) ) ⟹ char-set?
(pred (c char?) ) ⟹ boolean?
(shared description for char-set-filter, char-set-filter!) Returns a character set containing every character c in cs such that (pred c) returns true.
If character set base-cs is provided, the characters specified by pred are added to it. char-set-filter! is allowed, but not required, to side-effect and reuse the storage in base-cs; char-set-filter produces a fresh character set.
An implementation may not save away a reference to pred and invoke it after char-set-filter or char-set-filter! returns -- that is, "lazy", on-demand implementations are not allowed, as pred may have external dependencies on mutable data or have other side-effects.
Rationale: This procedure provides a means of converting a character predicate into its equivalent character set; the cs parameter allows the programmer to bound the predicate's domain. Programmers should be aware that filtering a character set such as char-set:full could be a very expensive operation in an implementation that provided an extremely large character type, such as 32-bit Unicode. An earlier draft of this library provided a simple predicate->char-set procedure, which was rejected in favor of char-set-filter for this reason.
(scheme charset) procedure (ucs-range->char-set (lower integer?) (upper integer?) ) ⟹ char-set?
(scheme charset) procedure (ucs-range->char-set (lower integer?) (upper integer?) (error? boolean?) ) ⟹ char-set?
(scheme charset) procedure (ucs-range->char-set (lower integer?) (upper integer?) (error? boolean?) (base-cs char-set?) ) ⟹ char-set?
(shared description for ucs-range->char-set, ucs-range->char-set!) Lower and upper are exact non-negative integers; lower <= upper.
Returns a character set containing every character whose ISO/IEC 10646 UCS-4 code lies in the half-open range [lower,upper).
* If the requested range includes unassigned UCS values, these are silently ignored (the current UCS specification has "holes" in the space of assigned codes).
* If the requested range includes "private" or "user space" codes, these are handled in an implementation-specific manner; however, a UCS- or Unicode-based Scheme implementation should pass them through transparently.
* If any code from the requested range specifies a valid, assigned UCS character that has no corresponding representative in the implementation's character type, then (1) an error is raised if error? is true, and (2) the code is ignored if error? is false (the default). This might happen, for example, if the implementation uses ASCII characters, and the requested range includes non-ASCII characters.
If character set base-cs is provided, the characters specified by the range are added to it. ucs-range->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; ucs-range->char-set produces a fresh character set.
Note that ASCII codes are a subset of the Latin-1 codes, which are in turn a subset of the 16-bit Unicode codes, which are themselves a subset of the 32-bit UCS-4 codes. We commit to a specific encoding in this routine, regardless of the underlying representation of characters, so that client code using this library will be portable. I.e., a conformant Scheme implementation may use EBCDIC or SHIFT-JIS to encode characters; it must simply map the UCS characters from the given range into the native representation when possible, and report errors when not possible.
(scheme charset) procedure (ucs-range->char-set! (lower integer?) (upper integer?) (error? boolean?) (base-cs char-set?) ) ⟹ char-set?
(shared description for ucs-range->char-set, ucs-range->char-set!) Lower and upper are exact non-negative integers; lower <= upper.
Returns a character set containing every character whose ISO/IEC 10646 UCS-4 code lies in the half-open range [lower,upper).
* If the requested range includes unassigned UCS values, these are silently ignored (the current UCS specification has "holes" in the space of assigned codes).
* If the requested range includes "private" or "user space" codes, these are handled in an implementation-specific manner; however, a UCS- or Unicode-based Scheme implementation should pass them through transparently.
* If any code from the requested range specifies a valid, assigned UCS character that has no corresponding representative in the implementation's character type, then (1) an error is raised if error? is true, and (2) the code is ignored if error? is false (the default). This might happen, for example, if the implementation uses ASCII characters, and the requested range includes non-ASCII characters.
If character set base-cs is provided, the characters specified by the range are added to it. ucs-range->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; ucs-range->char-set produces a fresh character set.
Note that ASCII codes are a subset of the Latin-1 codes, which are in turn a subset of the 16-bit Unicode codes, which are themselves a subset of the 32-bit UCS-4 codes. We commit to a specific encoding in this routine, regardless of the underlying representation of characters, so that client code using this library will be portable. I.e., a conformant Scheme implementation may use EBCDIC or SHIFT-JIS to encode characters; it must simply map the UCS characters from the given range into the native representation when possible, and report errors when not possible.
(scheme charset) procedure (->char-set (x string?) ) ⟹ char-set?
(scheme charset) procedure (->char-set (x char?) ) ⟹ char-set?
(scheme charset) procedure (->char-set (x char-set?) ) ⟹ char-set?
Coerces x into a char-set. X may be a string, character or char-set. A string is converted to the set of its constituent characters; a character is converted to a singleton set; a char-set is returned as-is. This procedure is intended for use by other procedures that want to provide "user-friendly", wide-spectrum interfaces to their clients.
(scheme charset) procedure (char-set-size (cs char-set?) ) ⟹ integer?
Returns the number of elements in character set cs.
(scheme charset) procedure (char-set-count (pred procedure?) (cs char-set?) ) ⟹ integer?
(pred (c char?) ) ⟹ boolean?
Apply pred to the chars of character set cs, and return the number of chars that caused the predicate to return true.
(scheme charset) procedure (char-set->list (cs char-set?) ) ⟹ list?
This procedure returns a list of the members of character set cs. The order in which cs's characters appear in the list is not defined, and may be different from one call to another.
(scheme charset) procedure (char-set->string (cs char-set?) ) ⟹ string?
This procedure returns a string containing the members of character set cs. The order in which cs's characters appear in the string is not defined, and may be different from one call to another.
(scheme charset) procedure (char-set-contains? (cs char-set?) (char char?) ) ⟹ boolean?
This procedure tests char for membership in character set cs.
The MIT Scheme character-set package called this procedure char-set-member?, but the argument order isn't consistent with the name.
(scheme charset) procedure (char-set-every (pred procedure?) (cs char-set?) ) ⟹ boolean?
(pred (c char?) ) ⟹ boolean?
(shared description for char-set-every, char-set-any) The char-set-every procedure returns true if predicate pred returns true of every character in the character set cs. Likewise, char-set-any applies pred to every character in character set cs, and returns the first true value it finds. If no character produces a true value, it returns false. The order in which these procedures sequence through the elements of cs is not specified.
Note that if you need to determine the actual character on which a predicate returns true, use char-set-any and arrange for the predicate to return the character parameter as its true value
(scheme charset) procedure (char-set-any (pred procedure?) (cs char-set?) ) ⟹ boolean?
(pred (c char?) ) ⟹ boolean?
(shared description for char-set-every, char-set-any) The char-set-every procedure returns true if predicate pred returns true of every character in the character set cs. Likewise, char-set-any applies pred to every character in character set cs, and returns the first true value it finds. If no character produces a true value, it returns false. The order in which these procedures sequence through the elements of cs is not specified.
Note that if you need to determine the actual character on which a predicate returns true, use char-set-any and arrange for the predicate to return the character parameter as its true value
(scheme charset) procedure (char-set-adjoin (cs char-set?) (char1 char?) ... ) ⟹ char-set?
Add the chari characters to character set cs.
(scheme charset) procedure (char-set-delete (cs char-set?) (char1 char?) ... ) ⟹ char-set?
Delete the chari characters from character set cs.
(scheme charset) procedure (char-set-adjoin! (cs char-set?) (char1 char?) ... ) ⟹ char-set?
Add the chari characters to character set cs. Linear-update variant. The procedure is allowed, but not required, to side-effect its first parameter.
(scheme charset) procedure (char-set-delete! (cs char-set?) (char1 char?) ... ) ⟹ char-set?
Delete the chari characters from character set cs. Linear-update variant. The procedure is allowed, but not required, to side-effect its first parameter.
(scheme charset) procedure (char-set-complement (cs char-set?) ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(scheme charset) procedure (char-set-union (cs1 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(scheme charset) procedure (char-set-intersection (cs1 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(scheme charset) procedure (char-set-difference (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(scheme charset) procedure (char-set-xor (cs1 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(scheme charset) procedure (char-set-diff+intersection (cs1 char-set?) (cs2 char-set?) ... ) ⟹ (values char-set?char-set?)
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(scheme charset) procedure (char-set-complement! (cs char-set?) ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(scheme charset) procedure (char-set-union (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(scheme charset) procedure (char-set-intersection! (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(scheme charset) procedure (char-set-difference! (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(scheme charset) procedure (char-set-xor! (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(scheme charset) procedure (char-set-diff+intersection! (cs1 char-set?) (cs2 char-set?) (cs3 char-set?) ... ) ⟹ (values char-set?char-set?)
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
char-set:lower-case ⟹ char-set?
Lower-case letters
char-set:upper-case ⟹ char-set?
Upper-case letters
char-set:title-case ⟹ char-set?
Title-case letters
char-set:letter ⟹ char-set?
Letters
char-set:digit ⟹ char-set?
Digits
char-set:letter+digit ⟹ char-set?
Letters and digits
char-set:graphic ⟹ char-set?
Printing characters except spaces
char-set:printing ⟹ char-set?
Printing characters including spaces
char-set:whitespace ⟹ char-set?
Whitespace characters
char-set:iso-control ⟹ char-set?
The ISO control characters
char-set:punctuation ⟹ char-set?
Punctuation characters
char-set:symbol ⟹ char-set?
Symbol characters
char-set:hex-digit ⟹ char-set?
A hexadecimal digit: 0-9, A-F, a-f
char-set:blank ⟹ char-set?
Blank characters -- horizontal whitespace
char-set:ascii ⟹ char-set?
All characters in the ASCII set.
char-set:empty ⟹ char-set?
Empty set
char-set:full ⟹ char-set?
All characters
library (scheme ephemeron)
(scheme ephemeron) procedure (ephemeron? object ) ⟹ boolean?
Returns #t if object is an ephemeron; otherwise returns #f.
(scheme ephemeron) procedure (make-ephemeron key datum ) ⟹ ephemeron?
Returns a newly allocated ephemeron, with components key and datum. Note that if key and datum are the same in the sense of eq?, the ephemeron is effectively a weak reference to the object.
(scheme ephemeron) procedure (ephemeron-broken? (ephemeron ephemeron?) ) ⟹ boolean?
Returns #t if ephemeron has been broken; otherwise returns #f.
This procedure must be used with care. If it returns #f, that guarantees only that prior evaluations of ephemeron-key or ephemeron-datum yielded the key or datum that was stored in ephemeron. However, it makes no guarantees about subsequent calls to ephemeron-key or ephemeron-datum, because the GC may run and break the ephemeron immediately after ephemeron-broken? returns.
(scheme ephemeron) procedure (ephemeron-key (ephemeron ephemeron?) ) ⟹ *
(shared description for ephemeron-key, ephemeron-datum) These return the key or datum component, respectively, of ephemeron. If ephemeron has been broken, these operations return #f, but they can also return #f if that is what was stored as the key or datum.
(scheme ephemeron) procedure (ephemeron-datum (ephemeron ephemeron?) ) ⟹ *
(shared description for ephemeron-key, ephemeron-datum) These return the key or datum component, respectively, of ephemeron. If ephemeron has been broken, these operations return #f, but they can also return #f if that is what was stored as the key or datum.
(scheme ephemeron) procedure (reference-barrier key ) ⟹ *
This procedure ensures that the garbage collector does not break an ephemeron containing an unreferenced key before a certain point in a program. The program can invoke a reference barrier on the key by calling this procedure, which guarantees that even if the program does not use the key, it will be considered strongly reachable until after reference-barrier returns.
Because one cannot reliably operate on ephemerons in a portable way without calling the procedure reference-barrier, reference-barrier is mandatory.
library (scheme generator)
(scheme generator) procedure (generator arg ... ) ⟹ procedure?
(return ) ⟹ *
The simplest finite generator. Generates each of its arguments in turn. When no arguments are provided, it returns an empty generator that generates no values.
(scheme generator) procedure (circular-generator arg ... ) ⟹ procedure?
(return ) ⟹ *
The simplest infinite generator. Generates each of its arguments in turn, then generates them again in turn, and so on forever.
(scheme generator) procedure (make-iota-generator (count integer?) ) ⟹ procedure?
(scheme generator) procedure (make-iota-generator (count integer?) (start real?) ) ⟹ procedure?
(scheme generator) procedure (make-iota-generator (count integer?) (start real?) (step real?) ) ⟹ procedure?
(return ) ⟹ real? / eof-object? /
Creates a finite generator of a sequence of count numbers. The sequence begins with start (which defaults to 0) and increases by step (which defaults to 1). If both start and step are exact, it generates exact numbers; otherwise it generates inexact numbers. The exactness of count doesn't affect the exactness of the results.
(scheme generator) procedure (make-range-generator (start real?) ) ⟹ procedure?
(scheme generator) procedure (make-range-generator (start real?) (end real?) ) ⟹ procedure?
(scheme generator) procedure (make-range-generator (start real?) (end real?) (step real?) ) ⟹ procedure?
(return ) ⟹ real? / eof-object? /
Creates a generator of a sequence of numbers. The sequence begins with start, increases by step (default 1), and continues while the number is less than end, or forever if end is omitted. If both start and step are exact, it generates exact numbers; otherwise it generates inexact numbers. The exactness of end doesn't affect the exactness of the results.
(scheme generator) procedure (make-coroutine-generator (proc procedure?) ) ⟹ procedure?
(proc (yield procedure?) ) ⟹ undefined
(yield value ) ⟹ undefined
(return ) ⟹ *
Creates a generator from a coroutine.
The proc argument is a procedure that takes one argument, yield. When called, make-coroutine-generator immediately returns a generator g. When g is called, proc runs until it calls yield. Calling yield causes the execution of proc to be suspended, and g returns the value passed to yield.
Whether this generator is finite or infinite depends on the behavior of proc. If proc returns, it is the end of the sequence — g returns an end-of-file object from then on. The return value of proc is ignored.
(scheme generator) procedure (list->generator (lis list?) ) ⟹ procedure?
(return ) ⟹ *
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(scheme generator) procedure (vector->generator (vec vector?) ) ⟹ procedure?
(scheme generator) procedure (vector->generator (vec vector?) (start integer?) ) ⟹ procedure?
(scheme generator) procedure (vector->generator (vec vector?) (start integer?) (end integer?) ) ⟹ procedure?
(return ) ⟹ *
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(scheme generator) procedure (reverse-vector->generator (vec vector?) ) ⟹ procedure?
(scheme generator) procedure (reverse-vector->generator (vec vector?) (start integer?) ) ⟹ procedure?
(scheme generator) procedure (reverse-vector->generator (vec vector?) (start integer?) (end integer?) ) ⟹ procedure?
(return ) ⟹ *
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(scheme generator) procedure (string->generator (str string?) ) ⟹ procedure?
(scheme generator) procedure (string->generator (str string?) (start integer?) ) ⟹ procedure?
(scheme generator) procedure (string->generator (str string?) (start integer?) (end integer?) ) ⟹ procedure?
(return ) ⟹ char? / eof-object? /
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(scheme generator) procedure (bytevector->generator (bytevector bytevector?) ) ⟹ procedure?
(scheme generator) procedure (bytevector->generator (bytevector bytevector?) (start integer?) ) ⟹ procedure?
(scheme generator) procedure (bytevector->generator (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ procedure?
(return ) ⟹ integer? / eof-object? /
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(scheme generator) procedure (make-for-each-generator (for-each procedure?) obj ) ⟹ procedure?
(for-each element ) ⟹ undefined
(return ) ⟹ *
A generator constructor that converts any collection obj to a generator that returns its elements using a for-each procedure appropriate for obj. This must be a procedure that when called as (for-each proc obj) calls proc on each element of obj. Examples of such procedures are for-each, string-for-each, and vector-for-each from R7RS. The value returned by for-each is ignored. The generator is finite if the collection is finite, which would typically be the case.
The collections need not be conventional ones (lists, strings, etc.) as long as for-each can invoke a procedure on everything that counts as a member.
(scheme generator) procedure (make-unfold-generator (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ procedure?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
(return ) ⟹ *
A generator constructor similar to SRFI 1's unfold.
The stop? predicate takes a seed value and determines whether to stop. The mapper procedure calculates a value to be returned by the generator from a seed value. The successor procedure calculates the next seed value from the current seed value.
For each call of the resulting generator, stop? is called with the current seed value. If it returns true, then the generator returns an end-of-file object. Otherwise, it applies mapper to the current seed value to get the value to return, and uses successor to update the seed value.
This generator is finite unless stop? never returns true.
(scheme generator) procedure (gcons* item ... (gen procedure?) ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ *
Returns a generator that adds items in front of gen. Once the items have been consumed, the generator is guaranteed to tail-call gen.
(scheme generator) procedure (gappend (gen procedure?) ... ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ *
Returns a generator that yields the items from the first given generator, and once it is exhausted, from the second generator, and so on.
(scheme generator) procedure (gflatten (gen procedure?) ... ) ⟹ procedure?
(gen ) ⟹ list?
(return ) ⟹ *
Returns a generator that yields the elements of the lists produced by the given generator.
(scheme generator) procedure (ggroup (gen procedure?) (k integer?) ) ⟹ procedure?
(scheme generator) procedure (ggroup (gen procedure?) (k integer?) padding ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ list? / eof-object? /
Returns a generator that yields lists of k items from the given generator. If fewer than k elements are available for the last list, and padding is absent, the short list is returned; otherwise, it is padded by padding to length k.
(scheme generator) procedure (gmerge (less-than procedure?) (gen1 procedure?) ... ) ⟹ procedure?
(less-than a b ) ⟹ boolean?
(gen ) ⟹ *
Returns a generator that yields the items from the given generators in the order dictated by less-than. If the items are equal, the leftmost item is used first. When all of given generators are exhausted, the returned generator is exhausted also.
As a special case, if only one generator is given, it is returned.
(scheme generator) procedure (gmap (proc procedure?) (gen1 procedure?) ... ) ⟹ procedure?
(proc el ) ⟹ *
(gen ) ⟹ *
When only one generator is given, returns a generator that yields the items from the given generator after invoking proc on them.
When more than one generator is given, each item of the resulting generator is a result of applying proc to the items from each generator. If any of input generator is exhausted, the resulting generator is also exhausted.
Note: This differs from generator-map->list, which consumes all values at once and returns the results as a list, while gmap returns a generator immediately without consuming input.
(scheme generator) procedure (gcombine (proc procedure?) seed (gen1 procedure?) (gen2 procedure?) ... ) ⟹ procedure?
(proc value1 value2 ... seed ) ⟹ (values **)
(gen ) ⟹ *
(return ) ⟹ *
A generator for mapping with state. It yields a sequence of sub-folds over proc.
The proc argument is a procedure that takes as many arguments as the input generators plus one. It is called as (proc v1 v2 … seed), where v1, v2, … are the values yielded from the input generators, and seed is the current seed value. It must return two values, the yielding value and the next seed. The result generator is exhausted when any of the genn generators is exhausted, at which time all the others are in an undefined state.
(scheme generator) procedure (gfilter (pred procedure?) (gen procedure?) ) ⟹ procedure?
(pred element ) ⟹ boolean?
(gen ) ⟹ *
(return ) ⟹ *
Returns generators that yield the items from the source generator, except those on which pred answers false.
(scheme generator) procedure (gremove (pred procedure?) (gen procedure?) ) ⟹ procedure?
(pred element ) ⟹ boolean?
(gen ) ⟹ *
(return ) ⟹ *
Returns generators that yield the items from the source generator, except those on which pred answers true.
(scheme generator) procedure (gstate-filter (proc procedure?) seed (gen procedure?) ) ⟹ procedure?
(proc item state ) ⟹ (values boolean?*)
(gen ) ⟹ *
(return ) ⟹ *
Returns a generator that obtains items from the source generator and passes an item and a state (whose initial value is seed) as arguments to proc. Proc in turn returns two values, a boolean and a new value of the state. If the boolean is true, the item is returned; otherwise, this algorithm is repeated until gen is exhausted, at which point the returned generator is also exhausted. The final value of the state is discarded.
(scheme generator) procedure (gtake (gen procedure?) (k integer?) ) ⟹ procedure?
(scheme generator) procedure (gtake (gen procedure?) (k integer?) padding ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ *
Gtake returns a generator that yields (at most) the first k items of the source generator.
The procedure won't complain if the source generator is exhausted before generating k items. By default, the generator returned by gtake terminates when the source generator does, but if you provide the padding argument, then the returned generator will yield exactly k items, using the padding value as needed to provide sufficient additional values.
(scheme generator) procedure (gdrop (gen procedure?) (k integer?) ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ *
Gdrop returns a generator that skips the first k items of the source generator. The procedure won't complain if the source generator is exhausted before generating k items.
(scheme generator) procedure (gtake-while (pred procedure?) (gen procedure?) ) ⟹ procedure?
(pred element ) ⟹ boolean?
(gen ) ⟹ *
(return ) ⟹ *
The generator returned from gtake-while yields items from the source generator as long as pred returns true for each.
(scheme generator) procedure (gdrop-while (pred procedure?) (gen procedure?) ) ⟹ procedure?
(pred element ) ⟹ boolean?
(gen ) ⟹ *
(return ) ⟹ *
The generator returned from gdrop-while first reads and discards values from the source generator while pred returns true for them, then starts yielding items returned by the source.
(scheme generator) procedure (gdelete item (gen procedure?) ) ⟹ procedure?
(scheme generator) procedure (gdelete item (gen procedure?) (= procedure?) ) ⟹ procedure?
(gen ) ⟹ *
(= a b ) ⟹ boolean?
(return ) ⟹ *
Creates a generator that returns whatever gen returns, except for any items that are the same as item in the sense of =, which defaults to equal?. The = predicate is passed exactly two arguments, of which the first is item and the second is an element generated by gen.
(scheme generator) procedure (gdelete-neighbor-dups (gen procedure?) ) ⟹ procedure?
(scheme generator) procedure (gdelete-neighbor-dups (gen procedure?) (= procedure?) ) ⟹ procedure?
(gen ) ⟹ *
(= a b ) ⟹ boolean?
(return ) ⟹ *
Creates a generator that returns whatever gen returns, except for any items that are equal to the preceding item in the sense of =, which defaults to equal?. The = predicate is passed exactly two arguments, of which the first was generated by gen before the second.
(scheme generator) procedure (gindex (value-gen procedure?) (index-gen procedure?) ) ⟹ procedure?
(value-gen ) ⟹ *
(index-gen ) ⟹ integer? / eof-object? /
(return ) ⟹ *
Creates a generator that returns elements of value-gen specified by the indices (non-negative exact integers) generated by index-gen. It is an error if the indices are not strictly increasing. The result generator is exhausted when either generator is exhausted, at which time the other is in an undefined state.
(scheme generator) procedure (gselect (value-gen procedure?) (truth-gen procedure?) ) ⟹ procedure?
(value-gen ) ⟹ *
(truth-gen ) ⟹ boolean? / eof-object? /
(return ) ⟹ *
Creates a generator that returns elements of value-gen that correspond to the values generated by truth-gen. If the current value of truth-gen is true, the current value of value-gen is generated, but otherwise not. The result generator is exhausted when either generator is exhausted, at which time the other is in an undefined state.
(scheme generator) procedure (generator->list (generator procedure?) ) ⟹ list?
(scheme generator) procedure (generator->list (generator procedure?) (k integer?) ) ⟹ list?
(generator ) ⟹ *
Reads items from generator and returns a newly allocated list of them. By default, it reads until the generator is exhausted.
If an optional argument k is given, it must be a non-negative integer, and the list ends when either k items are consumed, or generator is exhausted; therefore generator can be infinite in this case.
(scheme generator) procedure (generator->reverse-list (generator procedure?) ) ⟹ list?
(scheme generator) procedure (generator->reverse-list (generator procedure?) (k integer?) ) ⟹ list?
(generator ) ⟹ *
Reads items from generator and returns a newly allocated list of them in reverse order. By default, this reads until the generator is exhausted.
If an optional argument k is given, it must be a non-negative integer, and the list ends when either k items are read, or generator is exhausted; therefore generator can be infinite in this case.
(scheme generator) procedure (generator->vector (generator procedure?) ) ⟹ vector?
(scheme generator) procedure (generator->vector (generator procedure?) (k integer?) ) ⟹ vector?
(generator ) ⟹ *
Reads items from generator and returns a newly allocated vector of them. By default, it reads until the generator is exhausted.
If an optional argument k is given, it must be a non-negative integer, and the list ends when either k items are consumed, or generator is exhausted; therefore generator can be infinite in this case.
(scheme generator) procedure (generator->vector! (vector vector?) (at integer?) (generator procedure?) ) ⟹ integer?
(generator ) ⟹ *
Reads items from generator and puts them into vector starting at index at, until vector is full or generator is exhausted. Generator can be infinite. The number of elements generated is returned.
(scheme generator) procedure (generator->string (generator procedure?) ) ⟹ string?
(scheme generator) procedure (generator->string (generator procedure?) (k integer?) ) ⟹ string?
(generator ) ⟹ char? / eof-object? /
Reads items from generator and returns a newly allocated string of them. It is an error if the items are not characters. By default, it reads until the generator is exhausted.
If an optional argument k is given, it must be a non-negative integer, and the string ends when either k items are consumed, or generator is exhausted; therefore generator can be infinite in this case.
(scheme generator) procedure (generator-fold (proc procedure?) seed (gen1 procedure?) (gen2 procedure?) ... ) ⟹ procedure?
(proc val1 val2 ... state ) ⟹ *
(gen ) ⟹ *
Works like SRFI 1 fold on the values generated by the generator arguments.
When one generator is given, for each value v generated by gen, proc is called as (proc v r), where r is the current accumulated result; the initial value of the accumulated result is seed, and the return value from proc becomes the next accumulated result. When gen is exhausted, the accumulated result at that time is returned from generator-fold.
When more than one generator is given, proc is invoked on the values returned by all the generator arguments followed by the current accumulated result. The procedure terminates when any of the genn generators is exhausted, at which time all the others are in an undefined state.
(scheme generator) procedure (generator-for-each (proc procedure?) (gen1 procedure?) (gen2 procedure?) ... ) ⟹ undefined
(proc val1 val2 ... ) ⟹ undefined
(gen ) ⟹ *
A generator analogue of for-each that consumes generated values using side effects. Repeatedly applies proc on the values yielded by gen, gen2 … until any one of the generators is exhausted, at which time all the others are in an undefined state. The values returned from proc are discarded. Returns an unspecified value.
(scheme generator) procedure (generator-map->list (proc procedure?) (gen1 procedure?) (gen2 procedure?) ... ) ⟹ list?
(proc element ) ⟹ *
(generator ) ⟹ *
A generator analogue of map that consumes generated values, processes them through a mapping function, and returns a list of the mapped values. Repeatedly applies proc on the values yielded by gen, gen2 … until any one of the generators is exhausted, at which time all the others are in an undefined state. The values returned from proc are accumulated into a list, which is returned.
(scheme generator) procedure (generator-find (pred procedure?) (generator procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(generator ) ⟹ *
Applies pred to each item from gen. As soon as it yields a true value, the item is returned without consuming the rest of gen. If gen is exhausted, returns #f.
(scheme generator) procedure (generator-count (pred procedure?) (generator procedure?) ) ⟹ integer?
(pred element ) ⟹ boolean?
(generator ) ⟹ *
Returns the number of items available from the generator gen that satisfy the predicate pred.
(scheme generator) procedure (generator-any (pred procedure?) (generator procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(generator ) ⟹ *
Applies pred to each item from gen. As soon as it yields a true value, the value is returned without consuming the rest of gen. If gen is exhausted, returns #f.
(scheme generator) procedure (generator-every (pred procedure?) (generator procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(generator ) ⟹ *
Applies pred to each item from gen. As soon as it yields a false value, the value is returned without consuming the rest of gen. If gen is exhausted, returns the last value returned by pred, or #t if pred was never called.
(scheme generator) procedure (generator-unfold (gen procedure?) (unfold procedure?) arg ... ) ⟹ *
(gen ) ⟹ *
(unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed args ... ) ⟹ *
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Equivalent to (unfold eof-object? (lambda (x) x) (lambda (x) (gen)) (gen) arg ...). The values of gen are unfolded into the collection that unfold creates.
The signature of the unfold procedure is (unfold stop? mapper successor seed args ...). Note that the vector-unfold and vector-unfold-right of SRFI 43 and SRFI 133 do not have this signature and cannot be used with this procedure. To unfold into a vector, use SRFI 1's unfold and then apply list->vector to the result.
(scheme generator) procedure (make-accumulator (kons procedure?) knil (finalizer procedure?) ) ⟹ procedure?
(kons element state ) ⟹ *
(finalizer state ) ⟹ *
(return el ) ⟹ *
Returns an accumulator that, when invoked on an object other than an end-of-file object, invokes kons on its argument and the accumulator's current state, using the same order as a function passed to fold. It then sets the accumulator's state to the value returned by kons and returns an unspecified value. The initial state of the accumulator is set to knil. However, if an end-of-file object is passed to the accumulator, it returns the result of tail-calling the procedure finalizer on the state. Repeated calls with an end-of-file object will reinvoke finalizer.
(scheme generator) procedure (count-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / integer? /
Returns an accumulator that, when invoked on an object, adds 1 to a count inside the accumulator and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the count.
(scheme generator) procedure (list-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / list? /
Returns an accumulator that, when invoked on an object, adds that object to a list inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the list.
(scheme generator) procedure (reverse-list-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / list? /
Returns an accumulator that, when invoked on an object, adds that object to a list inside the accumulator in reverse order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the list.
(scheme generator) procedure (vector-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / vector? /
Returns an accumulator that, when invoked on an object, adds that object to a vector inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the vector.
(scheme generator) procedure (reverse-vector-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / vector? /
Returns an accumulator that, when invoked on an object, adds that object to a vector inside the accumulator in reverse order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the vector.
(scheme generator) procedure (vector-accumulator! (vector vector?) (at integer?) ) ⟹ procedure?
(return el ) ⟹ undefined / vector? /
Returns an accumulator that, when invoked on an object, adds that object to consecutive positions of vector starting at at in order of accumulation. It is an error to try to accumulate more objects than vector will hold. An unspecified value is returned. However, if an end-of-file object is passed, the accumulator returns vector.
(scheme generator) procedure (string-accumulator ) ⟹ procedure?
(return (char (or char?eof-object?)) ) ⟹ undefined / string? /
Returns an accumulator that, when invoked on a character, adds that character to a string inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the string.
(scheme generator) procedure (bytevector-accumulator ) ⟹ procedure?
(return (byte (or integer?eof-object?)) ) ⟹ undefined / bytevector? /
Returns an accumulator that, when invoked on a byte, adds that integer to a bytevector inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the bytevector.
(scheme generator) procedure (bytevector-accumulator! (bytevector bytevector?) (at integer?) ) ⟹ procedure?
(return (byte (or integer?eof-object?)) ) ⟹ undefined / bytevector? /
Returns an accumulator that, when invoked on a byte, adds that byte to consecutive positions of bytevector starting at at in order of accumulation. It is an error to try to accumulate more bytes than vector will hold. An unspecified value is returned. However, if an end-of-file object is passed, the accumulator returns bytevector.
(scheme generator) procedure (sum-accumulator ) ⟹ procedure?
(return (char (or number?eof-object?)) ) ⟹ undefined / number? /
Returns an accumulator that, when invoked on a number, adds that number to a sum inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the sum.
(scheme generator) procedure (product-accumulator ) ⟹ procedure?
(return (char (or number?eof-object?)) ) ⟹ undefined / number? /
Returns an accumulator that, when invoked on a number, multiplies that number to a product inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the product.
library (scheme hash-table)
(scheme hash-table) procedure (make-hash-table (comparator comparator?) arg ... ) ⟹ hash-table?
(scheme hash-table) procedure (make-hash-table (equality-predicate procedure?) arg ... ) ⟹ hash-table?
(scheme hash-table) procedure (make-hash-table (equality-predicate procedure?) (hash-function procedure?) arg ... ) ⟹ hash-table?
(equality-predicate a b ) ⟹ boolean?
(hash-function obj ) ⟹ integer?
Returns a newly allocated hash table whose equality predicate and hash function are extracted from comparator. Alternatively, for backward compatibility with SRFI 69 the equality predicate and hash function can be passed as separate arguments; this usage is deprecated.
As mentioned above, implementations are free to use an appropriate implementation-dependent hash function instead of the specified hash function, provided that the specified equality predicate is a refinement of the equal? predicate. This applies whether the hash function and equality predicate are passed as separate arguments or packaged up into a comparator.
If an equality predicate rather than a comparator is provided, the ability to omit the hash-function argument is severely limited. The implementation must provide hash functions appropriate for use with the predicates eq?, eqv?, equal?, string=?, and string-ci=?, and may extend this list. But if any unknown equality predicate is provided without a hash function, an error should be signaled. The constraints on equality predicates and hash functions are given in SRFI 128.
The meaning of any further arguments is implementation-dependent. However, implementations which support the ability to specify the initial capacity of a hash table should interpret a non-negative exact integer as the specification of that capacity. In addition, if the symbols thread-safe, weak-keys, ephemeral-keys, weak-values, or ephemeral-values are present, implementations should create thread-safe hash tables, hash tables with weak keys or ephemeral keys, or hash tables with weak or ephemeral values respectively. Implementations are free to use ephemeral keys or values when weak keys or values respectively have been requested. To avoid collision with the hash-function argument, none of these arguments can be procedures.
(R6RS make-eq-hashtable, make-eqv-hashtable, and make-hashtable; Common Lisp make-hash-table)
(scheme hash-table) procedure (hash-table (comparator comparator?) key1 value1 ... ) ⟹ hash-table?
Returns a newly allocated hash table, created as if by make-hash-table using comparator. For each pair of arguments, an association is added to the new hash table with key as its key and value as its value. If the implementation supports immutable hash tables, this procedure returns an immutable hash table. If the same key (in the sense of the equality predicate) is specified more than once, it is an error.
(scheme hash-table) procedure (hash-table-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (comparator comparator?) arg ... ) ⟹ hash-table?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ (values **)
(successor seed ) ⟹ *
Create a new hash table as if by make-hash-table using comparator and the args. If the result of applying the predicate stop? to seed is true, return the hash table. Otherwise, apply the procedure mapper to seed. Mapper returns two values, which are inserted into the hash table as the key and the value respectively. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
(scheme hash-table) procedure (alist->hash-table (alist list?) (comparator comparator?) arg ... ) ⟹ hash-table?
(scheme hash-table) procedure (alist->hash-table (alist list?) (equality-predicate procedure?) arg ... ) ⟹ hash-table?
(scheme hash-table) procedure (alist->hash-table (alist list?) (equality-predicate procedure?) (hash-function procedure?) arg ... ) ⟹ hash-table?
(equality-predicate a b ) ⟹ boolean?
(hash-function obj ) ⟹ integer?
Returns a newly allocated hash-table as if by make-hash-table using comparator and the args. It is then initialized from the associations of alist. Associations earlier in the list take precedence over those that come later. The second form is for compatibility with SRFI 69, and is deprecated.
(scheme hash-table) procedure (hash-table? obj ) ⟹ boolean?
Returns #t if obj is a hash table, and #f otherwise. (R6RS hashtable?; Common Lisp hash-table-p)
(scheme hash-table) procedure (hash-table-contains? (hash-table hash-table?) key ) ⟹ boolean?
Returns #t if there is any association to key in hash-table, and #f otherwise. Must execute in expected amortized constant time. (R6RS hashtable-contains?)
(scheme hash-table) procedure (hash-table-exists? (hash-table hash-table?) key ) ⟹ boolean?
Returns #t if there is any association to key in hash-table, and #f otherwise. Must execute in expected amortized constant time. The hash-table-exists? procedure is the same as hash-table-contains?, is provided for backward compatibility with SRFI 69, and is deprecated. (R6RS hashtable-contains?)
(scheme hash-table) procedure (hash-table-empty? (hash-table hash-table?) ) ⟹ boolean?
Returns #t if hash-table contains no associations, and #f otherwise.
(scheme hash-table) procedure (hash-table=? (value-comparator comparator?) (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ boolean?
Returns #t if hash-table1 and hash-table2 have the same keys (in the sense of their common equality predicate) and each key has the same value (in the sense of value-comparator), and #f otherwise.
(scheme hash-table) procedure (hash-table-mutable? (hash-table hash-table?) ) ⟹ boolean?
Returns #t if the hash table is mutable. Implementations may or may not support immutable hash tables. (R6RS hashtable-mutable?)
(scheme hash-table) procedure (hash-table-ref (hash-table hash-table?) key ) ⟹ *
(scheme hash-table) procedure (hash-table-ref (hash-table hash-table?) key (failure procedure?) ) ⟹ *
(scheme hash-table) procedure (hash-table-ref (hash-table hash-table?) key (failure procedure?) (success procedure?) ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Extracts the value associated to key in hash-table, invokes the procedure success on it, and returns its result; if success is not provided, then the value itself is returned. If key is not contained in hash-table and failure is supplied, then failure is invoked on no arguments and its result is returned. Otherwise, it is an error. Must execute in expected amortized constant time, not counting the time to call the procedures. SRFI 69 does not support the success procedure.
(scheme hash-table) procedure (hash-table-ref/default (hash-table hash-table?) key default ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(hash-table-ref hash-table key (lambda () default))
(R6RS hashtable-ref; Common Lisp gethash)
(scheme hash-table) procedure (hash-table-set! (hash-table hash-table?) key1 value1 ... ) ⟹ undefined
Repeatedly mutates hash-table, creating new associations in it by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, it is deleted. It is an error if the type check procedure of the comparator of hash-table, when invoked on a key, does not return #t. Likewise, it is an error if a key is not a valid argument to the equality predicate of hash-table. Returns an unspecified value. Must execute in expected amortized constant time per key. SRFI 69, R6RS hashtable-set! and Common Lisp (setf gethash) do not handle multiple associations.
(scheme hash-table) procedure (hash-table-delete! (hash-table hash-table?) key ... ) ⟹ undefined
Deletes any association to each key in hash-table and returns the number of keys that had associations. Must execute in expected amortized constant time per key. SRFI 69, R6RS hashtable-delete!, and Common Lisp remhash do not handle multiple associations.
(scheme hash-table) procedure (hash-table-intern! (hash-table hash-table?) key (failure procedure?) ) ⟹ undefined
(failure ) ⟹ *
Effectively invokes hash-table-ref with the given arguments and returns what it returns. If key was not found in hash-table, its value is set to the result of calling failure. Must execute in expected amortized constant time.
(scheme hash-table) procedure (hash-table-update! (hash-table hash-table?) key (updater procedure?) ) ⟹ undefined
(scheme hash-table) procedure (hash-table-update! (hash-table hash-table?) key (updater procedure?) (failure procedure?) ) ⟹ undefined
(scheme hash-table) procedure (hash-table-update! (hash-table hash-table?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ undefined
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(hash-table-set! hash-table key (updater (hash-table-ref hash-table key failure success)))
Must execute in expected amortized constant time. Returns an unspecified value. (SRFI 69 and R6RS hashtable-update! do not support the success procedure)
(scheme hash-table) procedure (hash-table-update!/default (hash-table hash-table?) key (updater procedure?) default ) ⟹ undefined
(updated value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(hash-table-set! hash-table key (updater (hash-table-ref/default hash-table key default)))
Must execute in expected amortized constant time. Returns an unspecified value.
(scheme hash-table) procedure (hash-table-pop! (hash-table hash-table?) ) ⟹ (values **)
Chooses an arbitrary association from hash-table and removes it, returning the key and value as two values.
It is an error if hash-table is empty.
(scheme hash-table) procedure (hash-table-clear! (hash-table hash-table?) ) ⟹ undefined
Delete all the associations from hash-table. (R6RS hashtable-clear!; Common Lisp clrhash)
(scheme hash-table) procedure (hash-table-size (hash-table hash-table?) ) ⟹ integer?
Returns the number of associations in hash-table as an exact integer. Should execute in constant time. (R6RS hashtable-size; Common Lisp hash-table-count.)
(scheme hash-table) procedure (hash-table-keys (hash-table hash-table?) ) ⟹ list?
Returns a newly allocated list of all the keys in hash-table. R6RS hashtable-keys returns a vector.
(scheme hash-table) procedure (hash-table-values (hash-table hash-table?) ) ⟹ list?
Returns a newly allocated list of all the keys in hash-table.
(scheme hash-table) procedure (hash-table-entries (hash-table hash-table?) ) ⟹ (values list?list?)
Returns two values, a newly allocated list of all the keys in hash-table and a newly allocated list of all the values in hash-table in the corresponding order. R6RS hash-table-entries returns vectors.
(scheme hash-table) procedure (hash-table-find (proc procedure?) (hash-table hash-table?) (failure procedure?) ) ⟹ *
(proc key value ) ⟹ *
(failure ) ⟹ *
For each association of hash-table, invoke proc on its key and value. If proc returns true, then hash-table-find returns what proc returns. If all the calls to proc return #f, return the result of invoking the thunk failure.
(scheme hash-table) procedure (hash-table-count (pred procedure?) (hash-table hash-table?) ) ⟹ integer?
(pred key value ) ⟹ boolean?
For each association of hash-table, invoke pred on its key and value. Return the number of calls to pred which returned true.
(scheme hash-table) procedure (hash-table-map (proc procedure?) (comparator comparator?) (hash-table hash-table?) ) ⟹ hash-table?
(proc value ) ⟹ *
Returns a newly allocated hash table as if by (make-hash-table comparator). Calls proc for every association in hash-table with the value of the association. The key of the association and the result of invoking proc are entered into the new hash table. Note that this is not the result of lifting mapping over the domain of hash tables, but it is considered more useful.
If comparator recognizes multiple keys in the hash-table as equivalent, any one of such associations is taken.
(scheme hash-table) procedure (hash-table-for-each (proc procedure?) (hash-table hash-table?) ) ⟹ undefined
(proc key value ) ⟹ undefined
Calls proc for every association in hash-table with two arguments: the key of the association and the value of the association. The value returned by proc is discarded. Returns an unspecified value. (Common Lisp maphash)
(scheme hash-table) procedure (hash-table-walk (hash-table hash-table?) (proc procedure?) ) ⟹ undefined
(proc key value ) ⟹ undefined
Calls proc for every association in hash-table with two arguments: the key of the association and the value of the association. The value returned by proc is discarded. Returns an unspecified value. The hash-table-walk procedure is equivalent to hash-table-for-each with the arguments reversed, is provided for backward compatibility with SRFI 69, and is deprecated. (Common Lisp maphash)
(scheme hash-table) procedure (hash-table-map! (proc procedure?) (comparator comparator?) (hash-table hash-table?) ) ⟹ undefined
(proc key value ) ⟹ *
Calls proc for every association in hash-table with two arguments: the key of the association and the value of the association. The value returned by proc is used to update the value of the association. Returns an unspecified value.
(scheme hash-table) procedure (hash-table-map->list (proc procedure?) (hash-table hash-table?) ) ⟹ list?
(proc key value ) ⟹ *
Calls proc for every association in hash-table with two arguments: the key of the association and the value of the association. The values returned by the invocations of proc are accumulated into a list, which is returned.
(scheme hash-table) procedure (hash-table-fold (proc procedure?) seed (hash-table hash-table?) ) ⟹ *
(scheme hash-table) procedure (hash-table-fold (hash-table hash-table?) (proc procedure?) seed ) ⟹ *
(proc key value state ) ⟹ *
Calls proc for every association in hash-table with three arguments: the key of the association, the value of the association, and an accumulated value val. Val is seed for the first invocation of procedure, and for subsequent invocations of proc, the returned value of the previous invocation. The value returned by hash-table-fold is the return value of the last invocation of proc. The order of arguments with hash-table as the first argument is provided for SRFI 69 compatibility, and is deprecated.
(scheme hash-table) procedure (hash-table-prune! (proc procedure?) (hash-table hash-table?) ) ⟹ undefined
(proc key value ) ⟹ boolean?
Calls proc for every association in hash-table with two arguments, the key and the value of the association, and removes all associations from hash-table for which proc returns true. Returns an unspecified value.
(scheme hash-table) procedure (hash-table-copy (hash-table hash-table?) ) ⟹ hash-table?
(scheme hash-table) procedure (hash-table-copy (hash-table hash-table?) (mutable boolean?) ) ⟹ hash-table?
Returns a newly allocated hash table with the same properties and associations as hash-table. If the second argument is present and is true, the new hash table is mutable. Otherwise it is immutable provided that the implementation supports immutable hash tables. SRFI 69 hash-table-copy does not support a second argument. (R6RS hashtable-copy)
(scheme hash-table) procedure (hash-table-empty-copy (hash-table hash-table?) ) ⟹ hash-table?
Returns a newly allocated mutable hash table with the same properties as hash-table, but with no associations.
(scheme hash-table) procedure (hash-table->alist (hash-table hash-table?) ) ⟹ list?
Returns an alist with the same associations as hash-table in an unspecified order.
(scheme hash-table) procedure (hash-table-union! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Adds the associations of hash-table2 to hash-table1 and returns hash-table1. If a key appears in both hash tables, its value is set to the value appearing in hash-table1. Returns hash-table1.
(scheme hash-table) procedure (hash-table-merge! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Adds the associations of hash-table2 to hash-table1 and returns hash-table1. If a key appears in both hash tables, its value is set to the value appearing in hash-table1. Returns hash-table1. The hash-table-merge! procedure is the same as hash-table-union!, is provided for compatibility with SRFI 69, and is deprecated.
(scheme hash-table) procedure (hash-table-intersection! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Deletes the associations from hash-table1 whose keys don't also appear in hash-table2 and returns hash-table1.
(scheme hash-table) procedure (hash-table-difference! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Deletes the associations of hash-table1 whose keys are also present in hash-table2 and returns hash-table1.
(scheme hash-table) procedure (hash-table-xor! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Deletes the associations of hash-table1 whose keys are also present in hash-table2, and then adds the associations of hash-table2 whose keys are not present in hash-table1 to hash-table1. Returns hash-table1.
(scheme hash-table) procedure (hash obj ) ⟹ integer?
(scheme hash-table) procedure (hash obj arg ) ⟹ integer?
The same as SRFI 128's default-hash procedure, except that it must accept (and should ignore) an optional second argument.
(scheme hash-table) procedure (string-hash (str string?) ) ⟹ integer?
(scheme hash-table) procedure (string-hash (str string?) arg ) ⟹ integer?
Similar to SRFI 128's string-hash procedure, except that it must accept (and should ignore) an optional second argument. It is incompatible with the procedure of the same name exported by SRFI 128 and SRFI 126.
(scheme hash-table) procedure (string-ci-hash (str string?) ) ⟹ integer?
(scheme hash-table) procedure (string-ci-hash (str string?) arg ) ⟹ integer?
Similar to SRFI 128's string-ci-hash procedure, except that it must accept (and should ignore) an optional second argument. It is incompatible with the procedure of the same name exported by SRFI 128 and SRFI 126.
(scheme hash-table) procedure (hash-by-identity obj ) ⟹ integer?
(scheme hash-table) procedure (hash-by-identity obj arg ) ⟹ integer?
The same as SRFI 128's default-hash procedure, except that it must accept (and should ignore) an optional second argument. However, if the implementation replaces the hash function associated with the eq? predicate with an implementation-dependent alternative, it is an error to call this procedure at all.
(scheme hash-table) procedure (hash-table-equivalence-function (hash-table hash-table?) ) ⟹ procedure?
(return a b ) ⟹ boolean?
Returns the equivalence procedure used to create hash-table.
(scheme hash-table) procedure (hash-table-hash-function (hash-table hash-table?) ) ⟹ procedure?
(return obj ) ⟹ integer?
Returns the hash function used to create hash-table. However, if the implementation has replaced the user-specified hash function with an implementation-specific alternative, the implementation may return #f instead.
library (scheme ideque)
(scheme ideque) procedure (ideque element ... ) ⟹ ideque?
Returns an ideque containing the elements. The first element (if any) will be at the front of the ideque and the last element (if any) will be at the back. Takes O(n) time, where n is the number of elements.
(scheme ideque) procedure (ideque-tabulate (n integer?) (proc procedure?) ) ⟹ ideque?
(proc (k integer?) ) ⟹ *
Invokes the predicate proc on every exact integer from 0 (inclusive) to n (exclusive). Returns an ideque containing the results in order of generation. Takes O(n) time.
(scheme ideque) procedure (ideque-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ ideque?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Invokes the predicate stop? on seed. If it returns false, generate the next result by applying mapper to seed, generate the next seed by applying successor to seed, and repeat this algorithm with the new seed. If stop? returns true, return an ideque containing the results in order of accumulation. Takes O(n) time.
(scheme ideque) procedure (ideque-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ ideque?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Invokes the predicate stop? on seed. If it returns false, generate the next result by applying mapper to seed, generate the next seed by applying successor to seed, and repeat the algorithm with the new seed. If stop? returns true, return an ideque containing the results in reverse order of accumulation. Takes O(n) time.
(scheme ideque) procedure (ideque? x ) ⟹ boolean?
Returns #t if x is an ideque, and #f otherwise. Takes O(1) time.
(scheme ideque) procedure (ideque-empty? (ideque ideque?) ) ⟹ boolean?
Returns #t if ideque contains zero elements, and #f otherwise. Takes O(1) time.
(scheme ideque) procedure (ideque= (elt= procedure?) (ideque ideque?) ... ) ⟹ boolean?
(elt= a b ) ⟹ boolean?
Determines ideque equality, given an element-equality procedure. Ideque A equals ideque B if they are of the same length, and their corresponding elements are equal, as determined by elt=. If the element-comparison procedure's first argument is from idequei, then its second argument is from idequei+1, i.e. it is always called as (elt= a b) for a an element of ideque A, and b an element of ideque B.
In the n-ary case, every idequei is compared to idequei+1 (as opposed, for example, to comparing ideque1 to every idequei, for i > 1). If there are zero or one ideque arguments, ideque= simply returns true. The name does not end in a question mark for compatibility with the SRFI-1 procedure list=.
Note that the dynamic order in which the elt= procedure is applied to pairs of elements is not specified. For example, if ideque= is applied to three ideques, A, B, and C, it may first completely compare A to B, then compare B to C, or it may compare the first elements of A and B, then the first elements of B and C, then the second elements of A and B, and so forth.
The equality procedure must be consistent with eq?. Note that this implies that two ideques which are eq? are always ideque=, as well; implementations may exploit this fact to "short-cut" the element-by-element comparisons.
(scheme ideque) procedure (ideque-any (pred procedure?) (ideque ideque?) ) ⟹ *
(pred element ) ⟹ *
Invokes pred on the elements of the ideque in order until one call returns a true value, which is then returned. If there are no elements, returns #f. Takes O(n) time.
(scheme ideque) procedure (ideque-every (pred procedure?) (ideque ideque?) ) ⟹ *
(pred element ) ⟹ *
Invokes pred on the elements of the ideque in order until one call returns a false value, which is then returned. If there are no elements, returns #t. Takes O(n) time.
(scheme ideque) procedure (ideque-front (ideque ideque?) ) ⟹ *
Returns the front element of ideque. It is an error for ideque to be empty. Takes O(1) time.
(scheme ideque) procedure (ideque-back (ideque ideque?) ) ⟹ *
Returns the back element of ideque. It is an error for ideque to be empty. Takes O(1) time.
(scheme ideque) procedure (ideque-remove-front (ideque ideque?) ) ⟹ ideque?
Returns an ideque with the front element of ideque removed. It is an error for ideque to be empty. Takes O(1) time.
(scheme ideque) procedure (ideque-remove-back (ideque ideque?) ) ⟹ ideque?
Returns an ideque with the back element of ideque removed. It is an error for ideque to be empty. Takes O(1) time.
(scheme ideque) procedure (ideque-add-front (ideque ideque?) obj ) ⟹ ideque?
Returns an ideque with obj pushed to the front of ideque. Takes O(1) time.
(scheme ideque) procedure (ideque-add-back (ideque ideque?) obj ) ⟹ ideque?
Returns an ideque with obj pushed to the back of ideque. Takes O(1) time.
(scheme ideque) procedure (ideque-ref (ideque ideque?) (n integer?) ) ⟹ *
Returns the nth element of ideque. It is an error unless n is less than the length of ideque. Takes O(n) time.
(scheme ideque) procedure (ideque-take (ideque ideque?) (n integer?) ) ⟹ ideque?
Returns an ideque containing the first n elements of ideque. It is an error if n is greater than the length of ideque. Takes O(n) time.
(scheme ideque) procedure (ideque-take-right (ideque ideque?) (n integer?) ) ⟹ ideque?
Returns an ideque containing the last n elements of ideque. It is an error if n is greater than the length of ideque. Takes O(n) time.
(scheme ideque) procedure (ideque-drop (ideque ideque?) (n integer?) ) ⟹ ideque?
Returns an ideque containing all but the first n elements of ideque. It is an error if n is greater than the length of ideque. Takes O(n) time.
(scheme ideque) procedure (ideque-drop-right (ideque ideque?) (n integer?) ) ⟹ ideque?
Returns an ideque containing all but the last n elements of ideque. It is an error if n is greater than the length of ideque. Takes O(n) time.
(scheme ideque) procedure (ideque-split-at (ideque ideque?) (n integer?) ) ⟹ (values ideque?ideque?)
Returns two values, the results of (ideque-take ideque n) and (ideque-drop ideque n) respectively, but may be more efficient. Takes O(n) time.
(scheme ideque) procedure (ideque-length (ideque ideque?) ) ⟹ integer?
Returns the length of ideque as an exact integer. May take O(n) time, though O(1) is optimal.
(scheme ideque) procedure (ideque-append (ideque ideque?) ... ) ⟹ ideque?
Returns an ideque with the contents of the ideque followed by the others, or an empty ideque if there are none. Takes O(kn) time, where k is the number of ideques and n is the number of elements involved, though O(k log n) is possible.
(scheme ideque) procedure (ideque-reverse (ideque ideque?) ) ⟹ ideque?
Returns an ideque containing the elements of ideque in reverse order. Takes O(1) time.
(scheme ideque) procedure (ideque-count (pred procedure?) (ideque ideque?) ) ⟹ integer?
(pred element ) ⟹ boolean?
Pred is a procedure taking a single value and returning a single value. It is applied element-wise to the elements of ideque, and a count is tallied of the number of elements that produce a true value. This count is returned. Takes O(n) time. The dynamic order of calls to pred is unspecified.
(scheme ideque) procedure (ideque-zip (ideque1 ideque?) (ideque2 ideque?) ... ) ⟹ ideque?
Returns an ideque of lists (not ideques) each of which contains the corresponding elements of ideques in the order specified. Terminates when all the elements of any of the ideques have been processed. Takes O(kn) time, where k is the number of ideques and n is the number of elements in the shortest ideque.
(scheme ideque) procedure (ideque-map (proc procedure?) (ideque ideque?) ) ⟹ ideque?
(proc element ) ⟹ *
Applies proc to the elements of ideque and returns an ideque containing the results in order. The dynamic order of calls to proc is unspecified. Takes O(n) time.
(scheme ideque) procedure (ideque-filter-map (proc procedure?) (ideque ideque?) ) ⟹ ideque?
(proc element ) ⟹ *
Applies proc to the elements of ideque and returns an ideque containing the true (i.e. non-#f) results in order. The dynamic order of calls to proc is unspecified. Takes O(n) time.
(scheme ideque) procedure (ideque-for-each (proc procedure?) (ideque ideque?) ) ⟹ undefined
(proc element ) ⟹ undefined
Applies proc to the elements of ideque in forward order and returns an unspecified result. Takes O(n) time.
(scheme ideque) procedure (ideque-for-each-right (proc procedure?) (ideque ideque?) ) ⟹ undefined
(proc element ) ⟹ undefined
Applies proc to the elements of ideque in reverse order and returns an unspecified result. Takes O(n) time.
(scheme ideque) procedure (ideque-fold (proc procedure?) nil (ideque ideque?) ) ⟹ *
(proc element state ) ⟹ *
Invokes proc on the elements of ideque in forward order, passing the result of the previous invocation as a second argument. For the first invocation, nil is used as the second argument. Returns the result of the last invocation, or nil if there was no invocation. Takes O(n) time.
(scheme ideque) procedure (ideque-fold-right (proc procedure?) nil (ideque ideque?) ) ⟹ *
(proc element state ) ⟹ *
Invokes proc on the elements of ideque in reverse order, passing the result of the previous invocation as a second argument. For the first invocation, nil is used as the second argument. Returns the result of the last invocation, or nil if there was no invocation. Takes O(n) time.
(scheme ideque) procedure (ideque-append-map (proc procedure?) (ideque ideque?) ) ⟹ ideque?
(proc element ) ⟹ list?
Applies proc to the elements of ideque. It is an error if the result is not a list. Returns an ideque containing the elements of the lists in order. Takes O(n) time, where n is the number of elements in all the lists returned.
(scheme ideque) procedure (ideque-filter (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque containing the elements of ideque that do satisfy pred. Takes O(n) time.
(scheme ideque) procedure (ideque-remove (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque containing the elements of ideque that do not satisfy pred. Takes O(n) time.
(scheme ideque) procedure (ideque-partition (pred procedure?) (ideque ideque?) ) ⟹ (values ideque?ideque?)
(pred element ) ⟹ boolean?
Returns two values, the results of (ideque-filter pred ideque) and (ideque-remove pred ideque) respectively, but may be more efficient. Takes O(n) time.
(scheme ideque) procedure (ideque-find (pred procedure?) (ideque ideque?) ) ⟹ *
(scheme ideque) procedure (ideque-find (pred procedure?) (ideque ideque?) (failure procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(failure ) ⟹ *
Returns the first element of ideque that satisfies pred. If there is no such element, returns the result of invoking the thunk failure; the default thunk is (lambda () #f). Takes O(n) time.
(scheme ideque) procedure (ideque-find-right (pred procedure?) (ideque ideque?) ) ⟹ *
(scheme ideque) procedure (ideque-find-right (pred procedure?) (ideque ideque?) (failure procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(failure ) ⟹ *
Returns the last element of ideque that satisfies pred. If there is no such element, returns the result of invoking the thunk failure; the default thunk is (lambda () #f). Takes O(n) time.
(scheme ideque) procedure (ideque-take-while (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque containing the longest initial prefix of elements in ideque all of which satisfy pred. Takes O(n) time.
(scheme ideque) procedure (ideque-take-while-right (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque containing the longest final prefix of elements in ideque all of which satisfy pred. Takes O(n) time.
(scheme ideque) procedure (ideque-drop-while (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque which omits the longest initial prefix of elements in ideque all of which satisfy pred, but includes all other elements of ideque. Takes O(n) time.
(scheme ideque) procedure (ideque-drop-while-right (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque which omits the longest final prefix of elements in ideque all of which satisfy pred, but includes all other elements of ideque. Takes O(n) time.
(scheme ideque) procedure (ideque-span (pred procedure?) (ideque ideque?) ) ⟹ (values ideque?ideque?)
(pred element ) ⟹ boolean?
Returns two values, the initial prefix of the elements of ideque which do satisfy pred, and the remaining elements. Takes O(n) time.
(scheme ideque) procedure (ideque-break (pred procedure?) (ideque ideque?) ) ⟹ (values ideque?ideque?)
(pred element ) ⟹ boolean?
Returns two values, the initial prefix of the elements of ideque which do not satisfy pred, and the remaining elements. Takes O(n) time.
(scheme ideque) procedure (list->ideque (list list?) ) ⟹ ideque?
(shared description for list->ideque, ideque->list) Conversion between ideque and list structures. FIFO order is preserved, so the front of a list corresponds to the front of an ideque. Each operation takes O(n) time.
(scheme ideque) procedure (ideque->list (ideque ideque?) ) ⟹ list?
(shared description for list->ideque, ideque->list) Conversion between ideque and list structures. FIFO order is preserved, so the front of a list corresponds to the front of an ideque. Each operation takes O(n) time.
(scheme ideque) procedure (generator->ideque (generator procedure?) ) ⟹ ideque?
(generator ) ⟹ *
(shared description for generator->ideque, ideque->generator) Conversion between SRFI 121 generators and ideques. Each operation takes O(n) time. A generator is a procedure that is called repeatedly with no arguments to generate consecutive values, and returns an end-of-file object when it has no more values to return.
(scheme ideque) procedure (ideque->generator (ideque ideque?) ) ⟹ procedure?
(return ) ⟹ *
(shared description for generator->ideque, ideque->generator) Conversion between SRFI 121 generators and ideques. Each operation takes O(n) time. A generator is a procedure that is called repeatedly with no arguments to generate consecutive values, and returns an end-of-file object when it has no more values to return.
library (scheme ilist)
(scheme ilist) syntax (iq () ((_ datum ...) ilist? ) )
iq is partly analogous to quote, taking an arbitrary number of literals and constructing an ilist from them, with any pairs in the literals converted to ipairs. It is useful for providing constant ipair-based objects. Note that pairs within literal vectors or other implementation-dependent literals will not be converted. Unfortunately, there is no ilist analogue of ', so we save keystrokes by using iq rather than iquote and omitting the top-level parentheses.
(scheme ilist) procedure (ipair a d ) ⟹ ipair?
The primitive constructor. Returns a newly allocated ipair whose icar is a and whose icdr is d. The ipair is guaranteed to be different (in the sense of eqv?) from every existing object.
(scheme ilist) procedure (ilist object ... ) ⟹ ilist?
Returns a newly allocated ilist of its arguments.
(scheme ilist) procedure (xipair d a ) ⟹ ipair?
(lambda (d a) (ipair a d))
Of utility only as a value to be conveniently passed to higher-order procedures.
(scheme ilist) procedure (ipair* elt1 elt2 ... ) ⟹ *
Like ilist, but the last argument provides the tail of the constructed ilist
(scheme ilist) procedure (make-ilist (n integer?) ) ⟹ ilist?
(scheme ilist) procedure (make-ilist (n integer?) fill ) ⟹ ilist?
Returns an n-element ilist, whose elements are all the value fill. If the fill argument is not given, the elements of the ilist may be arbitrary values.
(scheme ilist) procedure (ilist-tabulate (n integer?) (init-proc procedure?) ) ⟹ ilist?
(init-proc (i integer?) ) ⟹ *
Returns an n-element ilist. Element i of the ilist, where 0 <= i < n, is produced by (init-proc i). No guarantee is made about the dynamic order in which init-proc is applied to these indices.
(scheme ilist) procedure (ilist-copy (dilist ilist?) ) ⟹ ilist?
(scheme ilist) procedure (ilist-copy (dilist dotted-ilist?) ) ⟹ dotted-ilist?
Copies the spine of the argument, including the ilist tail.
(scheme ilist) procedure (iiota (count integer?) ) ⟹ ilist?
(scheme ilist) procedure (iiota (count integer?) (start number?) ) ⟹ ilist?
(scheme ilist) procedure (iiota (count integer?) (start number?) (step number?) ) ⟹ ilist?
Returns an ilist containing the elements
(start start+step ... start+(count-1)*step)
The start and step parameters default to 0 and 1, respectively. This procedure takes its name from the APL primitive.
(scheme ilist) procedure (proper-ilist? obj ) ⟹ boolean?
(scheme ilist) procedure (ilist? obj ) ⟹ boolean?
These identifiers are bound either to the same procedure, or to procedures of equivalent behavior. In either case, true is returned iff x is a proper ilist — a ()-terminated ilist.
More carefully: The empty list is a proper ilist. An ipair whose icdr is a proper ilist is also a proper ilist. Everything else is a dotted ilist. This includes non-ipair, non-() values (e.g. symbols, numbers, mutable pairs), which are considered to be dotted ilists of length 0.
(scheme ilist) procedure (dotted-ilist? obj ) ⟹ boolean?
True if x is a finite, non-nil-terminated ilist. That is, there exists an n >= 0 such that icdrn(x) is neither an ipair nor (). This includes non-ipair, non-() values (e.g. symbols, numbers), which are considered to be dotted ilists of length 0.
(scheme ilist) procedure (ipair? obj ) ⟹ boolean?
Returns #t if object is an ipair; otherwise, #f.
(scheme ilist) procedure (null-ilist? (lst ilist?) ) ⟹ boolean?
Ilist is a proper ilist. This procedure returns true if the argument is the empty list (), and false otherwise. It is an error to pass this procedure a value which is not a proper ilist. This procedure is recommended as the termination condition for ilist-processing procedures that are not defined on dotted ilists.
(scheme ilist) procedure (not-ipair? obj ) ⟹ boolean?
(lambda (x) (not (ipair? x)))
Provided as a procedure as it can be useful as the termination condition for ilist-processing procedures that wish to handle all ilists, both proper and dotted.
(scheme ilist) procedure (ilist= (elt= procedure?) (ilist1 ilist?) ... ) ⟹ boolean?
(elt= a b ) ⟹ *
Determines ilist equality, given an element-equality procedure. Proper ilist A equals proper ilist B if they are of the same length, and their corresponding elements are equal, as determined by elt=. If the element-comparison procedure's first argument is from ilisti, then its second argument is from ilisti+1, i.e. it is always called as (elt= a b) for a an element of ilist A, and b an element of ilist B.
In the n-ary case, every ilisti is compared to ilisti+1 (as opposed, for example, to comparing ilist1 to ilisti, for i>1). If there are no ilist arguments at all, ilist= simply returns true.
It is an error to apply ilist= to anything except proper ilists. It cannot reasonably be extended to dotted ilists, as it provides no way to specify an equality procedure for comparing the ilist terminators.
Note that the dynamic order in which the elt= procedure is applied to pairs of elements is not specified. For example, if ilist= is applied to three ilists, A, B, and C, it may first completely compare A to B, then compare B to C, or it may compare the first elements of A and B, then the first elements of B and C, then the second elements of A and B, and so forth.
The equality procedure must be consistent with eq?. That is, it must be the case that
(eq? x y) => (elt= x y).
Note that this implies that two ilists which are eq? are always ilist=, as well; implementations may exploit this fact to "short-cut" the element-by-element comparisons.
(scheme ilist) procedure (icar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdr (ipair ipair?) ) ⟹ *
These procedures return the contents of the icar and icdr field of their argument, respectively. Note that it is an error to apply them to the empty ilist.
(scheme ilist) procedure (icaar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icadr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icddr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icaaaar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icaaadr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icaaar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icaadar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icaaddr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icaadr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icadaar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icadadr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icadar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icaddar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icadddr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icaddr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdaaar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdaadr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdaar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdadar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdaddr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdadr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icddaar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icddadr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icddar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdddar (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icddddr (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (icdddr (ipair ipair?) ) ⟹ *
These procedures are compositions of icar and icdr, where for example icaddr could be defined by
(define icaddr (lambda (x) (icar (icdr (icdr x))))).
Arbitrary compositions, up to four deep, are provided. There are twenty-eight of these procedures in all.
(scheme ilist) procedure (ilist-ref (ilist ilist?) (i integer?) ) ⟹ *
Returns the ith element of ilist. (This is the same as the icar of (idrop ilist i).) It is an error if i >= n, where n is the length of ilist.
(scheme ilist) procedure (ifirst (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (isecond (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (ithird (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (ifourth (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (ififth (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (isixth (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (iseventh (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (ieighth (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (ininth (ipair ipair?) ) ⟹ *
(scheme ilist) procedure (itenth (ipair ipair?) ) ⟹ *
Synonyms for car, cadr, caddr, ...
(scheme ilist) procedure (icar+icdr (ipair ipair?) ) ⟹ (values **)
The fundamental ipair deconstructor:
(lambda (p) (values (icar p) (icdr p)))
This can, of course, be implemented more efficiently by a compiler.
(scheme ilist) procedure (itake (x ilist?) (i integer?) ) ⟹ ilist?
(scheme ilist) procedure (itake (x dotted-ilist?) (i integer?) ) ⟹ ilist?
itake returns the first i elements of ilist x.
(scheme ilist) procedure (idrop (x ilist?) (i integer?) ) ⟹ ilist?
(scheme ilist) procedure (idrop (x dotted-ilist?) (i integer?) ) ⟹ *
(scheme ilist) procedure (ilist-tail (x ilist?) (i integer?) ) ⟹ ilist?
(scheme ilist) procedure (ilist-tail (x dotted-ilist?) (i integer?) ) ⟹ *
idrop / ilist-tail returns all but the first i elements of ilist x.
(scheme ilist) procedure (itake-right (dilist ilist?) (i integer?) ) ⟹ ilist?
(scheme ilist) procedure (itake-right (dilist dotted-ilist?) (i integer?) ) ⟹ *
itake-right returns the last i elements of dilist.
(scheme ilist) procedure (idrop-right (dilist ilist?) (i integer?) ) ⟹ ilist?
(scheme ilist) procedure (idrop-right (dilist dotted-ilist?) (i integer?) ) ⟹ ilist?
idrop-right returns all but the last i elements of dilist.
(scheme ilist) procedure (isplit-at (x ilist?) (i integer?) ) ⟹ (values ilist?ilist?)
(scheme ilist) procedure (isplit-at (x dotted-ilist?) (i integer?) ) ⟹ (values ilist?*)
isplit-at splits the ilist x at index i, returning an ilist of the first i elements, and the remaining tail. It is equivalent to
(values (itake x i) (idrop x i))
(scheme ilist) procedure (ilast (ipair ilist?) ) ⟹ *
Returns the last element of the non-empty, possibly dotted, ilist ipair.
(scheme ilist) procedure (last-ipair (ipair ilist?) ) ⟹ ipair?
last-ipair returns the last ipair in the non-empty ilist pair.
(scheme ilist) procedure (ilength (ilist ilist?) ) ⟹ integer?
Returns the length of its argument. It is an error to pass a value to ilength which is not a proper ilist (()-terminated).
The length of a proper ilist is a non-negative integer n such that icdr applied n times to the ilist produces the empty list.
(scheme ilist) procedure (iappend (ilist ilist?) ... ) ⟹ ilist?
(scheme ilist) procedure (iappend (ilist ilist?) ... obj ) ⟹ *
Returns an ilist consisting of the elements of ilist1 followed by the elements of the other ilist parameters.
The resulting ilist is always newly allocated, except that it shares structure with the final ilisti argument. This last argument may be any value at all; an improper ilist results if it is not a proper ilist. All other arguments must be proper ilists.
(scheme ilist) procedure (iconcatenate (ilist-of-ilists ilist?) ) ⟹ *
Appends the elements of its argument together. That is, iconcatenate returns
(iapply iappend ilist-of-ilists)
or, equivalently,
(ireduce-right iappend '() ilist-of-ilists)
Note that some Scheme implementations do not support passing more than a certain number (e.g., 64) of arguments to an n-ary procedure. In these implementations, the (iapply iappend ...) idiom would fail when applied to long lists, but iconcatenate would continue to function properly.
As with iappend, the last element of the input list may be any value at all.
(scheme ilist) procedure (ireverse (ilist ilist?) ) ⟹ ilist?
Returns a newly allocated ilist consisting of the elements of ilist in reverse order.
(scheme ilist) procedure (iappend-reverse (rev-head ilist?) (tail ilist?) ) ⟹ ilist?
(scheme ilist) procedure (iappend-reverse (rev-head ilist?) tail ) ⟹ *
iappend-reverse returns (iappend (ireverse rev-head) tail). It is provided because it is a common operation — a common list-processing style calls for this exact operation to transfer values accumulated in reverse order onto the front of another ilist, and because the implementation is significantly more efficient than the simple composition it replaces. (But note that this pattern of iterative computation followed by a reverse can frequently be rewritten as a recursion, dispensing with the reverse and iappend-reverse steps, and shifting temporary, intermediate storage from the heap to the stack, which is typically a win for reasons of cache locality and eager storage reclamation.)
(scheme ilist) procedure (izip (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(lambda ilists (iapply imap ilist ilists))
If izip is passed n ilists, it returns an ilist as long as the shortest of these ilists, each element of which is an n-element ilist comprised of the corresponding elements from the parameter ilists.
(scheme ilist) procedure (iunzip1 (ilist ilist?) ) ⟹ ilist?
(scheme ilist) procedure (iunzip2 (ilist ilist?) ) ⟹ (values ilist?ilist?)
(scheme ilist) procedure (iunzip3 (ilist ilist?) ) ⟹ (values ilist?ilist?ilist?)
(scheme ilist) procedure (iunzip4 (ilist ilist?) ) ⟹ (values ilist?ilist?ilist?ilist?)
(scheme ilist) procedure (iunzip5 (ilist ilist?) ) ⟹ (values ilist?ilist?ilist?ilist?ilist?)
iunzip1 takes an ilist of ilists, where every ilist must contain at least one element, and returns an ilist containing the initial element of each such ilist. That is, it returns (imap icar ilists). iunzip2 takes an ilist of ilists, where every ilist must contain at least two elements, and returns two values: an ilist of the first elements, and an ilist of the second elements. iunzip3 does the same for the first three elements of the ilists, and so forth.
(scheme ilist) procedure (icount (pred procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ integer?
(pred obj ... ) ⟹ *
pred is a procedure taking as many arguments as there are ilists and returning a single value. It is applied element-wise to the elements of the ilists, and a count is tallied of the number of elements that produce a true value. This count is returned. count is "iterative" in that it is guaranteed to apply pred to the ilist elements in a left-to-right order. The counting stops when the shortest ilist expires.
(scheme ilist) procedure (ifold (kons procedure?) knil (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(kons obj1 obj2 ... fold-state ) ⟹ *
The fundamental ilist iterator.
First, consider the single ilist-parameter case. If ilist1 = (e1 e2 ... en), then this procedure returns
(kons en ... (kons e2 (kons e1 knil)) ... )
If n ilist arguments are provided, then the kons function must take n+1 parameters: one element from each ilist, and the "seed" or fold state, which is initially knil. The fold operation terminates when the shortest ilist runs out of values
(scheme ilist) procedure (ifold-right (kons procedure?) knil (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(kons obj1 obj2 ... fold-state ) ⟹ *
The fundamental ilist recursion operator.
First, consider the single ilist-parameter case. If ilist1 = (e1 e2 ... en), then this procedure returns
(kons e1 (kons e2 ... (kons en knil)))
If n ilist arguments are provided, then the kons procedure must take n+1 parameters: one element from each ilist, and the "seed" or fold state, which is initially knil. The fold operation terminates when the shortest ilist runs out of values
(scheme ilist) procedure (ipair-fold (kons procedure?) knil (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(kons (ipair1 ipair?) (ipair2 ipair?) ... fold-state ) ⟹ *
Analogous to fold, but kons is applied to successive sub-ilists of the ilists, rather than successive elements — that is, kons is applied to the ipairs making up the lists.
(scheme ilist) procedure (ipair-fold-right (kons procedure?) knil (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(kons (ipair1 ipair?) (ipair2 ipair?) ... fold-state ) ⟹ *
Holds the same relationship with ifold-right that ipair-fold holds with ifold.
(scheme ilist) procedure (ireduce (f procedure?) ridentity (ilist ilist?) ) ⟹ *
(f obj fold-state ) ⟹ *
ireduce is a variant of ifold.
ridentity should be a "right identity" of the procedure f - that is, for any value x acceptable to f,
(f x ridentity) = x
ireduce has the following definition:
If ilist = (), return ridentity;
Otherwise, return (ifold f (icar ilist) (icdr ilist)).
...in other words, we compute (ifold f ridentity ilist).
Note that ridentity is used only in the empty-list case. You typically use ireduce when applying f is expensive and you'd like to avoid the extra application incurred when ifold applies f to the head of ilist and the identity value, redundantly producing the same value passed in to f. For example, if f involves searching a file directory or performing a database query, this can be significant. In general, however, ifold is useful in many contexts where ireduce is not (consider the examples given in the ifold definition — only one of the five folds uses a function with a right identity. The other four may not be performed with ireduce).
(scheme ilist) procedure (ireduce-right (f procedure?) ridentity (ilist ilist?) ) ⟹ *
(f obj fold-state ) ⟹ *
ireduce-right is the fold-right variant of ireduce. It obeys the following definition:
(ireduce-right f ridentity '()) = ridentity
(ireduce-right f ridentity (iq e1)) = (f e1 ridentity) = e1
(ireduce-right f ridentity (iq e1 e2 ...)) =
(f e1 (ireduce f ridentity (e2 ...)))
...in other words, we compute (ifold-right f ridentity ilist).
(scheme ilist) procedure (iunfold (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ ilist?
(scheme ilist) procedure (iunfold (p procedure?) (f procedure?) (g procedure?) seed (tail-gen ilist?) ) ⟹ *
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(tail-gen ) ⟹ *
iunfold is best described by its basic recursion:
(iunfold p f g seed) =
(if (p seed) (tail-gen seed)
(ipair (f seed)
(iunfold p f g (g seed))))
p: Determines when to stop unfolding.
f: Maps each seed value to the corresponding ilist element.
g: Maps each seed value to next seed value.
seed: The "state" value for the unfold.
tail-gen: Creates the tail of the ilist; defaults to (lambda (x) '())
In other words, we use g to generate a sequence of seed values
seed, g(seed), g^2(seed), g^3(seed), ...
These seed values are mapped to ilist elements by f, producing the elements of the result ilist in a left-to-right order. P says when to stop.
(scheme ilist) procedure (iunfold-right (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ ilist?
(scheme ilist) procedure (iunfold-right (p procedure?) (f procedure?) (g procedure?) seed (tail-gen ilist?) ) ⟹ *
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(tail-gen ) ⟹ *
iunfold-right constructs an ilist with the following loop:
(let lp ((seed seed) (lis tail))
(if (p seed) lis
(lp (g seed)
(ipair (f seed) lis))))
p: Determines when to stop unfolding.
f: Maps each seed value to the corresponding ilist element.
g: Maps each seed value to next seed value.
seed: The "state" value for the unfold.
tail: ilist terminator; defaults to '().
In other words, we use g to generate a sequence of seed values
seed, g(seed), g2(seed), g3(seed), ...
These seed values are mapped to ilist elements by f, producing the elements of the result ilist in a right-to-left order. P says when to stop.
(scheme ilist) procedure (imap (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(proc obj1 obj2 ... ) ⟹ *
proc is a procedure taking as many arguments as there are ilist arguments and returning a single value. imap applies proc element-wise to the elements of the ilists and returns an ilist of the results, in order. The dynamic order in which proc is applied to the elements of the ilists is unspecified.
(scheme ilist) procedure (ifor-each (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ undefined
(proc obj1 obj2 ... ) ⟹ undefined
The arguments to ifor-each are like the arguments to imap, but ifor-each calls proc for its side effects rather than for its values. Unlike imap, ifor-each is guaranteed to call proc on the elements of the ilists in order from the first element(s) to the last, and the value returned by ifor-each is unspecified.
(scheme ilist) procedure (iappend-map (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(proc obj1 obj2 ... ) ⟹ ilist?
Equivalent to
(iapply iappend (imap f ilist1 ilist2 ...))
and
(iapply iappend (imap f ilist1 ilist2 ...))
Map f over the elements of the ilists, just as in the imap function. However, the results of the applications are appended together (using iappend) to make the final result.
The dynamic order in which the various applications of f are made is not specified.
(scheme ilist) procedure (imap-in-order (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(proc obj1 obj2 ... ) ⟹ *
A variant of the imap procedure that guarantees to apply f across the elements of the ilisti arguments in a left-to-right order. This is useful for mapping procedures that both have side effects and return useful values.
(scheme ilist) procedure (ipair-for-each (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ undefined
(proc (obj1 ipair?) (obj2 ipair?) ... ) ⟹ undefined
Like ifor-each, but f is applied to successive sub-ilists of the argument ilists. That is, f is applied to the cells of the ilists, rather than the ilists' elements. These applications occur in left-to-right order.
(scheme ilist) procedure (ifilter-map (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(proc obj1 obj2 ... ) ⟹ *
Like imap, but only true values are saved.
(scheme ilist) procedure (ifilter (pred procedure?) (ilist ilist?) ) ⟹ ilist?
(pred obj ) ⟹ *
Return all the elements of ilist that satisfy predicate pred. The ilist is not disordered — elements that appear in the result ilist occur in the same order as they occur in the argument ilist. The returned ilist may share a common tail with the argument ilist. The dynamic order in which the various applications of pred are made is not specified.
(scheme ilist) procedure (ipartition (pred procedure?) (ilist ilist?) ) ⟹ (values ilist?ilist?)
(pred obj ) ⟹ *
Partitions the elements of ilist with predicate pred, and returns two values: the ilist of in-elements and the ilist of out-elements. The ilist is not disordered — elements occur in the result ilists in the same order as they occur in the argument ilist. The dynamic order in which the various applications of pred are made is not specified. One of the returned ilists may share a common tail with the argument ilist.
(scheme ilist) procedure (iremove (pred procedure?) (ilist ilist?) ) ⟹ ilist?
(pred obj ) ⟹ *
Returns ilist without the elements that satisfy predicate pred:
(lambda (pred ilist) (ifilter (lambda (x) (not (pred x))) ilist))
The ilist is not disordered — elements that appear in the result ilist occur in the same order as they occur in the argument ilist. The returned ilist may share a common tail with the argument ilist. The dynamic order in which the various applications of pred are made is not specified.
(scheme ilist) procedure (ifind (pred procedure?) (ilist ilist?) ) ⟹ *
(pred obj ) ⟹ *
Return the first element of ilist that satisfies predicate pred; false if no element does.
(ifind even? (iq 3 1 4 1 5 9)) => 4
Note that ifind has an ambiguity in its lookup semantics — if ifind returns #f, you cannot tell (in general) if it found a #f element that satisfied pred, or if it did not find any element at all. In many situations, this ambiguity cannot arise — either the ilist being searched is known not to contain any #f elements, or the ilist is guaranteed to have an element satisfying pred. However, in cases where this ambiguity can arise, you should use ifind-tail instead of ifind — ifind-tail has no such ambiguity
(scheme ilist) procedure (ifind-tail (pred procedure?) (ilist ilist?) ) ⟹ ipair? / #f /
(pred obj ) ⟹ *
Return the first ipair of ilist whose icar satisfies pred. If no ipair does, return false.
ifind-tail can be viewed as a general-predicate variant of the imember function.
Ifind-tail is essentially idrop-while, where the sense of the predicate is inverted: Ifind-tail searches until it finds an element satisfying the predicate; idrop-while searches until it finds an element that doesn't satisfy the predicate.
(scheme ilist) procedure (itake-while (pred procedure?) (ilist ilist?) ) ⟹ ilist?
(pred obj ) ⟹ *
Returns the longest initial prefix of ilist whose elements all satisfy the predicate pred.
(scheme ilist) procedure (idrop-while (pred procedure?) (ilist ilist?) ) ⟹ ilist?
(pred obj ) ⟹ *
idrops the longest initial prefix of ilist whose elements all satisfy the predicate pred, and returns the rest of the ilist.
(scheme ilist) procedure (ispan (pred procedure?) (ilist ilist?) ) ⟹ (values ilist?ilist?)
(pred obj ) ⟹ *
(scheme ilist) procedure (ibreak (pred procedure?) (ilist ilist?) ) ⟹ (values ilist?ilist?)
(pred obj ) ⟹ *
ispan splits the ilist into the longest initial prefix whose elements all satisfy pred, and the remaining tail. ibreak inverts the sense of the predicate: the tail commences with the first element of the input ilist that satisfies the predicate.
In other words: ispan finds the initial span of elements satisfying pred, and ibreak breaks the ilist at the first element satisfying pred.
(scheme ilist) procedure (iany (pred procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(pred obj1 obj2 ... ) ⟹ *
Applies the predicate across the ilists, returning true if the predicate returns true on any application.
If there are n ilist arguments ilist1 ... ilistn, then pred must be a procedure taking n arguments and returning a boolean result.
iany applies pred to the first elements of the ilisti parameters. If this application returns a true value, iany immediately returns that value. Otherwise, it iterates, applying pred to the second elements of the ilisti parameters, then the third, and so forth. The iteration stops when a true value is produced or one of the ilists runs out of values; in the latter case, iany returns #f. The application of pred to the last element of the ilists is a tail call.
Note the difference between ifind and iany — ifind returns the element that satisfied the predicate; iany returns the true value that the predicate produced.
Like ievery, iany's name does not end with a question mark — this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(scheme ilist) procedure (ievery (pred procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(pred obj1 obj2 ... ) ⟹ *
Applies the predicate across the ilists, returning true if the predicate returns true on every application.
If there are n ilist arguments ilist1 ... ilistn, then pred must be a procedure taking n arguments and returning a boolean result.
ievery applies pred to the first elements of the ilisti parameters. If this application returns false, ievery immediately returns false. Otherwise, it iterates, applying pred to the second elements of the ilisti parameters, then the third, and so forth. The iteration stops when a false value is produced or one of the ilists runs out of values. In the latter case, ievery returns the true value produced by its final application of pred. The application of pred to the last element of the ilists is a tail call.
If one of the ilisti has no elements, ievery simply returns #t.
Like iany, ievery's name does not end with a question mark — this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(scheme ilist) procedure (ilist-index (pred procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ integer? / #f /
(pred obj1 obj2 ... ) ⟹ *
Return the index of the leftmost element that satisfies pred.
If there are n ilist arguments ilist1 ... ilistn, then pred must be a function taking n arguments and returning a boolean result.
ilist-index applies pred to the first elements of the ilisti parameters. If this application returns true, ilist-index immediately returns zero. Otherwise, it iterates, applying pred to the second elements of the ilisti parameters, then the third, and so forth. When it finds a tuple of ilist elements that cause pred to return true, it stops and returns the zero-based index of that position in the ilists.
The iteration stops when one of the ilists runs out of values; in this case, ilist-index returns #f.
(scheme ilist) procedure (imember obj (ilist ilist?) ) ⟹ #f / ilist? /
(scheme ilist) procedure (imember obj (ilist ilist?) (= procedure?) ) ⟹ #f / ilist? /
(= obj1 obj2 ) ⟹ *
(scheme ilist) procedure (imemq obj (ilist ilist?) ) ⟹ #f / ilist? /
(scheme ilist) procedure (imemv obj (ilist ilist?) ) ⟹ #f / ilist? /
These procedures return the first sub-ilist of ilist whose icar is x, where the sub-ilists of ilist are the non-empty ilists returned by (idrop ilist i) for i less than the length of ilist. If x does not occur in ilist, then #f is returned. imemq uses eq? to compare x with the elements of ilist, while imemv uses eqv?, and imember uses equal?.
The comparison procedure is used to compare the elements ei of ilist to the key x in this way:
(= x ei) ; ilist is (E1 ... En)
That is, the first argument is always x, and the second argument is one of the ilist elements.
(scheme ilist) procedure (idelete obj (ilist ilist?) ) ⟹ ilist?
(scheme ilist) procedure (idelete obj (ilist ilist?) (= procedure?) ) ⟹ ilist?
(= obj1 obj2 ) ⟹ *
idelete uses the comparison procedure =, which defaults to equal?, to find all elements of ilist that are equal to x, and deletes them from ilist. The dynamic order in which the various applications of = are made is not specified.
The ilist is not disordered — elements that appear in the result ilist occur in the same order as they occur in the argument ilist. The result may share a common tail with the argument ilist.
The comparison procedure is used in this way: (= x ei). That is, x is always the first argument, and an ilist element is always the second argument. The comparison procedure will be used to compare each element of ilist exactly once; the order in which it is applied to the various ei is not specified.
(scheme ilist) procedure (idelete-duplicates (ilist ilist?) ) ⟹ ilist?
(scheme ilist) procedure (idelete-duplicates (ilist ilist?) (= procedure?) ) ⟹ ilist?
(= obj1 obj2 ) ⟹ *
idelete-duplicates removes duplicate elements from the ilist argument. If there are multiple equal elements in the argument ilist, the result ilist only contains the first or leftmost of these elements in the result. The order of these surviving elements is the same as in the original ilist — idelete-duplicates does not disorder the ilist (hence it is useful for "cleaning up" immutable association lists).
The = parameter is used to compare the elements of the ilist; it defaults to equal?. If x comes before y in ilist, then the comparison is performed (= x y). The comparison procedure will be used to compare each pair of elements in ilist no more than once; the order in which it is applied to the various pairs is not specified.
Implementations of idelete-duplicates are allowed to share common tails between argument and result ilists — for example, if the ilist argument contains only unique elements, it may simply return exactly this ilist.
Be aware that, in general, idelete-duplicates runs in time O(n2) for n-element ilists. Uniquifying long ilists can be accomplished in O(n lg n) time by sorting the ilist to bring equal elements together, then using a linear-time algorithm to remove equal elements. Alternatively, one can use algorithms based on element-marking, with linear-time results.
(scheme ilist) procedure (iassoc obj (ialist ilist?) ) ⟹ ilist? / #f /
(scheme ilist) procedure (iassoc obj (ialist ilist?) (= procedure?) ) ⟹ ipair? / #f /
(= a b ) ⟹ *
(scheme ilist) procedure (iassq obj (ialist ilist?) ) ⟹ ipair? / #f /
(scheme ilist) procedure (iassv obj (ialist ilist?) ) ⟹ ipair? / #f /
ialist must be an immutable association list — an ilist of ipairs. These procedures find the first ipair in ialist whose icar field is key, and returns that ipair. If no ipair in ialist has key as its icar, then #f is returned. iassq uses eq? to compare key with the icar fields of the ipairs in ialist, while iassv uses eqv? and iassoc uses equal?.
The comparison procedure is used to compare the elements ei of ilist to the key parameter in this way:
(= key (icar ei)) ; ilist is (E1 ... En)
That is, the first argument is always key, and the second argument is one of the ilist elements.
(scheme ilist) procedure (ialist-cons key datum (ialist ilist?) ) ⟹ ilist?
(lambda (key datum ialist) (ipair (ipair key datum) ialist))
Construct a new ialist entry mapping key -> datum onto ialist.
(scheme ilist) procedure (ialist-delete key (ialist ilist?) ) ⟹ ilist?
(scheme ilist) procedure (ialist-delete key (ialist ilist?) (= procedure?) ) ⟹ ilist?
(= a b ) ⟹ *
ialist-delete deletes all associations from ialist with the given key, using key-comparison procedure =, which defaults to equal?. The dynamic order in which the various applications of = are made is not specified.
Return values may share common tails with the ialist argument. The ialist is not disordered — elements that appear in the result ialist occur in the same order as they occur in the argument ialist.
The comparison procedure is used to compare the element keys ki of ialist's entries to the key parameter in this way: (= key ki)
(scheme ilist) procedure (replace-icar (ipair ipair?) object ) ⟹ ipair?
This procedure returns an ipair with object in the icar field and the icdr of ipair in the icdr field.
(scheme ilist) procedure (replace-icdr (ipair ipair?) object ) ⟹ ipair?
This procedure returns an ipair with object in the icdr field and the icar of ipair in the icar field.
(scheme ilist) procedure (pair->ipair (pair pair?) ) ⟹ ipair?
(scheme ilist) procedure (ipair->pair (ipair ipair?) ) ⟹ pair?
These procedures, which are inverses, return an ipair and a pair respectively that have the same (i)car and (i)cdr fields as the argument.
(scheme ilist) procedure (list->ilist (flist list?) ) ⟹ ilist?
(scheme ilist) procedure (list->ilist (flist dotted-list?) ) ⟹ dotted-ilist?
(scheme ilist) procedure (ilist->list (flist ilist?) ) ⟹ list?
(scheme ilist) procedure (ilist->list (flist dotted-ilist?) ) ⟹ dotted-list?
These procedures return an ilist and a list respectively that have the same elements as the argument. The tails of dotted (i)lists are preserved in the result, which makes the procedures not inverses when the tail of a dotted ilist is a list or vice versa. The empty list is converted to itself.
It is an error to apply list->ilist to a circular list.
(scheme ilist) procedure (tree->itree (pair pair?) ) ⟹ ipair?
(scheme ilist) procedure (tree->itree object ) ⟹ *
(scheme ilist) procedure (itree->tree (ipair ipair?) ) ⟹ pair?
(scheme ilist) procedure (itree->tree object ) ⟹ *
These procedures walk a tree of pairs or ipairs respectively and make a deep copy of it, returning an isomorphic tree containing ipairs or pairs respectively. The result may share structure with the argument. If the argument is not of the expected type, it is returned.
These procedures are not inverses in the general case. For example, a pair of ipairs would be converted by tree->itree to an ipair of ipairs, which if converted by itree->tree would produce a pair of pairs.
(scheme ilist) procedure (gtree->itree (pair pair?) ) ⟹ ipair?
(scheme ilist) procedure (gtree->itree object ) ⟹ *
(scheme ilist) procedure (gtree->tree (ipair ipair?) ) ⟹ pair?
(scheme ilist) procedure (gtree->tree object ) ⟹ *
These procedures walk a generalized tree consisting of pairs, ipairs, or a combination of both, and make a deep copy of it, returning an isomorphic tree containing only ipairs or pairs respectively. The result may share structure with the argument. If the argument is neither a pair nor an ipair, it is returned.
(scheme ilist) procedure (iapply (proc procedure?) arg1 ... (args ilist?) ) ⟹ *
The iapply procedure is an analogue of apply whose last argument is an ilist rather than a list. It is equivalent to (apply procedure object ... (ilist->list ilist)), but may be implemented more efficiently.
ipair-comparator ⟹ comparator?
The ipair-comparator object is a SRFI-114 comparator suitable for comparing ipairs. Note that it is not a procedure. It compares pairs using default-comparator on their cars. If the cars are not equal, that value is returned. If they are equal, default-comparator is used on their cdrs and that value is returned.
ilist-comparator ⟹ comparator?
The ilist-comparator object is a SRFI-114 comparator suitable for comparing ilists. Note that it is not a procedure. It compares ilists lexicographically, as follows:
(scheme ilist) procedure (make-ilist-comparator (element-comparator comparator?) ) ⟹ comparator?
The make-ilist-comparator procedure returns a comparator suitable for comparing ilists using element-comparator to compare the elements.
(scheme ilist) procedure (make-improper-ilist-comparator (element-comparator comparator?) ) ⟹ comparator?
The make-improper-ilist-comparator procedure returns a comparator that compares arbitrary objects as follows: the empty list precedes all ipairs, which precede all other objects. Ipairs are compared as if with (make-ipair-comparator comparator comparator). All other objects are compared using comparator.
(scheme ilist) procedure (make-ipair-comparator (car-comparator comparator?) (cdr-comparator comparator?) ) ⟹ comparator?
Returns a comparator that compares ipairs first on their icars using icar-comparator. If the icars are equal, it compares the icdrs using icdr-comparator.
(scheme ilist) procedure (make-icar-comparator (comparator comparator?) ) ⟹ comparator?
The make-icar-comparator procedure returns a comparator that compares ipairs on their icars alone using comparator.
(scheme ilist) procedure (make-icdr-comparator (comparator comparator?) ) ⟹ comparator?
The make-icdr-comparator procedure returns a comparator that compares ipairs on their icdrs alone using comparator.
library (scheme list)
(scheme list) procedure (cons a d ) ⟹ pair?
The primitive constructor. Returns a newly allocated pair whose car is a and whose cdr is d. The pair is guaranteed to be different (in the sense of eqv?) from every existing object.
(scheme list) procedure (list object ... ) ⟹ list?
Returns a newly allocated list of its arguments.
(scheme list) procedure (xcons d a ) ⟹ pair?
(lambda (d a) (cons a d)) Of utility only as a value to be conveniently passed to higher-order procedures.
(scheme list) procedure (cons* elt1 elt2 ... ) ⟹ *
Like list, but the last argument provides the tail of the constructed list, returning (cons elt1 (cons elt2 (cons ... eltn))). This function is called list* in Common Lisp and about half of the Schemes that provide it, and cons* in the other half.
(scheme list) procedure (make-list (n integer?) ) ⟹ list?
(scheme list) procedure (make-list (n integer?) fill ) ⟹ list?
Returns an n-element list, whose elements are all the value fill. If the fill argument is not given, the elements of the list may be arbitrary values.
(scheme list) procedure (list-tabulate (n integer?) (init-proc procedure?) ) ⟹ list?
(init-proc (i integer?) ) ⟹ *
Returns an n-element list. Element i of the list, where 0 <= i < n, is produced by (init-proc i). No guarantee is made about the dynamic order in which init-proc is applied to these indices.
(scheme list) procedure (list-copy (flist list?) ) ⟹ list?
(scheme list) procedure (list-copy (flist dotted-list?) ) ⟹ dotted-list?
Copies the spine of the argument.
(scheme list) procedure (circular-list elt1 elt2 ... ) ⟹ circular-list?
Constructs a circular list of the elements.
(scheme list) procedure (iota (count integer?) ) ⟹ list?
(scheme list) procedure (iota (count integer?) (start number?) ) ⟹ list?
(scheme list) procedure (iota (count integer?) (start number?) (step number?) ) ⟹ list?
Returns a list containing the elements (start start+step ... start+(count-1)*step). The start and step parameters default to 0 and 1, respectively. This procedure takes its name from the APL primitive.
(scheme list) procedure (proper-list? obj ) ⟹ boolean?
Returns true iff x is a proper list -- a finite, nil-terminated list. More carefully: The empty list is a proper list. A pair whose cdr is a proper list is also a proper list: <proper-list> ::= () | (cons <x> <proper-list>). Note that this definition rules out circular lists. This function is required to detect this case and return false. Nil-terminated lists are called "proper" lists by R5RS and Common Lisp. The opposite of proper is improper.
(scheme list) procedure (circular-list? obj ) ⟹ boolean?
True if x is a circular list. A circular list is a value such that for every n >= 0, cdrn(x) is a pair. Terminology: The opposite of circular is finite.
(scheme list) procedure (dotted-list? obj ) ⟹ boolean?
True if x is a finite, non-nil-terminated list. That is, there exists an n >= 0 such that cdrn(x) is neither a pair nor (). This includes non-pair, non-() values (e.g. symbols, numbers), which are considered to be dotted lists of length 0.
(scheme list) procedure (pair? obj ) ⟹ boolean?
Returns #t if object is a pair; otherwise, #f.
(scheme list) procedure (null? obj ) ⟹ boolean?
Returns #t if object is the empty list; otherwise, #f.
(scheme list) procedure (null-list? (lst list?) ) ⟹ boolean?
(scheme list) procedure (null-list? (lst circular-list?) ) ⟹ boolean?
List is a proper or circular list. This procedure returns true if the argument is the empty list (), and false otherwise. It is an error to pass this procedure a value which is not a proper or circular list. This procedure is recommended as the termination condition for list-processing procedures that are not defined on dotted lists.
(scheme list) procedure (not-pair? obj ) ⟹ boolean?
(lambda (x) (not (pair? x))). Provided as a procedure as it can be useful as the termination condition for list-processing procedures that wish to handle all finite lists, both proper and dotted.
(scheme list) procedure (list= (elt= procedure?) (list1 list?) ... ) ⟹ boolean?
(elt= a b ) ⟹ *
Determines list equality, given an element-equality procedure. Proper list A equals proper list B if they are of the same length, and their corresponding elements are equal, as determined by elt=. If the element-comparison procedure's first argument is from listi, then its second argument is from listi+1, i.e. it is always called as (elt= a b) for a an element of list A, and b an element of list B. In the n-ary case, every listi is compared to listi+1 (as opposed, for example, to comparing list1 to every listi, for i>1). If there are no list arguments at all, list= simply returns true. It is an error to apply list= to anything except proper lists. While implementations may choose to extend it to circular lists, note that it cannot reasonably be extended to dotted lists, as it provides no way to specify an equality procedure for comparing the list terminators. Note that the dynamic order in which the elt= procedure is applied to pairs of elements is not specified. For example, if list= is applied to three lists, A, B, and C, it may first completely compare A to B, then compare B to C, or it may compare the first elements of A and B, then the first elements of B and C, then the second elements of A and B, and so forth. The equality procedure must be consistent with eq?. That is, it must be the case that (eq? x y) => (elt= x y). Note that this implies that two lists which are eq? are always list=, as well; implementations may exploit this fact to "short-cut" the element-by-element comparisons.
(scheme list) procedure (caar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (car (pair pair?) ) ⟹ *
car, cdr These functions return the contents of the car and cdr field of their argument, respectively. Note that it is an error to apply them to the empty list.
(scheme list) procedure (cdar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cdr (pair pair?) ) ⟹ *
car, cdr These functions return the contents of the car and cdr field of their argument, respectively. Note that it is an error to apply them to the empty list.
(scheme list) procedure (caaaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (caaadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (caaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (caadar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (caaddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (caadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cadaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cadadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cadar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (caddar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cadddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (caddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cdaaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cdaadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cdaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cdadar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cdaddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cdadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cddaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cddadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cddar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cdddar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cddddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (cdddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(scheme list) procedure (list-ref (clist list?) (i integer?) ) ⟹ *
(scheme list) procedure (list-ref (clist circular-list?) (i integer?) ) ⟹ *
Returns the ith element of clist. (This is the same as the car of (drop clist i).) It is an error if i >= n, where n is the length of clist.
(scheme list) procedure (first (pair pair?) ) ⟹ *
(scheme list) procedure (second (pair pair?) ) ⟹ *
(scheme list) procedure (third (pair pair?) ) ⟹ *
(scheme list) procedure (fourth (pair pair?) ) ⟹ *
(scheme list) procedure (fifth (pair pair?) ) ⟹ *
(scheme list) procedure (sixth (pair pair?) ) ⟹ *
(scheme list) procedure (seventh (pair pair?) ) ⟹ *
(scheme list) procedure (eighth (pair pair?) ) ⟹ *
(scheme list) procedure (ninth (pair pair?) ) ⟹ *
(scheme list) procedure (tenth (pair pair?) ) ⟹ *
Synonyms for car, cadr, caddr, ...
(scheme list) procedure (car+cdr (pair pair?) ) ⟹ (values **)
The fundamental pair deconstructor: (lambda (p) (values (car p) (cdr p)))
(scheme list) procedure (take (x list?) (i integer?) ) ⟹ list?
(scheme list) procedure (take (x circular-list?) (i integer?) ) ⟹ list?
(scheme list) procedure (take (x dotted-list?) (i integer?) ) ⟹ list?
take, drop take returns the first i elements of list x. drop returns all but the first i elements of list x. x may be any value -- a proper, circular, or dotted list. For a legal i, take and drop partition the list in a manner which can be inverted with append: (append (take x i) (drop x i)) = x. drop is exactly equivalent to performing i cdr operations on x; the returned value shares a common tail with x. If the argument is a list of non-zero length, take is guaranteed to return a freshly-allocated list, even in the case where the entire list is taken, e.g. (take lis (length lis)).
(scheme list) procedure (drop (x list?) (i integer?) ) ⟹ list?
(scheme list) procedure (drop (x circular-list?) (i integer?) ) ⟹ circular-list?
(scheme list) procedure (drop (x dotted-list?) (i integer?) ) ⟹ *
take, drop take returns the first i elements of list x. drop returns all but the first i elements of list x. x may be any value -- a proper, circular, or dotted list. For a legal i, take and drop partition the list in a manner which can be inverted with append: (append (take x i) (drop x i)) = x. drop is exactly equivalent to performing i cdr operations on x; the returned value shares a common tail with x. If the argument is a list of non-zero length, take is guaranteed to return a freshly-allocated list, even in the case where the entire list is taken, e.g. (take lis (length lis)).
(scheme list) procedure (take-right (flist list?) (i integer?) ) ⟹ list?
(scheme list) procedure (take-right (flist dotted-list?) (i integer?) ) ⟹ *
take-right, drop right take-right returns the last i elements of flist. drop-right returns all but the last i elements of flist. The returned list may share a common tail with the argument list. flist may be any finite list, either proper or dotted. For a legal i, take-right and drop-right partition the list in a manner which can be inverted with append: (append (take flist i) (drop flist i)) = flist. take-right's return value is guaranteed to share a common tail with flist. If the argument is a list of non-zero length, drop-right is guaranteed to return a freshly-allocated list, even in the case where nothing is dropped, e.g. (drop-right lis 0).
(scheme list) procedure (drop-right (flist list?) (i integer?) ) ⟹ list?
(scheme list) procedure (drop-right (flist dotted-list?) (i integer?) ) ⟹ list?
take-right, drop right take-right returns the last i elements of flist. drop-right returns all but the last i elements of flist. The returned list may share a common tail with the argument list. flist may be any finite list, either proper or dotted. For a legal i, take-right and drop-right partition the list in a manner which can be inverted with append: (append (take flist i) (drop flist i)) = flist. take-right's return value is guaranteed to share a common tail with flist. If the argument is a list of non-zero length, drop-right is guaranteed to return a freshly-allocated list, even in the case where nothing is dropped, e.g. (drop-right lis 0).
(scheme list) procedure (take! (x list?) (i integer?) ) ⟹ list?
(scheme list) procedure (take! (x circular-list?) (i integer?) ) ⟹ list?
(scheme list) procedure (take! (x dotted-list?) (i integer?) ) ⟹ list?
take!, drop-right! take! and drop-right! are "linear-update" variants of take and drop-right: the procedure is allowed, but not required, to alter the argument list to produce the result. If x is circular, take! may return a shorter-than-expected list
(scheme list) procedure (drop-right! (flist list?) (i integer?) ) ⟹ list?
(scheme list) procedure (drop-right! (flist dotted-list?) (i integer?) ) ⟹ list?
take!, drop-right! take! and drop-right! are "linear-update" variants of take and drop-right: the procedure is allowed, but not required, to alter the argument list to produce the result. If x is circular, take! may return a shorter-than-expected list
(scheme list) procedure (split-at (x list?) (i integer?) ) ⟹ (values list?list?)
(scheme list) procedure (split-at (x circular-list?) (i integer?) ) ⟹ (values list?circular-list?)
(scheme list) procedure (split-at (x dotted-list?) (i integer?) ) ⟹ (values list?*)
split-at, split-at! split-at splits the list x at index i, returning a list of the first i elements, and the remaining tail. It is equivalent to (values (take x i) (drop x i)). split-at! is the linear-update variant. It is allowed, but not required, to alter the argument list to produce the result.
(scheme list) procedure (split-at! (x list?) (i integer?) ) ⟹ (values list?list?)
(scheme list) procedure (split-at! (x circular-list?) (i integer?) ) ⟹ (values list?circular-list?)
(scheme list) procedure (split-at! (x dotted-list?) (i integer?) ) ⟹ (values list?*)
split-at, split-at! split-at splits the list x at index i, returning a list of the first i elements, and the remaining tail. It is equivalent to (values (take x i) (drop x i)). split-at! is the linear-update variant. It is allowed, but not required, to alter the argument list to produce the result.
(scheme list) procedure (last (pair list?) ) ⟹ *
last, last-pair last returns the last element of the non-empty, finite list pair. last-pair returns the last pair in the non-empty, finite list pair.
(scheme list) procedure (last-pair (pair list?) ) ⟹ pair?
last, last-pair last returns the last element of the non-empty, finite list pair. last-pair returns the last pair in the non-empty, finite list pair.
(scheme list) procedure (length (list list?) ) ⟹ integer?
length, length+ Both length and length+ return the length of the argument. It is an error to pass a value to length which is not a proper list (finite and nil-terminated). In particular, this means an implementation may diverge or signal an error when length is applied to a circular list. length+, on the other hand, returns #F when applied to a circular list. The length of a proper list is a non-negative integer n such that cdr applied n times to the list produces the empty list.
(scheme list) procedure (length+ (clist list?) ) ⟹ integer?
(scheme list) procedure (length+ (clist circular-list?) ) ⟹ boolean?
length, length+ Both length and length+ return the length of the argument. It is an error to pass a value to length which is not a proper list (finite and nil-terminated). In particular, this means an implementation may diverge or signal an error when length is applied to a circular list. length+, on the other hand, returns #F when applied to a circular list. The length of a proper list is a non-negative integer n such that cdr applied n times to the list produces the empty list.
(scheme list) procedure (append (list list?) ... ) ⟹ list?
(scheme list) procedure (append (list list?) ... obj ) ⟹ *
append, append! append returns a list consisting of the elements of list1 followed by the elements of the other list parameters. The resulting list is always newly allocated, except that it shares structure with the final listi argument. This last argument may be any value at all; an improper list results if it is not a proper list. All other arguments must be proper lists. append! is the "linear-update" variant of append -- it is allowed, but not required, to alter cons cells in the argument lists to construct the result list. The last argument is never altered; the result list shares structure with this parameter.
(scheme list) procedure (append! (list list?) ... ) ⟹ list?
(scheme list) procedure (append! (list list?) ... obj ) ⟹ *
append, append! append returns a list consisting of the elements of list1 followed by the elements of the other list parameters. The resulting list is always newly allocated, except that it shares structure with the final listi argument. This last argument may be any value at all; an improper list results if it is not a proper list. All other arguments must be proper lists. append! is the "linear-update" variant of append -- it is allowed, but not required, to alter cons cells in the argument lists to construct the result list. The last argument is never altered; the result list shares structure with this parameter.
(scheme list) procedure (concatenate (list-of-lists list?) ) ⟹ *
list-of-lists ⟹ (list (lst list?) )
concatenate, concatenate! These functions append the elements of their argument together. That is, concatenate returns (apply append list-of-lists) or, equivalently, (reduce-right append '() list-of-lists). concatenate! is the linear-update variant, defined in terms of append! instead of append. Note that some Scheme implementations do not support passing more than a certain number (e.g., 64) of arguments to an n-ary procedure. In these implementations, the (apply append ...) idiom would fail when applied to long lists, but concatenate would continue to function properly. As with append and append!, the last element of the input list may be any value at all.
(scheme list) procedure (concatenate! (list-of-lists list?) ) ⟹ *
list-of-lists ⟹ (list (lst list?) )
concatenate, concatenate! These functions append the elements of their argument together. That is, concatenate returns (apply append list-of-lists) or, equivalently, (reduce-right append '() list-of-lists). concatenate! is the linear-update variant, defined in terms of append! instead of append. Note that some Scheme implementations do not support passing more than a certain number (e.g., 64) of arguments to an n-ary procedure. In these implementations, the (apply append ...) idiom would fail when applied to long lists, but concatenate would continue to function properly. As with append and append!, the last element of the input list may be any value at all.
(scheme list) procedure (reverse (list list?) ) ⟹ list?
reverse, reverse! reverse returns a newly allocated list consisting of the elements of list in reverse order. reverse! is the linear-update variant of reverse. It is permitted, but not required, to alter the argument's cons cells to produce the reversed list.
(scheme list) procedure (reverse! (list list?) ) ⟹ list?
reverse, reverse! reverse returns a newly allocated list consisting of the elements of list in reverse order. reverse! is the linear-update variant of reverse. It is permitted, but not required, to alter the argument's cons cells to produce the reversed list.
(scheme list) procedure (append-reverse (rev-head list?) (tail list?) ) ⟹ list?
(scheme list) procedure (append-reverse (rev-head list?) tail ) ⟹ *
append-reverse, append-reverse! append-reverse returns (append (reverse rev-head) tail). It is provided because it is a common operation -- a common list-processing style calls for this exact operation to transfer values accumulated in reverse order onto the front of another list, and because the implementation is significantly more efficient than the simple composition it replaces. (But note that this pattern of iterative computation followed by a reverse can frequently be rewritten as a recursion, dispensing with the reverse and append-reverse steps, and shifting temporary, intermediate storage from the heap to the stack, which is typically a win for reasons of cache locality and eager storage reclamation.) append-reverse! is just the linear-update variant -- it is allowed, but not required, to alter rev-head's cons cells to construct the result.
(scheme list) procedure (append-reverse! (rev-head list?) (tail list?) ) ⟹ list?
(scheme list) procedure (append-reverse! (rev-head list?) tail ) ⟹ *
append-reverse, append-reverse! append-reverse returns (append (reverse rev-head) tail). It is provided because it is a common operation -- a common list-processing style calls for this exact operation to transfer values accumulated in reverse order onto the front of another list, and because the implementation is significantly more efficient than the simple composition it replaces. (But note that this pattern of iterative computation followed by a reverse can frequently be rewritten as a recursion, dispensing with the reverse and append-reverse steps, and shifting temporary, intermediate storage from the heap to the stack, which is typically a win for reasons of cache locality and eager storage reclamation.) append-reverse! is just the linear-update variant -- it is allowed, but not required, to alter rev-head's cons cells to construct the result.
(scheme list) procedure (zip (clist1 list?) (clist2 list?) ... ) ⟹ list?
(lambda lists (apply map list lists)). If zip is passed n lists, it returns a list as long as the shortest of these lists, each element of which is an n-element list comprised of the corresponding elements from the parameter lists. At least one of the argument lists must be finite.
(scheme list) procedure (unzip1 (list list?) ) ⟹ list?
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(scheme list) procedure (unzip2 (list list?) ) ⟹ (values list?list?)
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(scheme list) procedure (unzip3 (list list?) ) ⟹ (values list?list?list?)
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(scheme list) procedure (unzip4 (list list?) ) ⟹ (values list?list?list?list?)
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(scheme list) procedure (unzip5 (list list?) ) ⟹ (values list?list?list?list?list?)
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(scheme list) procedure (count (pred procedure?) (clist1 list?) (clist2 list?) ... ) ⟹ integer?
(pred obj ... ) ⟹ *
pred is a procedure taking as many arguments as there are lists and returning a single value. It is applied element-wise to the elements of the lists, and a count is tallied of the number of elements that produce a true value. This count is returned. count is "iterative" in that it is guaranteed to apply pred to the list elements in a left-to-right order. The counting stops when the shortest list expires. At least one of the argument lists must be finite.
(scheme list) procedure (fold (kons procedure?) knil (clist1 list?) (clist2 list?) ... ) ⟹ *
(kons obj1 obj2 ... fold-state ) ⟹ *
The fundamental list iterator. First, consider the single list-parameter case. If clist1 = (e1 e2 ... en), then this procedure returns (kons en ... (kons e2 (kons e1 knil)) ... ). If n list arguments are provided, then the kons function must take n+1 parameters: one element from each list, and the "seed" or fold state, which is initially knil. The fold operation terminates when the shortest list runs out of values. At least one of the list arguments must be finite.
(scheme list) procedure (fold-right (kons procedure?) knil (clist1 list?) (clist2 list?) ... ) ⟹ *
(kons obj1 obj2 ... fold-state ) ⟹ *
The fundamental list recursion operator. First, consider the single list-parameter case. If clist1 = (e1 e2 ... en), then this procedure returns (kons e1 (kons e2 ... (kons en knil))). If n list arguments are provided, then the kons function must take n+1 parameters: one element from each list, and the "seed" or fold state, which is initially knil. The fold operation terminates when the shortest list runs out of values. At least one of the list arguments must be finite.
(scheme list) procedure (pair-fold (kons procedure?) knil (clist1 list?) (clist2 list?) ... ) ⟹ *
(kons (pair1 pair?) (pair2 pair?) ... fold-state ) ⟹ *
Analogous to fold, but kons is applied to successive sublists of the lists, rather than successive elements -- that is, kons is applied to the pairs making up the lists. For finite lists, the kons function may reliably apply set-cdr! to the pairs it is given without altering the sequence of execution. At least one of the list arguments must be finite.
(scheme list) procedure (pair-fold-right (kons procedure?) knil (clist1 list?) (clist2 list?) ... ) ⟹ *
(kons (pair1 pair?) (pair2 pair?) ... fold-state ) ⟹ *
Holds the same relationship with fold-right that pair-fold holds with fold. At least one of the list arguments must be finite.
(scheme list) procedure (reduce (f procedure?) ridentity (list list?) ) ⟹ *
(f obj fold-state ) ⟹ *
reduce is a variant of fold. ridentity should be a "right identity" of the procedure f -- that is, for any value x acceptable to f, (f x ridentity) = x. reduce has the following definition: If list = (), return ridentity; Otherwise, return (fold f (car list) (cdr list)). ...in other words, we compute (fold f ridentity list). Note that ridentity is used only in the empty-list case. You typically use reduce when applying f is expensive and you'd like to avoid the extra application incurred when fold applies f to the head of list and the identity value, redundantly producing the same value passed in to f. For example, if f involves searching a file directory or performing a database query, this can be significant. In general, however, fold is useful in many contexts where reduce is not (consider the examples given in the fold definition -- only one of the five folds uses a function with a right identity. The other four may not be performed with reduce). Note: MIT Scheme and Haskell flip F's arg order for their reduce and fold functions.
(scheme list) procedure (reduce-right (f procedure?) ridentity (list list?) ) ⟹ *
(f obj fold-state ) ⟹ *
reduce-right is the fold-right variant of reduce.
(scheme list) procedure (unfold (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ list?
(scheme list) procedure (unfold (p procedure?) (f procedure?) (g procedure?) seed (tail-gen list?) ) ⟹ *
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(tail-gen ) ⟹ *
unfold is best described by its basic recursion: (unfold p f g seed) = (if (p seed) (tail-gen seed) (cons (f seed) (unfold p f g (g seed)))). p determines when to stop unfolding. f maps each seed value to the corresponding list element. g maps each seed value to next seed value. seed the "state" value for the unfold. tail-gen creates the tail of the list; defaults to (lambda (x) '()). In other words, we use g to generate a sequence of seed values seed, g(seed), g2(seed), g3(seed), ... These seed values are mapped to list elements by f, producing the elements of the result list in a left-to-right order. P says when to stop. unfold is the fundamental recursive list constructor, just as fold-right is the fundamental recursive list consumer.
(scheme list) procedure (unfold-right (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ list?
(scheme list) procedure (unfold-right (p procedure?) (f procedure?) (g procedure?) seed (tail-gen list?) ) ⟹ *
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(tail-gen ) ⟹ *
unfold-right constructs a list with the following loop: (let lp ((seed seed) (lis tail)) (if (p seed) lis (lp (g seed) (cons (f seed) lis)))). p determines when to stop unfolding. f maps each seed value to the corresponding list element. g maps each seed value to next seed value. seed the "state" value for the unfold. tail list terminator; defaults to '(). In other words, we use g to generate a sequence of seed values seed, g(seed), g2(seed), g3(seed), ... These seed values are mapped to list elements by f, producing the elements of the result list in a right-to-left order. P says when to stop. unfold-right is the fundamental iterative list constructor, just as fold is the fundamental iterative list consumer.
(scheme list) procedure (map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ *
proc is a procedure taking as many arguments as there are list arguments and returning a single value. 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. his procedure is extended from its R5RS specification to allow the arguments to be of unequal length; it terminates when the shortest list runs out. At least one of the argument lists must be finite.
(scheme list) 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. This procedure is extended from its R5RS specification to allow the arguments to be of unequal length; it terminates when the shortest list runs out. At least one of the argument lists must be finite.
(scheme list) procedure (append-map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ list?
append-map, append-map! Equivalent to (apply append (map f clist1 clist2 ...)) and (apply append! (map f clist1 clist2 ...)). Map f over the elements of the lists, just as in the map function. However, the results of the applications are appended together to make the final result. append-map uses append to append the results together; append-map! uses append!. The dynamic order in which the various applications of f are made is not specified.
(scheme list) procedure (append-map! (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 objs2 ... ) ⟹ list?
append-map, append-map! Equivalent to (apply append (map f clist1 clist2 ...)) and (apply append! (map f clist1 clist2 ...)). Map f over the elements of the lists, just as in the map function. However, the results of the applications are appended together to make the final result. append-map uses append to append the results together; append-map! uses append!. The dynamic order in which the various applications of f are made is not specified.
(scheme list) procedure (map! (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ *
Linear-update variant of map -- map! is allowed, but not required, to alter the cons cells of list1 to construct the result list. The dynamic order in which the various applications of f are made is not specified. In the n-ary case, clist2, clist3, ... must have at least as many elements as list1.
(scheme list) procedure (map-in-order (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ *
A variant of the map procedure that guarantees to apply f across the elements of the listi arguments in a left-to-right order. This is useful for mapping procedures that both have side effects and return useful values. At least one of the list arguments must be finite.
(scheme list) procedure (pair-for-each (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ undefined
(proc (obj1 pair?) (obj2 pair?) ... ) ⟹ undefined
Like for-each, but f is applied to successive sublists of the argument lists. That is, f is applied to the cons cells of the lists, rather than the lists' elements. These applications occur in left-to-right order. The f procedure may reliably apply set-cdr! to the pairs it is given without altering the sequence of execution.
(scheme list) procedure (filter-map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ *
Like map, but only true values are saved. The dynamic order in which the various applications of f are made is not specified. At least one of the list arguments must be finite.
(scheme list) procedure (filter (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
Return all the elements of list that satisfy predicate pred. The list is not disordered -- elements that appear in the result list occur in the same order as they occur in the argument list. The returned list may share a common tail with the argument list. The dynamic order in which the various applications of pred are made is not specified.
(scheme list) procedure (filter! (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
filter!, partition!, remove! Linear-update variants of filter, partition and remove. These procedures are allowed, but not required, to alter the cons cells in the argument list to construct the result lists.
(scheme list) procedure (partition (pred procedure?) (list list?) ) ⟹ (values list?list?)
(pred obj ) ⟹ *
Partitions the elements of list with predicate pred, and returns two values: the list of in-elements and the list of out-elements. The list is not disordered -- elements occur in the result lists in the same order as they occur in the argument list. The dynamic order in which the various applications of pred are made is not specified. One of the returned lists may share a common tail with the argument list.
(scheme list) procedure (partition! (pred procedure?) (list list?) ) ⟹ (values list?list?)
(pred obj ) ⟹ *
filter!, partition!, remove! Linear-update variants of filter, partition and remove. These procedures are allowed, but not required, to alter the cons cells in the argument list to construct the result lists.
(scheme list) procedure (remove (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
Returns list without the elements that satisfy predicate pred: (lambda (pred list) (filter (lambda (x) (not (pred x))) list)). The list is not disordered -- elements that appear in the result list occur in the same order as they occur in the argument list. The returned list may share a common tail with the argument list. The dynamic order in which the various applications of pred are made is not specified.
(scheme list) procedure (remove! (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
filter!, partition!, remove! Linear-update variants of filter, partition and remove. These procedures are allowed, but not required, to alter the cons cells in the argument list to construct the result lists.
(scheme list) procedure (find (pred procedure?) (list list?) ) ⟹ *
(pred obj ) ⟹ *
Return the first element of clist that satisfies predicate pred; false if no element does. Note that find has an ambiguity in its lookup semantics -- if find returns #f, you cannot tell (in general) if it found a #f element that satisfied pred, or if it did not find any element at all. In many situations, this ambiguity cannot arise -- either the list being searched is known not to contain any #f elements, or the list is guaranteed to have an element satisfying pred. However, in cases where this ambiguity can arise, you should use find-tail instead of find -- find-tail has no such ambiguity.
(scheme list) procedure (find-tail (pred procedure?) (list list?) ) ⟹ pair? / #f /
(pred obj ) ⟹ *
Return the first pair of clist whose car satisfies pred. If no pair does, return false. find-tail can be viewed as a general-predicate variant of the member function. In the circular-list case, this procedure "rotates" the list. Find-tail is essentially drop-while, where the sense of the predicate is inverted: Find-tail searches until it finds an element satisfying the predicate; drop-while searches until it finds an element that doesn't satisfy the predicate.
(scheme list) procedure (take-while (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
take-while, take-while! Returns the longest initial prefix of clist whose elements all satisfy the predicate pred. Take-while! is the linear-update variant. It is allowed, but not required, to alter the argument list to produce the result.
(scheme list) procedure (take-while! (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
take-while, take-while! Returns the longest initial prefix of clist whose elements all satisfy the predicate pred. Take-while! is the linear-update variant. It is allowed, but not required, to alter the argument list to produce the result.
(scheme list) procedure (drop-while (pred procedure?) (list list?) ) ⟹ list?
(scheme list) procedure (drop-while (pred procedure?) (list circular-list?) ) ⟹ circular-list?
(pred obj ) ⟹ *
Drops the longest initial prefix of clist whose elements all satisfy the predicate pred, and returns the rest of the list. The circular-list case may be viewed as "rotating" the list.
(scheme list) procedure (span (pred procedure?) (list list?) ) ⟹ (values list?list?)
(scheme list) procedure (span (pred procedure?) (list circular-list?) ) ⟹ (values list?circular-list?)
(pred obj ) ⟹ *
span, span!, break, break! Span splits the list into the longest initial prefix whose elements all satisfy pred, and the remaining tail. Break inverts the sense of the predicate: the tail commences with the first element of the input list that satisfies the predicate. In other words: span finds the intial span of elements satisfying pred, and break breaks the list at the first element satisfying pred. Span is equivalent to (values (take-while pred clist) (drop-while pred clist)). Span! and break! are the linear-update variants. They are allowed, but not required, to alter the argument list to produce the result.
(scheme list) procedure (span! (pred procedure?) (list list?) ) ⟹ (values list?list?)
(pred obj ) ⟹ *
span, span!, break, break! Span splits the list into the longest initial prefix whose elements all satisfy pred, and the remaining tail. Break inverts the sense of the predicate: the tail commences with the first element of the input list that satisfies the predicate. In other words: span finds the intial span of elements satisfying pred, and break breaks the list at the first element satisfying pred. Span is equivalent to (values (take-while pred clist) (drop-while pred clist)). Span! and break! are the linear-update variants. They are allowed, but not required, to alter the argument list to produce the result.
(scheme list) procedure (break (pred procedure?) (list list?) ) ⟹ (values list?list?)
(scheme list) procedure (break (pred procedure?) (list circular-list?) ) ⟹ (values list?circular-list?)
(pred obj ) ⟹ *
span, span!, break, break! Span splits the list into the longest initial prefix whose elements all satisfy pred, and the remaining tail. Break inverts the sense of the predicate: the tail commences with the first element of the input list that satisfies the predicate. In other words: span finds the intial span of elements satisfying pred, and break breaks the list at the first element satisfying pred. Span is equivalent to (values (take-while pred clist) (drop-while pred clist)). Span! and break! are the linear-update variants. They are allowed, but not required, to alter the argument list to produce the result.
(scheme list) procedure (break! (pred procedure?) (list list?) ) ⟹ (values list?list?)
(pred obj ) ⟹ *
span, span!, break, break! Span splits the list into the longest initial prefix whose elements all satisfy pred, and the remaining tail. Break inverts the sense of the predicate: the tail commences with the first element of the input list that satisfies the predicate. In other words: span finds the intial span of elements satisfying pred, and break breaks the list at the first element satisfying pred. Span is equivalent to (values (take-while pred clist) (drop-while pred clist)). Span! and break! are the linear-update variants. They are allowed, but not required, to alter the argument list to produce the result.
(scheme list) procedure (any (pred procedure?) (clist1 list?) (clist2 list?) ... ) ⟹ *
(pred obj1 obj2 ... ) ⟹ *
Applies the predicate across the lists, returning true if the predicate returns true on any application. If there are n list arguments clist1 ... clistn, then pred must be a procedure taking n arguments and returning a single value, interpreted as a boolean (that is, #f means false, and any other value means true). any applies pred to the first elements of the clisti parameters. If this application returns a true value, any immediately returns that value. Otherwise, it iterates, applying pred to the second elements of the clisti parameters, then the third, and so forth. The iteration stops when a true value is produced or one of the lists runs out of values; in the latter case, any returns #f. The application of pred to the last element of the lists is a tail call. Note the difference between find and any -- find returns the element that satisfied the predicate; any returns the true value that the predicate produced. Like every, any's name does not end with a question mark -- this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(scheme list) procedure (every (pred procedure?) (clist1 list?) (clist2 list?) ... ) ⟹ *
(pred obj1 obj2 ... ) ⟹ *
Applies the predicate across the lists, returning true if the predicate returns true on every application. If there are n list arguments clist1 ... clistn, then pred must be a procedure taking n arguments and returning a single value, interpreted as a boolean (that is, #f means false, and any other value means true). every applies pred to the first elements of the clisti parameters. If this application returns false, every immediately returns false. Otherwise, it iterates, applying pred to the second elements of the clisti parameters, then the third, and so forth. The iteration stops when a false value is produced or one of the lists runs out of values. In the latter case, every returns the true value produced by its final application of pred. The application of pred to the last element of the lists is a tail call. If one of the clisti has no elements, every simply returns #t. Like any, every's name does not end with a question mark -- this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(scheme list) procedure (list-index (pred procedure?) (clist1 list?) (clist2 list?) ... ) ⟹ integer? / #f /
(pred obj1 obj2 ... ) ⟹ *
Return the index of the leftmost element that satisfies pred. If there are n list arguments clist1 ... clistn, then pred must be a function taking n arguments and returning a single value, interpreted as a boolean (that is, #f means false, and any other value means true). list-index applies pred to the first elements of the clisti parameters. If this application returns true, list-index immediately returns zero. Otherwise, it iterates, applying pred to the second elements of the clisti parameters, then the third, and so forth. When it finds a tuple of list elements that cause pred to return true, it stops and returns the zero-based index of that position in the lists. The iteration stops when one of the lists runs out of values; in this case, list-index returns #f.
(scheme list) procedure (member obj (list list?) ) ⟹ #f / list? /
(scheme list) procedure (member obj (list list?) (= procedure?) ) ⟹ #f / list? /
(= obj1 obj2 ) ⟹ *
member, memq, memv These procedures return the first sublist of list whose car is x, where the sublists of list are the non-empty lists returned by (drop list i) for i less than the length of list. If x does not occur in list, then #f is returned. memq uses eq? to compare x with the elements of list, while memv uses eqv?, and member uses equal?. member is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key x in this way: (= x ei) ; list is (E1 ... En). That is, the first argument is always x, and the second argument is one of the list elements. Thus one can reliably find the first element of list that is greater than five with (member 5 list <). Note that fully general list searching may be performed with the find-tail and find procedures.
(scheme list) procedure (memq obj (list list?) ) ⟹ #f / list? /
member, memq, memv These procedures return the first sublist of list whose car is x, where the sublists of list are the non-empty lists returned by (drop list i) for i less than the length of list. If x does not occur in list, then #f is returned. memq uses eq? to compare x with the elements of list, while memv uses eqv?, and member uses equal?. member is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key x in this way: (= x ei) ; list is (E1 ... En). That is, the first argument is always x, and the second argument is one of the list elements. Thus one can reliably find the first element of list that is greater than five with (member 5 list <). Note that fully general list searching may be performed with the find-tail and find procedures.
(scheme list) procedure (memv obj (list list?) ) ⟹ #f / list? /
member, memq, memv These procedures return the first sublist of list whose car is x, where the sublists of list are the non-empty lists returned by (drop list i) for i less than the length of list. If x does not occur in list, then #f is returned. memq uses eq? to compare x with the elements of list, while memv uses eqv?, and member uses equal?. member is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key x in this way: (= x ei) ; list is (E1 ... En). That is, the first argument is always x, and the second argument is one of the list elements. Thus one can reliably find the first element of list that is greater than five with (member 5 list <). Note that fully general list searching may be performed with the find-tail and find procedures.
(scheme list) procedure (delete obj (list list?) ) ⟹ list?
(scheme list) procedure (delete obj (list list?) (= procedure?) ) ⟹ list?
(= obj1 obj2 ) ⟹ *
delete, delete! delete uses the comparison procedure =, which defaults to equal?, to find all elements of list that are equal to x, and deletes them from list. The dynamic order in which the various applications of = are made is not specified. The list is not disordered -- elements that appear in the result list occur in the same order as they occur in the argument list. The result may share a common tail with the argument list. Note that fully general element deletion can be performed with the remove and remove! procedures. The comparison procedure is used in this way: (= x ei). That is, x is always the first argument, and a list element is always the second argument. The comparison procedure will be used to compare each element of list exactly once; the order in which it is applied to the various ei is not specified. Thus, one can reliably remove all the numbers greater than five from a list with (delete 5 list <). delete! is the linear-update variant of delete. It is allowed, but not required, to alter the cons cells in its argument list to construct the result.
(scheme list) procedure (delete! obj (list list?) ) ⟹ list?
(scheme list) procedure (delete! obj (list list?) (= procedure?) ) ⟹ list?
(= obj1 obj2 ) ⟹ *
delete, delete! delete uses the comparison procedure =, which defaults to equal?, to find all elements of list that are equal to x, and deletes them from list. The dynamic order in which the various applications of = are made is not specified. The list is not disordered -- elements that appear in the result list occur in the same order as they occur in the argument list. The result may share a common tail with the argument list. Note that fully general element deletion can be performed with the remove and remove! procedures. The comparison procedure is used in this way: (= x ei). That is, x is always the first argument, and a list element is always the second argument. The comparison procedure will be used to compare each element of list exactly once; the order in which it is applied to the various ei is not specified. Thus, one can reliably remove all the numbers greater than five from a list with (delete 5 list <). delete! is the linear-update variant of delete. It is allowed, but not required, to alter the cons cells in its argument list to construct the result.
(scheme list) procedure (delete-duplicates (list list?) ) ⟹ list?
(scheme list) procedure (delete-duplicates (list list?) (= procedure?) ) ⟹ list?
(= obj1 obj2 ) ⟹ *
delete-duplicates, delete-duplicates! delete-duplicates removes duplicate elements from the list argument. If there are multiple equal elements in the argument list, the result list only contains the first or leftmost of these elements in the result. The order of these surviving elements is the same as in the original list -- delete-duplicates does not disorder the list (hence it is useful for "cleaning up" association lists). The = parameter is used to compare the elements of the list; it defaults to equal?. If x comes before y in list, then the comparison is performed (= x y). The comparison procedure will be used to compare each pair of elements in list no more than once; the order in which it is applied to the various pairs is not specified. Implementations of delete-duplicates are allowed to share common tails between argument and result lists -- for example, if the list argument contains only unique elements, it may simply return exactly this list. Be aware that, in general, delete-duplicates runs in time O(n2) for n-element lists. Uniquifying long lists can be accomplished in O(n lg n) time by sorting the list to bring equal elements together, then using a linear-time algorithm to remove equal elements. Alternatively, one can use algorithms based on element-marking, with linear-time results. delete-duplicates! is the linear-update variant of delete-duplicates; it is allowed, but not required, to alter the cons cells in its argument list to construct the result.
(scheme list) procedure (delete-duplicates! (list list?) ) ⟹ list?
(scheme list) procedure (delete-duplicates! (list list?) (= procedure?) ) ⟹ list?
(= obj1 obj2 ) ⟹ *
delete-duplicates, delete-duplicates! delete-duplicates removes duplicate elements from the list argument. If there are multiple equal elements in the argument list, the result list only contains the first or leftmost of these elements in the result. The order of these surviving elements is the same as in the original list -- delete-duplicates does not disorder the list (hence it is useful for "cleaning up" association lists). The = parameter is used to compare the elements of the list; it defaults to equal?. If x comes before y in list, then the comparison is performed (= x y). The comparison procedure will be used to compare each pair of elements in list no more than once; the order in which it is applied to the various pairs is not specified. Implementations of delete-duplicates are allowed to share common tails between argument and result lists -- for example, if the list argument contains only unique elements, it may simply return exactly this list. Be aware that, in general, delete-duplicates runs in time O(n2) for n-element lists. Uniquifying long lists can be accomplished in O(n lg n) time by sorting the list to bring equal elements together, then using a linear-time algorithm to remove equal elements. Alternatively, one can use algorithms based on element-marking, with linear-time results. delete-duplicates! is the linear-update variant of delete-duplicates; it is allowed, but not required, to alter the cons cells in its argument list to construct the result.
(scheme list) procedure (assoc obj (alist list?) ) ⟹ list? / #f /
(scheme list) procedure (assoc obj (alist list?) (= procedure?) ) ⟹ pair? / #f /
(= a b ) ⟹ *
assoc, assq, assv alist must be an association list -- a list of pairs. These procedures find the first pair in alist whose car field is key, and returns that pair. If no pair in alist has key as its car, then #f is returned. assq uses eq? to compare key with the car fields of the pairs in alist, while assv uses eqv? and assoc uses equal?. assoc is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key parameter in this way: (= key (car ei)) ; list is (E1 ... En). That is, the first argument is always key, and the second argument is one of the list elements. Thus one can reliably find the first entry of alist whose key is greater than five with (assoc 5 alist <). Note that fully general alist searching may be performed with the find-tail and find procedures
(scheme list) procedure (assq obj (alist list?) ) ⟹ pair? / #f /
assoc, assq, assv alist must be an association list -- a list of pairs. These procedures find the first pair in alist whose car field is key, and returns that pair. If no pair in alist has key as its car, then #f is returned. assq uses eq? to compare key with the car fields of the pairs in alist, while assv uses eqv? and assoc uses equal?. assoc is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key parameter in this way: (= key (car ei)) ; list is (E1 ... En). That is, the first argument is always key, and the second argument is one of the list elements. Thus one can reliably find the first entry of alist whose key is greater than five with (assoc 5 alist <). Note that fully general alist searching may be performed with the find-tail and find procedures
(scheme list) procedure (assv obj (alist list?) ) ⟹ pair? / #f /
assoc, assq, assv alist must be an association list -- a list of pairs. These procedures find the first pair in alist whose car field is key, and returns that pair. If no pair in alist has key as its car, then #f is returned. assq uses eq? to compare key with the car fields of the pairs in alist, while assv uses eqv? and assoc uses equal?. assoc is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key parameter in this way: (= key (car ei)) ; list is (E1 ... En). That is, the first argument is always key, and the second argument is one of the list elements. Thus one can reliably find the first entry of alist whose key is greater than five with (assoc 5 alist <). Note that fully general alist searching may be performed with the find-tail and find procedures
(scheme list) procedure (alist-cons key datum (alist list?) ) ⟹ list?
(lambda (key datum alist) (cons (cons key datum) alist)) Cons a new alist entry mapping key -> datum onto alist.
(scheme list) procedure (alist-copy (alist list?) ) ⟹ list?
Make a fresh copy of alist. This means copying each pair that forms an association as well as the spine of the list.
(scheme list) procedure (alist-delete key (alist list?) ) ⟹ list?
(scheme list) procedure (alist-delete key (alist list?) (= procedure?) ) ⟹ list?
(= a b ) ⟹ *
alist-delete, alist-delete! alist-delete deletes all associations from alist with the given key, using key-comparison procedure =, which defaults to equal?. The dynamic order in which the various applications of = are made is not specified. Return values may share common tails with the alist argument. The alist is not disordered -- elements that appear in the result alist occur in the same order as they occur in the argument alist. The comparison procedure is used to compare the element keys ki of alist's entries to the key parameter in this way: (= key ki). Thus, one can reliably remove all entries of alist whose key is greater than five with (alist-delete 5 alist <). alist-delete! is the linear-update variant of alist-delete. It is allowed, but not required, to alter cons cells from the alist parameter to construct the result.
(scheme list) procedure (alist-delete! key (alist list?) ) ⟹ list?
(scheme list) procedure (alist-delete! key (alist list?) (= procedure?) ) ⟹ list?
(= a b ) ⟹ *
alist-delete, alist-delete! alist-delete deletes all associations from alist with the given key, using key-comparison procedure =, which defaults to equal?. The dynamic order in which the various applications of = are made is not specified. Return values may share common tails with the alist argument. The alist is not disordered -- elements that appear in the result alist occur in the same order as they occur in the argument alist. The comparison procedure is used to compare the element keys ki of alist's entries to the key parameter in this way: (= key ki). Thus, one can reliably remove all entries of alist whose key is greater than five with (alist-delete 5 alist <). alist-delete! is the linear-update variant of alist-delete. It is allowed, but not required, to alter cons cells from the alist parameter to construct the result.
(scheme list) procedure (lset<= (= procedure?) (list1 list?) ... ) ⟹ boolean?
(= a b ) ⟹ *
Returns true iff every listi is a subset of listi+1, using = for the element-equality procedure. List A is a subset of list B if every element in A is equal to some element of B. When performing an element comparison, the = procedure's first argument is an element of A; its second, an element of B.
(scheme list) procedure (lset= (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ boolean?
(= a b ) ⟹ *
Returns true iff every listi is set-equal to listi+1, using = for the element-equality procedure. "Set-equal" simply means that listi is a subset of listi+1, and listi+1 is a subset of listi. The = procedure's first argument is an element of listi; its second is an element of listi+1.
(scheme list) procedure (lset-adjoin (= procedure?) (list list?) elt1 ... ) ⟹ list?
(= a b ) ⟹ *
Adds the elti elements not already in the list parameter to the result list. The result shares a common tail with the list parameter. The new elements are added to the front of the list, but no guarantees are made about their order. The = parameter is an equality procedure used to determine if an elti is already a member of list. Its first argument is an element of list; its second is one of the elti. The list parameter is always a suffix of the result -- even if the list parameter contains repeated elements, these are not reduced.
(scheme list) procedure (lset-union (= procedure?) (list1 list?) ... ) ⟹ list?
(= a b ) ⟹ *
Returns the union of the lists, using = for the element-equality procedure. The union of lists A and B is constructed as follows: If A is the empty list, the answer is B (or a copy of B). Otherwise, the result is initialised to be list A (or a copy of A). Proceed through the elements of list B in a left-to-right order. If b is such an element of B, compare every element r of the current result list to b: (= r b). If all comparisons fail, b is consed onto the front of the result. However, there is no guarantee that = will be applied to every pair of arguments from A and B. In particular, if A is eq? to B, the operation may immediately terminate. In the n-ary case, the two-argument list-union operation is simply folded across the argument lists.
(scheme list) procedure (lset-union! (= procedure?) (list1 list?) ... ) ⟹ list?
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(scheme list) procedure (lset-intersection (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(= a b ) ⟹ *
Returns the intersection of the lists, using = for the element-equality procedure. The intersection of lists A and B is comprised of every element of A that is = to some element of B: (= a b), for a in A, and b in B. Note this implies that an element which appears in B and multiple times in list A will also appear multiple times in the result. The order in which elements appear in the result is the same as they appear in list1 -- that is, lset-intersection essentially filters list1, without disarranging element order. The result may share a common tail with list1. In the n-ary case, the two-argument list-intersection operation is simply folded across the argument lists. However, the dynamic order in which the applications of = are made is not specified. The procedure may check an element of list1 for membership in every other list before proceeding to consider the next element of list1, or it may completely intersect list1 and list2 before proceeding to list3, or it may go about its work in some third order.
(scheme list) procedure (lset-intersection! (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(scheme list) procedure (lset-difference (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(= a b ) ⟹ *
Returns the difference of the lists, using = for the element-equality procedure -- all the elements of list1 that are not = to any element from one of the other listi parameters. The = procedure's first argument is always an element of list1; its second is an element of one of the other listi. Elements that are repeated multiple times in the list1 parameter will occur multiple times in the result. The order in which elements appear in the result is the same as they appear in list1 -- that is, lset-difference essentially filters list1, without disarranging element order. The result may share a common tail with list1. The dynamic order in which the applications of = are made is not specified. The procedure may check an element of list1 for membership in every other list before proceeding to consider the next element of list1, or it may completely compute the difference of list1 and list2 before proceeding to list3, or it may go about its work in some third order.
(scheme list) procedure (lset-difference! (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(scheme list) procedure (lset-xor (= procedure?) (list1 list?) ... ) ⟹ list?
(= a b ) ⟹ *
Returns the exclusive-or of the sets, using = for the element-equality procedure. If there are exactly two lists, this is all the elements that appear in exactly one of the two lists. The operation is associative, and thus extends to the n-ary case -- the elements that appear in an odd number of the lists. The result may share a common tail with any of the listi parameters. More precisely, for two lists A and B, A xor B is a list of every element a of A such that there is no element b of B such that (= a b), and every element b of B such that there is no element a of A such that (= b a). However, an implementation is allowed to assume that = is symmetric -- that is, that (= a b) => (= b a). This means, for example, that if a comparison (= a b) produces true for some a in A and b in B, both a and b may be removed from inclusion in the result. In the n-ary case, the binary-xor operation is simply folded across the lists.
(scheme list) procedure (lset-xor! (= procedure?) (list1 list?) ... ) ⟹ list?
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(scheme list) procedure (lset-diff+intersection (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ (values list?list?)
(= a b ) ⟹ *
Returns two values -- the difference and the intersection of the lists. Is equivalent to (values (lset-difference = list1 list2 ...) (lset-intersection = list1 (lset-union = list2 ...))) but can be implemented more efficiently. The = procedure's first argument is an element of list1; its second is an element of one of the other listi. Either of the answer lists may share a common tail with list1. This operation essentially partitions list1.
(scheme list) procedure (lset-diff+intersection! (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ (values list?list?)
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(scheme list) procedure (set-car! (pair pair?) object ) ⟹ undefined
set-car!, set-cdr! These procedures store object in the car and cdr field of pair, respectively. The value returned is unspecified.
(scheme list) procedure (set-cdr! (pair pair?) object ) ⟹ undefined
set-car!, set-cdr! These procedures store object in the car and cdr field of pair, respectively. The value returned is unspecified.
library (scheme list-queue)
(scheme list-queue) procedure (make-list-queue (list list?) ) ⟹ list-queue?
(scheme list-queue) procedure (make-list-queue (list list?) (last pair?) ) ⟹ list-queue?
Returns a newly allocated list queue containing the elements of list in order. The result shares storage with list. If the last argument is not provided, this operation is O(n) where n is the length of list.
However, if last is provided, make-list-queue returns a newly allocated list queue containing the elements of the list whose first pair is first and whose last pair is last. It is an error if the pairs do not belong to the same list. Alternatively, both first and last can be the empty list. In either case, the operation is O(1).
Note: To apply a non-destructive list procedure to a list queue and return a new list queue, use (make-list-queue (proc (list-queue-list list-queue))).
(scheme list-queue) procedure (list-queue element ... ) ⟹ list-queue?
(scheme list-queue) procedure (list-queue (list-queue list-queue?) ) ⟹ list-queue?
Returns a newly allocated list queue containing the elements. This operation is O(n) where n is the number of elements.
(scheme list-queue) procedure (list-queue-copy (list-queue list-queue?) ) ⟹ list-queue?
Returns a newly allocated list queue containing the elements of list-queue. This operation is O(n) where n is the length of list-queue
(scheme list-queue) procedure (list-queue-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ list-queue?
(scheme list-queue) procedure (list-queue-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (queue list-queue?) ) ⟹ list-queue?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Performs the following algorithm:
If the result of applying the predicate stop? to seed is true, return queue. Otherwise, apply the procedure mapper to seed, returning a value which is added to the front of queue. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
If queue is omitted, a newly allocated list queue is used.
(scheme list-queue) procedure (list-queue-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ list-queue?
(scheme list-queue) procedure (list-queue-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (queue list-queue?) ) ⟹ list-queue?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Performs the following algorithm:
If the result of applying the predicate stop? to seed is true, return the list queue. Otherwise, apply the procedure mapper to seed, returning a value which is added to the back of the list queue. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
If queue is omitted, a newly allocated list queue is used.
(scheme list-queue) procedure (list-queue? obj ) ⟹ boolean?
Returns #t if obj is a list queue, and #f otherwise. This operation is O(1).
(scheme list-queue) procedure (list-queue-empty? (list-queue list-queue?) ) ⟹ boolean?
Returns #t if list-queue has no elements, and #f otherwise. This operation is O(1).
(scheme list-queue) procedure (list-queue-front (list-queue list-queue?) ) ⟹ *
Returns the first element of list-queue. If the list queue is empty, it is an error. This operation is O(1).
(scheme list-queue) procedure (list-queue-back (list-queue list-queue?) ) ⟹ *
Returns the last element of list-queue. If the list queue is empty, it is an error. This operation is O(1).
(scheme list-queue) procedure (list-queue-list (list-queue list-queue?) ) ⟹ list?
Returns the list that contains the members of list-queue in order. The result shares storage with list-queue. This operation is O(1).
(scheme list-queue) procedure (list-queue-first-last (list-queue list-queue?) ) ⟹ (values list?list?)
Returns two values, the first and last pairs of the list that contains the members of list-queue in order. If list-queue is empty, returns two empty lists. The results share storage with list-queue. This operation is O(1).
(scheme list-queue) procedure (list-queue-add-front! (list-queue list-queue?) element ) ⟹ undefined
Adds element to the beginning of list-queue. Returns an unspecified value. This operation is O(1).
(scheme list-queue) procedure (list-queue-add-back! (list-queue list-queue?) element ) ⟹ undefined
Adds element to the end of list-queue. Returns an unspecified value. This operation is O(1).
(scheme list-queue) procedure (list-queue-remove-front! (list-queue list-queue?) ) ⟹ *
Removes the first element of list-queue and returns it. If the list queue is empty, it is an error. This operation is O(1).
(scheme list-queue) procedure (list-queue-remove-back! (list-queue list-queue?) ) ⟹ *
Removes the last element of list-queue and returns it. If the list queue is empty, it is an error. This operation is O(n) where n is the length of list-queue, because queues do not not have backward links.
(scheme list-queue) procedure (list-queue-remove-all! (list-queue list-queue?) ) ⟹ list?
Removes all the elements of list-queue and returns them in order as a list. This operation is O(1).
(scheme list-queue) procedure (list-queue-set-list! (list-queue list-queue?) (list list?) ) ⟹ undefined
(scheme list-queue) procedure (list-queue-set-list! (list-queue list-queue?) (list list?) (last pair?) ) ⟹ undefined
Replaces the list associated with list-queue with list, effectively discarding all the elements of list-queue in favor of those in list. Returns an unspecified value. This operation is O(n) where n is the length of list. If last is provided, it is treated in the same way as in make-list-queue, and the operation is O(1).
Note: To apply a destructive list procedure to a list queue, use (list-queue-set-list! (proc (list-queue-list list-queue))).
(scheme list-queue) procedure (list-queue-append (list-queue list-queue?) ... ) ⟹ list-queue?
Returns a list queue which contains all the elements in front-to-back order from all the list-queues in front-to-back order. The result does not share storage with any of the arguments. This operation is O(n) in the total number of elements in all queues.
(scheme list-queue) procedure (list-queue-append! (list-queue list-queue?) ... ) ⟹ list-queue?
Returns a list queue which contains all the elements in front-to-back order from all the list-queues in front-to-back order. It is an error to assume anything about the contents of the list-queues after the procedure returns. This operation is O(n) in the total number of queues, not elements. It is not part of the R7RS-small list API, but is included here for efficiency when pure functional append is not required.
(scheme list-queue) procedure (list-queue-concatenate (list-of-list-queues list?) ) ⟹ list-queue?
Returns a list queue which contains all the elements in front-to-back order from all the list queues which are members of list-of-list-queues in front-to-back order. The result does not share storage with any of the arguments. This operation is O(n) in the total number of elements in all queues. It is not part of the R7RS-small list API, but is included here to make appending a large number of queues possible in Schemes that limit the number of arguments to apply.
(scheme list-queue) procedure (list-queue-map (proc procedure?) (list-queue list-queue?) ) ⟹ list-queue?
(proc element ) ⟹ *
Applies proc to each element of list-queue in unspecified order and returns a newly allocated list queue containing the results. This operation is O(n) where n is the length of list-queue.
(scheme list-queue) procedure (list-queue-map! (proc procedure?) (list-queue list-queue?) ) ⟹ undefined
(proc element ) ⟹ *
Applies proc to each element of list-queue in front-to-back order and modifies list-queue to contain the results. This operation is O(n) in the length of list-queue. It is not part of the R7RS-small list API, but is included here to make transformation of a list queue by mutation more efficient.
(scheme list-queue) procedure (list-queue-for-each (proc procedure?) (list-queue list-queue?) ) ⟹ undefined
(proc element ) ⟹ undefined
Applies proc to each element of list-queue in front-to-back order, discarding the returned values. Returns an unspecified value. This operation is O(n) where n is the length of list-queue.
library (scheme lseq)
(scheme lseq) procedure (generator->lseq (generator procedure?) ) ⟹ lseq?
(generator ) ⟹ *
Returns an lseq whose elements are the values generated by generator. The exact behavior is as follows:
(scheme lseq) procedure (lseq? x ) ⟹ boolean?
Returns #t if x is an lseq. This procedure may also return #t if x is an improper list whose last cdr is a procedure that requires arguments, since there is no portable way to examine a procedure to determine how many arguments it requires. Otherwise it returns #f.
(scheme lseq) procedure (lseq=? (elt=? procedure?) (lseq1 lseq?) (lseq2 lseq?) ) ⟹ boolean?
(elt=? a b ) ⟹ boolean?
Determines lseq equality, given an element-equality procedure. Two lseqs are equal if they are of the same length, and their corresponding elements are equal, as determined by elt=?. When elt=? is called, its first argument is always from lseq1 and its second argument is from lseq2.
The dynamic order in which the elt=? procedure is applied to pairs of elements is not specified.
The elt=? procedure must be consistent with eq?. This implies that two lseqs which are eq? are always lseq=?, as well; implementations may exploit this fact to "short-cut" the element-by-element equality tests.
(scheme lseq) procedure (lseq-car (lseq lseq?) ) ⟹ *
Returns the first element of lseq. It is included for completeness, as it is the same as car. It is an error to apply it to an empty lseq.
(scheme lseq) procedure (lseq-first (lseq lseq?) ) ⟹ *
Returns the first element of lseq. It is included for completeness, as it is the same as car. It is an error to apply it to an empty lseq.
(scheme lseq) procedure (lseq-cdr (lseq lseq?) ) ⟹ lseq?
Returns an lseq with the contents of lseq except for the first element. The exact behavior is as follows:
If obj is an end-of-file object, then the cdr of lseq is set to the empty list, which is returned.
If obj is any other object, then a new pair is allocated whose car is obj and whose cdr is the cdr of lseq (i.e. the procedure). The cdr of lseq is set to the newly allocated pair, which is returned.
(scheme lseq) procedure (lseq-rest (lseq lseq?) ) ⟹ lseq?
Returns an lseq with the contents of lseq except for the first element. The exact behavior is as follows:
If obj is an end-of-file object, then the cdr of lseq is set to the empty list, which is returned.
If obj is any other object, then a new pair is allocated whose car is obj and whose cdr is the cdr of lseq (i.e. the procedure). The cdr of lseq is set to the newly allocated pair, which is returned.
(scheme lseq) procedure (lseq-ref (lseq lseq?) (i integer?) ) ⟹ *
Returns the ith element of lseq. (This is the same as (lseq-first (lseq-drop lseq i)).) It is an error if i >= n, where n is the length of lseq.
(scheme lseq) procedure (lseq-take (lseq lseq?) (i integer?) ) ⟹ lseq?
lseq-take lazily returns the first i elements of lseq.
(scheme lseq) procedure (lseq-drop (lseq lseq?) (i integer?) ) ⟹ lseq?
lseq-drop returns all but the first i elements of lseq.
(scheme lseq) procedure (lseq-realize (lseq lseq?) ) ⟹ list?
Repeatedly applies lseq-cdr to lseq until its generator (if there is one) has been exhausted, and returns lseq, which is now guaranteed to be a proper list. This procedure can be called on an arbitrary lseq before passing it to a procedure which only accepts lists. However, if the generator never returns an end-of-file object, lseq-realize will never return.
(scheme lseq) procedure (lseq->generator (lseq lseq?) ) ⟹ procedure?
(return ) ⟹ *
Returns a generator which when invoked will return all the elements of lseq, including any that have not yet been realized.
(scheme lseq) procedure (lseq-length (lseq lseq?) ) ⟹ integer?
Returns the length of its argument, which is the non-negative integer n such that lseq-rest applied n times to the lseq produces an empty lseq. lseq must be finite, or this procedure will not return.
(scheme lseq) procedure (lseq-append (lseq lseq?) ... ) ⟹ lseq?
Returns an lseq that lazily contains all the elements of all the lseqs in order.
(scheme lseq) procedure (lseq-zip (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ lseq?
If lseq-zip is passed n lseqs, it lazily returns an lseq each element of which is an n-element list comprised of the corresponding elements from the lseqs. If any of the lseqs are finite in length, the result is as long as the shortest lseq.
(scheme lseq) procedure (lseq-map (proc procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ lseq?
(proc value1 value2 ... ) ⟹ *
The lseq-map procedure lazily applies proc element-wise to the corresponding elements of the lseqs, where proc is a procedure taking as many arguments as there are lseqs and returning a single value, and returns an lseq of the results in order. The dynamic order in which proc is applied to the elements of the lseqs is unspecified.
(scheme lseq) procedure (lseq-for-each (proc procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ *
(proc value1 value2 ... ) ⟹ *
The arguments to lseq-for-each are like the arguments to lseq-map, but lseq-for-each calls proc for its side effects rather than for its values. Unlike lseq-map, lseq-for-each is guaranteed to call proc on the elements of the lseqs in order from the first element(s) to the last, and the value returned by lseq-for-each is unspecified.
If none of the lseqs are finite, lseq-for-each never returns.
(scheme lseq) procedure (lseq-filter (pred procedure?) (lseq lseq?) ) ⟹ lseq?
(pred element ) ⟹ boolean?
The procedure lseq-filter lazily returns an lseq that contains only the elements of lseq that satisfy pred.
(scheme lseq) procedure (lseq-remove (pred procedure?) (lseq lseq?) ) ⟹ lseq?
(pred element ) ⟹ boolean?
The procedure lseq-remove is the same as lseq-filter, except that it returns elements that do not satisfy pred. These procedures are guaranteed to call pred on the elements of the lseqs in sequence order.
(scheme lseq) procedure (lseq-find (pred procedure?) (lseq lseq?) ) ⟹ *
(pred element ) ⟹ boolean?
Return the first element of lseq that satisfies predicate pred, or #f if no element does. It cannot reliably be applied to lseqs that include #f as an element; use lseq-find-tail instead. The predicate is guaranteed to be evaluated on the elements of lseq in sequence order, and only as often as necessary.
(scheme lseq) procedure (lseq-find-tail (pred procedure?) (lseq lseq?) ) ⟹ #f / lseq? /
(pred element ) ⟹ boolean?
Returns the longest tail of lseq whose first element satisfies pred, or #f if no element does. The predicate is guaranteed to be evaluated on the elements of lseq in sequence order, and only as often as necessary. lseq-find-tail can be viewed as a general-predicate variant of the lseq-member function.
(scheme lseq) procedure (lseq-take-while (pred procedure?) (lseq lseq?) ) ⟹ lseq?
(pred element ) ⟹ boolean?
Lazily returns the longest initial prefix of lseq whose elements all satisfy the predicate pred.
(scheme lseq) procedure (lseq-drop-while (pred procedure?) (lseq lseq?) ) ⟹ lseq?
(pred element ) ⟹ boolean?
Drops the longest initial prefix of lseq whose elements all satisfy the predicate pred, and returns the rest of the lseq. Note that lseq-drop-while is essentially lseq-find-tail where the sense of the predicate is inverted: lseq-find-tail searches until it finds an element satisfying the predicate; lseq-drop-while searches until it finds an element that doesn't satisfy the predicate.
(scheme lseq) procedure (lseq-any (pred procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ *
(pred element ) ⟹ *
Applies pred to successive elements of the lseqs, returning true if pred returns true on any application. If an application returns a true value, lseq-any immediately returns that value. Otherwise, it iterates until a true value is produced or one of the lseqs runs out of values; in the latter case, lseq-any returns #f. It is an error if pred does not accept the same number of arguments as there are lseqs and return a boolean result. Note the difference between lseq-find and lseq-any — lseq-find returns the element that satisfied the predicate; lseq-any returns the true value that the predicate produced. Like lseq-every, lseq-any's name does not end with a question mark — this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(scheme lseq) procedure (lseq-every (pred procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ *
(pred element ) ⟹ *
Applies pred to successive elements of the lseqs, returning true if the predicate returns true on every application. If an application returns a false value, lseq-every immediately returns that value. Otherwise, it iterates until a false value is produced or one of the lseqs runs out of values; in the latter case, lseq-every returns the last value returned by pred, or #t if pred was never invoked. It is an error if pred does not accept the same number of arguments as there are lseqs and return a boolean result. Like lseq-any, lseq-every's name does not end with a question mark — this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(scheme lseq) procedure (lseq-index (pred procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ integer? / #f /
(pred element ) ⟹ *
Return the index of the leftmost element that satisfies pred. Applies pred to successive elements of the lseqs, returning an index usable with lseq-ref if the predicate returns true. Otherwise, it iterates until one of the lseqs runs out of values, in which case #f is returned. It is an error if pred does not accept the same number of arguments as there are lseqs and return a boolean result. The iteration stops when one of the lseqs runs out of values; in this case, lseq-index returns #f.
(scheme lseq) procedure (lseq-member x (lseq lseq?) ) ⟹ #f / lseq? /
(scheme lseq) procedure (lseq-member x (lseq lseq?) (= procedure?) ) ⟹ #f / lseq? /
(= a b ) ⟹ boolean?
Returns the longest tail of lseq whose first element is x, where the tails of lseq are the non-empty lseqs returned by (lseq-drop lseq i) for i less than the length of lseq. If x does not occur in lseq, then #f is returned. lseq-member uses pred to compare x with the elements of lseq, which defaults to equal?.
The equality procedure is used to compare the elements ei of lseq to the key x in this way: the first argument is always x, and the second argument is one of the lseq elements. Thus one can reliably find the first element of lseq that is greater than five with (lseq-member 5 lseq <)
Note that fully general lseq searching may be performed with the lseq-find-tail procedure.
(scheme lseq) procedure (lseq-memq x (lseq lseq?) ) ⟹ #f / lseq? /
Returns the longest tail of lseq whose first element is x, where the tails of lseq are the non-empty lseqs returned by (lseq-drop lseq i) for i less than the length of lseq. If x does not occur in lseq, then #f is returned. lseq-memq uses eq? to compare x with the elements of lseq.
The equality procedure is used to compare the elements ei of lseq to the key x in this way: the first argument is always x, and the second argument is one of the lseq elements. Thus one can reliably find the first element of lseq that is greater than five with (lseq-member 5 lseq <)
Note that fully general lseq searching may be performed with the lseq-find-tail procedure.
(scheme lseq) procedure (lseq-memv x (lseq lseq?) ) ⟹ #f / lseq? /
Returns the longest tail of lseq whose first element is x, where the tails of lseq are the non-empty lseqs returned by (lseq-drop lseq i) for i less than the length of lseq. If x does not occur in lseq, then #f is returned. lseq-memv uses eqv? to compare x with the elements of lseq.
The equality procedure is used to compare the elements ei of lseq to the key x in this way: the first argument is always x, and the second argument is one of the lseq elements. Thus one can reliably find the first element of lseq that is greater than five with (lseq-member 5 lseq <)
Note that fully general lseq searching may be performed with the lseq-find-tail procedure.
library (scheme rlist)
(scheme rlist) procedure (rpair? obj ) ⟹ boolean?
Returns #t if obj is a pair, and otherwise returns #f.
(scheme rlist) procedure (rcons obj1 obj2 ) ⟹ rpair?
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. This operation must take O(1) time.
(scheme rlist) procedure (rcar (pair rpair?) ) ⟹ *
Returns the contents of the car field of pair. This operation must take O(1) time.
(scheme rlist) procedure (rcdr (pair rpair?) ) ⟹ *
Returns the contents of the cdr field of pair. This operation must take O(1) time.
(scheme rlist) procedure (rcaar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcadr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcdar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcddr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcaaar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcaadr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcadar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcaddr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcdaar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcdadr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcddar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcdddr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcaaaar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcaaadr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcaadar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcaaddr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcadaar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcadadr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcaddar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcadddr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcdaaar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcdaadr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcdadar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcdaddr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcddaar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcddadr (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcdddar (pair rpair?) ) ⟹ *
(scheme rlist) procedure (rcddddr (pair rpair?) ) ⟹ *
These procedures are compositions of car and cdr.
(scheme rlist) procedure (rnull? obj ) ⟹ boolean?
Returns #t if obj is the empty list, #f otherwise.
(scheme rlist) procedure (rlist? obj ) ⟹ boolean?
Returns #t if obj is a list, #f otherwise. By definition, all lists are chains of pairs that have finite length and are terminated by the empty list. This operation must take time bounded by O(log(n)), where n is the number of pairs in the chain forming the potential list.
(scheme rlist) procedure (rlist obj ... ) ⟹ rlist?
Returns a newly allocated list of its arguments. This operation must take time bounded by O(n), where n is the number of arguments to list.
(scheme rlist) procedure (make-rlist (k integer?) ) ⟹ rlist?
(scheme rlist) procedure (make-rlist (k integer?) obj ) ⟹ rlist?
Returns a newly allocated list of k elements. If a second argument is given, then each element is initialized to obj. Otherwise the initial contents of each element is unspecified. This operation must take time and space bounded by O(log(k)).
(scheme rlist) procedure (rlength (list rlist?) ) ⟹ integer?
Returns the length of list. This operation must take time bounded by O(log(n)), where n is the length of the list.
(scheme rlist) procedure (rlength<=? obj (k integer?) ) ⟹ boolean?
Returns true if obj is a chain of at least k pairs and false otherwise. This operation must take time bounded by O(log(min(k,n))), where n is the length of the chain of pairs.
(scheme rlist) procedure (rappend (list rlist?) ... ) ⟹ rlist?
(scheme rlist) procedure (rappend (list rlist?) ... obj ) ⟹ *
Returns a chain of pairs consisting of the elements of the first list followed by the elements of the other lists, with obj as the cdr of the final pair. An improper list results if obj is not a list. This operation must take time bounded by O(log(n)), where n is the total number of elements in the given lists.
(scheme rlist) procedure (rreverse (list rlist?) ) ⟹ rlist?
Returns a newly allocated list consisting of the element of list in reverse order. This operation must take time bounded by O(n) where n is the length of the list.
(scheme rlist) procedure (rlist-tail (list rlist?) (k integer?) ) ⟹ rlist?
(scheme rlist) procedure (rlist-tail obj (k integer?) ) ⟹ *
Obj should be a chain of pairs with a count of at least k. The list-tail procedure returns the object obtained by omitting the first k elements in obj. This operation must take time bounded by O(log(min(k,n))), where n is the length of the chain of pairs.
(scheme rlist) procedure (rlist-ref (pair rpair?) (k integer?) ) ⟹ *
Pair must be a chain of pairs whose count is at least k + 1. The list-ref procedure returns the kth element of pair. This operation must take time bounded by O(min(k,log(n))), where n is the length of the chain of pairs.
(scheme rlist) procedure (rlist-set (pair rpair?) (k integer?) obj ) ⟹ rpair?
Pair must be a chain of pairs whose count is at least k + 1. The list-set procedure returns the chain of pairs obtained by replacing the kth element with obj. This operation must take time bounded by O(min(k,log(n))), where n is the length of the chain of pairs.
(scheme rlist) procedure (rlist-ref/update (pair rpair?) (k integer?) (proc procedure?) ) ⟹ (values *rpair?)
(proc obj ) ⟹ *
Returns the same results as:
(values (list-ref pair k)
(list-set pair k (proc (list-ref pair k))))
but it may be implemented more efficiently.
(scheme rlist) procedure (rmap (proc procedure?) (list1 rlist?) (list2 rlist?) ... ) ⟹ rlist?
(proc obj1 obj2 ... ) ⟹ *
The lists should all have the same length. Proc should 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. Proc is always called in the same dynamic environment as map itself. The order in which proc is applied to the elements of the lists is unspecified.
(scheme rlist) procedure (rfor-each (proc procedure?) (list1 rlist?) (list2 rlist?) ... ) ⟹ undefined
(proc obj1 obj2 ... ) ⟹ undefined
The lists should all have the same length. Proc should accept as many arguments as there are lists.
The for-each procedure applies proc element-wise to the elements of the lists for its side effects, in order from the first element to the last. Proc is always called in the same dynamic environment as for-each itself. The return values of for-each are unspecified.
(scheme rlist) procedure (rlist->list (rlist rlist?) ) ⟹ list?
(scheme rlist) procedure (list->rlist (list list?) ) ⟹ rlist?
These procedures convert between (potentially) distinct representations of lists. To avoid confusion, parameters named ra-list range over lists represented with random-access lists, i.e. objects satisfying the list? predicate described above, while parameters named la-list range over lists represented with the more traditional linear-access lists, i.e. objects satisfying the list? predicate of R6RS. In systems that represent all lists as random-access lists, these conversions may simply be list identity procedures.
library (scheme set)
(scheme set) procedure (set (comparator comparator?) element ... ) ⟹ set?
Returns a newly allocated empty set. The comparator argument is a SRFI 114 comparator, which is used to control and distinguish the elements of the set. The elements are used to initialize the set.
(scheme set) procedure (set-unfold (comparator comparator?) (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ set?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Create a newly allocated set as if by set using comparator. If the result of applying the predicate stop? to seed is true, return the set. Otherwise, apply the procedure mapper to seed. The value that mapper returns is added to the set. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
(scheme set) procedure (set? obj ) ⟹ boolean?
Returns #t if obj is a set, and #f otherwise.
(scheme set) procedure (set-contains? (set set?) element ) ⟹ boolean?
Returns #t if element is a member of set and #f otherwise.
(scheme set) procedure (set-empty? (set set?) ) ⟹ boolean?
Returns #t if set has no elements and #f otherwise.
(scheme set) procedure (set-disjoint? (set1 set?) (set2 set?) ) ⟹ boolean?
Returns #t if set1 and set2 have no elements in common and #f otherwise.
(scheme set) procedure (set-member (set set?) element default ) ⟹ *
Returns the element of set that is equal, in the sense of set's equality predicate, to element. If element is not a member of set, default is returned.
(scheme set) procedure (set-element-comparator (set set?) ) ⟹ comparator?
Returns the comparator used to compare the elements of set.
(scheme set) procedure (set-adjoin (set set?) element ... ) ⟹ set?
The set-adjoin procedure returns a newly allocated set that uses the same comparator as set and contains all the values of set, and in addition each element unless it is already equal (in the sense of the comparator) to one of the existing or newly added members. It is an error to add an element to set that does not return #t when passed to the type test procedure of the comparator.
(scheme set) procedure (set-adjoin! (set set?) element ... ) ⟹ set?
The set-adjoin! procedure is the same as set-adjoin, except that it is permitted to mutate and return the set argument rather than allocating a new set.
(scheme set) procedure (set-replace (set set?) element ) ⟹ set?
The set-replace procedure returns a newly allocated set that uses the same comparator as set and contains all the values of set except as follows: If element is equal (in the sense of set's comparator) to an existing member of set, then that member is omitted and replaced by element. If there is no such element in set, then set is returned unchanged.
(scheme set) procedure (set-replace! (set set?) element ) ⟹ set?
The set-replace! procedure is the same as set-replace, except that it is permitted to mutate and return the set argument rather than allocating a new set.
(scheme set) procedure (set-delete (set set?) element ... ) ⟹ set?
The set-delete procedure returns a newly allocated set containing all the values of set except for any that are equal (in the sense of set's comparator) to one or more of the elements. Any element that is not equal to some member of the set is ignored.
(scheme set) procedure (set-delete! (set set?) element ... ) ⟹ set?
The set-delete! procedure is the same as set-delete, except that it is permitted to mutate and return the set argument rather than allocating a new set.
(scheme set) procedure (set-delete-all (set set?) (elements list?) ) ⟹ set?
The set-delete-all procedure is the same as set-delete, except that it accepts a single argument which is a list of elements to be deleted.
(scheme set) procedure (set-delete-all! (set set?) (elements list?) ) ⟹ set?
The set-delete-all! procedure is the same as set-delete!, except that it accepts a single argument which is a list of elements to be deleted.
(scheme set) procedure (set-search! (set set?) element (failure procedure?) (success procedure?) ) ⟹ (values set?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert obj ) ⟹ *
(ignore obj ) ⟹ *
(success element (update procedure?) (remove procedure?) ) ⟹ *
(update new-element obj ) ⟹ *
(remove obj ) ⟹ *
The set is searched for element. If it is not found, then the failure procedure is tail-called with two continuation arguments, insert and ignore, and is expected to tail-call one of them. If element is found, then the success procedure is tail-called with the matching element of set and two continuations, update and remove, and is expected to tail-call one of them. The effects of the continuations are as follows (where obj is any Scheme object):
In all cases, two values are returned: the possibly updated set and obj.
(scheme set) procedure (set-size (set set?) ) ⟹ integer?
Returns the number of elements in set as an exact integer.
(scheme set) procedure (set-find (predicate procedure?) (set set?) (failure procedure?) ) ⟹ *
(predicate obj ) ⟹ boolean?
(failure ) ⟹ *
Returns an arbitrarily chosen element of set that satisfies predicate, or the result of invoking failure with no arguments if there is none.
(scheme set) procedure (set-count (predicate procedure?) (set set?) ) ⟹ integer?
(predicate obj ) ⟹ boolean?
Returns the number of elements of set that satisfy predicate as an exact integer.
(scheme set) procedure (set-any? (predicate procedure?) (set set?) ) ⟹ boolean?
(predicate obj ) ⟹ boolean?
Returns #t if any element of set satisfies predicate, or #f otherwise. Note that this differs from the SRFI 1 analogue because it does not return an element of the set.
(scheme set) procedure (set-every? (predicate procedure?) (set set?) ) ⟹ boolean?
(predicate obj ) ⟹ boolean?
Returns #t if every element of set satisfies predicate, or #f otherwise. Note that this differs from the SRFI 1 analogue because it does not return an element of the set.
(scheme set) procedure (set-map (comparator comparator?) (proc procedure?) (set set?) ) ⟹ *
(proc obj ) ⟹ *
Applies proc to each element of set in arbitrary order and returns a newly allocated set, created as if by (set comparator), which contains the results of the applications. For example:
(set-map string-ci-comparator symbol->string (set eq? 'foo 'bar 'baz)) => (set string-ci-comparator "foo" "bar" "baz")
Note that, when proc defines a mapping that is not 1:1, some of the mapped objects may be equivalent in the sense of comparator's equality predicate, and in this case duplicate elements are omitted as in the set constructor.
(scheme set) procedure (set-for-each (proc procedure?) (set set?) ) ⟹ undefined
(proc obj ) ⟹ undefined
Applies proc to set in arbitrary order, discarding the returned values. Returns an unspecified result.
(scheme set) procedure (set-fold (proc procedure?) nil (set set?) ) ⟹ *
(proc obj state ) ⟹ *
Invokes proc on each member of set in arbitrary order, passing the result of the previous invocation as a second argument. For the first invocation, nil is used as the second argument. Returns the result of the last invocation, or nil if there was no invocation.
(scheme set) procedure (set-filter (predicate procedure?) (set set?) ) ⟹ set?
(predicate obj ) ⟹ *
Returns a newly allocated set with the same comparator as set, containing just the elements of set that satisfy predicate.
(scheme set) procedure (set-filter! (predicate procedure?) (set set?) ) ⟹ set?
(predicate obj ) ⟹ *
A linear update procedure that returns a set containing just the elements of set that satisfy predicate.
(scheme set) procedure (set-remove (predicate procedure?) (set set?) ) ⟹ set?
(predicate obj ) ⟹ *
Returns a newly allocated set with the same comparator as set, containing just the elements of set that do not satisfy predicate.
(scheme set) procedure (set-remove! (predicate procedure?) (set set?) ) ⟹ set?
(predicate obj ) ⟹ *
A linear update procedure that returns a set containing just the elements of set that do not satisfy predicate.
(scheme set) procedure (set-partition (predicate procedure?) (set set?) ) ⟹ (values set?set?)
(predicate obj ) ⟹ *
Returns two values: a newly allocated set with the same comparator as set that contains just the elements of set that satisfy predicate, and another newly allocated set, also with the same comparator, that contains just the elements of set that do not satisfy predicate.
(scheme set) procedure (set-partition! (predicate procedure?) (set set?) ) ⟹ (values set?set?)
(predicate obj ) ⟹ *
A linear update procedure that returns two sets containing the elements of set that do and do not, respectively, not satisfy predicate.
(scheme set) procedure (set-copy (set set?) ) ⟹ set?
Returns a newly allocated set containing the elements of set, and using the same comparator.
(scheme set) procedure (set->list (set set?) ) ⟹ list?
Returns a newly allocated list containing the members of set in unspecified order.
(scheme set) procedure (list->set (comparator comparator?) (list list?) ) ⟹ set?
Returns a newly allocated set, created as if by set using comparator, that contains the elements of list. Duplicate elements (in the sense of the equality predicate) are omitted.
(scheme set) procedure (list->set! (set set?) (list list?) ) ⟹ set?
Returns a set that contains the elements of both set and list. Duplicate elements (in the sense of the equality predicate) are omitted.
(scheme set) procedure (set=? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set contains the same elements.
(scheme set) procedure (set<? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set other than the last is a proper subset of the following set, and #f otherwise.
(scheme set) procedure (set>? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set other than the last is a proper superset of the following set, and #f otherwise.
(scheme set) procedure (set<=? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set other than the last is a subset of the following set, and #f otherwise.
(scheme set) procedure (set>=? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set other than the last is a superset of the following set, and #f otherwise.
(scheme set) procedure (set-union (set1 set?) (set2 set?) ... ) ⟹ set?
Return a newly allocated set that is the union of the sets.
(scheme set) procedure (set-intersection (set1 set?) (set2 set?) ... ) ⟹ set?
Return a newly allocated set that is the intersection of the sets.
(scheme set) procedure (set-difference (set1 set?) (set2 set?) ... ) ⟹ set?
Return a newly allocated set that is the asymmetric difference of the sets. Asymmetric difference is extended to more than two sets by taking the difference between the first set and the union of the others.
(scheme set) procedure (set-xor (set1 set?) (set2 set?) ) ⟹ set?
Return a newly allocated set that is the symmetric difference of the sets. Symmetric difference is not extended beyond two sets. Elements in the result set are drawn from the first set in which they appear.
(scheme set) procedure (set-union! (set1 set?) (set2 set?) ... ) ⟹ set?
Linear update returning a set that is the union of the sets.
(scheme set) procedure (set-intersection! (set1 set?) (set2 set?) ... ) ⟹ set?
Linear update returning a set that is the intersection of the sets.
(scheme set) procedure (set-difference! (set1 set?) (set2 set?) ... ) ⟹ set?
Linear update returning a set that is the asymmetric difference of the sets. Asymmetric difference is extended to more than two sets by taking the difference between the first set and the union of the others.
(scheme set) procedure (set-xor! (set1 set?) (set2 set?) ) ⟹ set?
Linear update returning a set that is the symmetric difference of the sets. Symmetric difference is not extended beyond two sets. Elements in the result set are drawn from the first set in which they appear.
(scheme set) procedure (bag (comparator comparator?) element ... ) ⟹ bag?
Returns a newly allocated empty bag. The comparator argument is a SRFI 114 comparator, which is used to control and distinguish the elements of the bag. The elements are used to initialize the bag.
(scheme set) procedure (bag-unfold (comparator comparator?) (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ bag?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Create a newly allocated bag as if by bag using comparator. If the result of applying the predicate stop? to seed is true, return the bag. Otherwise, apply the procedure mapper to seed. The value that mapper returns is added to the bag. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
(scheme set) procedure (bag? obj ) ⟹ boolean?
Returns #t if obj is a bag, and #f otherwise.
(scheme set) procedure (bag-contains? (bag bag?) element ) ⟹ boolean?
Returns #t if element is a member of bag and #f otherwise.
(scheme set) procedure (bag-empty? (bag bag?) ) ⟹ boolean?
Returns #t if bag has no elements and #f otherwise.
(scheme set) procedure (bag-disjoint? (bag1 bag?) (bag2 bag?) ) ⟹ boolean?
Returns #t if bag1 and bag2 have no elements in common and #f otherwise.
(scheme set) procedure (bag-member (bag bag?) element default ) ⟹ *
Returns the element of bag that is equal, in the sense of bag's equality predicate, to element. If element is not a member of bag, default is returned.
(scheme set) procedure (bag-element-comparator (bag bag?) ) ⟹ comparator?
Returns the comparator used to compare the elements of bag.
(scheme set) procedure (bag-adjoin (bag bag?) element ... ) ⟹ bag?
The bag-adjoin procedure returns a newly allocated bag that uses the same comparator as bag and contains all the values of bag, and in addition each element unless it is already equal (in the sense of the comparator) to one of the existing or newly added members. It is an error to add an element to bag that does not return #t when passed to the type test procedure of the comparator.
(scheme set) procedure (bag-adjoin! (bag bag?) element ... ) ⟹ bag?
The bag-adjoin! procedure is the same as bag-adjoin, except that it is permitted to mutate and return the bag argument rather than allocating a new bag.
(scheme set) procedure (bag-replace (bag bag?) element ) ⟹ bag?
The bag-replace procedure returns a newly allocated bag that uses the same comparator as bag and contains all the values of bag except as follows: If element is equal (in the sense of bag's comparator) to an existing member of bag, then that member is omitted and replaced by element. If there is no such element in bag, then bag is returned unchanged.
(scheme set) procedure (bag-replace! (bag bag?) element ) ⟹ bag?
The bag-replace! procedure is the same as bag-replace, except that it is permitted to mutate and return the bag argument rather than allocating a new bag.
(scheme set) procedure (bag-delete (bag bag?) element ... ) ⟹ bag?
The bag-delete procedure returns a newly allocated bag containing all the values of bag except for any that are equal (in the sense of bag's comparator) to one or more of the elements. Any element that is not equal to some member of the bag is ignored.
(scheme set) procedure (bag-delete! (bag bag?) element ... ) ⟹ bag?
The bag-delete! procedure is the same as bag-delete, except that it is permitted to mutate and return the bag argument rather than allocating a new bag.
(scheme set) procedure (bag-delete-all (bag bag?) (elements list?) ) ⟹ bag?
The bag-delete-all procedure is the same as bag-delete, except that it accepts a single argument which is a list of elements to be deleted.
(scheme set) procedure (bag-delete-all! (bag bag?) (elements list?) ) ⟹ bag?
The bag-delete-all! procedure is the same as bag-delete!, except that it accepts a single argument which is a list of elements to be deleted.
(scheme set) procedure (bag-search! (bag bag?) element (failure procedure?) (success procedure?) ) ⟹ (values bag?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert obj ) ⟹ *
(ignore obj ) ⟹ *
(success element (update procedure?) (remove procedure?) ) ⟹ *
(update new-element obj ) ⟹ *
(remove obj ) ⟹ *
The bag is searched for element. If it is not found, then the failure procedure is tail-called with two continuation arguments, insert and ignore, and is expected to tail-call one of them. If element is found, then the success procedure is tail-called with the matching element of bag and two continuations, update and remove, and is expected to tail-call one of them. The effects of the continuations are as follows (where obj is any Scheme object):
In all cases, two values are returned: the possibly updated bag and obj.
(scheme set) procedure (bag-size (bag bag?) ) ⟹ integer?
Returns the number of elements in bag as an exact integer.
(scheme set) procedure (bag-find (predicate procedure?) (bag bag?) (failure procedure?) ) ⟹ *
(predicate obj ) ⟹ boolean?
(failure ) ⟹ *
Returns an arbitrarily chosen element of bag that satisfies predicate, or the result of invoking failure with no arguments if there is none.
(scheme set) procedure (bag-count (predicate procedure?) (bag bag?) ) ⟹ integer?
(predicate obj ) ⟹ boolean?
Returns the number of elements of bag that satisfy predicate as an exact integer.
(scheme set) procedure (bag-any? (predicate procedure?) (bag bag?) ) ⟹ boolean?
(predicate obj ) ⟹ boolean?
Returns #t if any element of bag satisfies predicate, or #f otherwise. Note that this differs from the SRFI 1 analogue because it does not return an element of the bag.
(scheme set) procedure (bag-every? (predicate procedure?) (bag bag?) ) ⟹ boolean?
(predicate obj ) ⟹ boolean?
Returns #t if every element of bag satisfies predicate, or #f otherwise. Note that this differs from the SRFI 1 analogue because it does not return an element of the bag.
(scheme set) procedure (bag-map (comparator comparator?) (proc procedure?) (bag bag?) ) ⟹ *
(proc obj ) ⟹ *
Applies proc to each element of bag in arbitrary order and returns a newly allocated bag, created as if by (bag comparator), which contains the results of the applications. For example:
(bag-map string-ci-comparator symbol->string (bag eq? 'foo 'bar 'baz)) => (bag string-ci-comparator "foo" "bar" "baz")
Note that, when proc defines a mapping that is not 1:1, some of the mapped objects may be equivalent in the sense of comparator's equality predicate, and in this case duplicate elements are omitted as in the bag constructor.
(scheme set) procedure (bag-for-each (proc procedure?) (bag bag?) ) ⟹ undefined
(proc obj ) ⟹ undefined
Applies proc to bag in arbitrary order, discarding the returned values. Returns an unspecified result.
(scheme set) procedure (bag-fold (proc procedure?) nil (bag bag?) ) ⟹ *
(proc obj state ) ⟹ *
Invokes proc on each member of bag in arbitrary order, passing the result of the previous invocation as a second argument. For the first invocation, nil is used as the second argument. Returns the result of the last invocation, or nil if there was no invocation.
(scheme set) procedure (bag-filter (predicate procedure?) (bag bag?) ) ⟹ bag?
(predicate obj ) ⟹ *
Returns a newly allocated bag with the same comparator as bag, containing just the elements of bag that satisfy predicate.
(scheme set) procedure (bag-filter! (predicate procedure?) (bag bag?) ) ⟹ bag?
(predicate obj ) ⟹ *
A linear update procedure that returns a bag containing just the elements of bag that satisfy predicate.
(scheme set) procedure (bag-remove (predicate procedure?) (bag bag?) ) ⟹ bag?
(predicate obj ) ⟹ *
Returns a newly allocated bag with the same comparator as bag, containing just the elements of bag that do not satisfy predicate.
(scheme set) procedure (bag-remove! (predicate procedure?) (bag bag?) ) ⟹ bag?
(predicate obj ) ⟹ *
A linear update procedure that returns a bag containing just the elements of bag that do not satisfy predicate.
(scheme set) procedure (bag-partition (predicate procedure?) (bag bag?) ) ⟹ (values bag?bag?)
(predicate obj ) ⟹ *
Returns two values: a newly allocated bag with the same comparator as bag that contains just the elements of bag that satisfy predicate, and another newly allocated bag, also with the same comparator, that contains just the elements of bag that do not satisfy predicate.
(scheme set) procedure (bag-partition! (predicate procedure?) (bag bag?) ) ⟹ (values bag?bag?)
(predicate obj ) ⟹ *
A linear update procedure that returns two bags containing the elements of bag that do and do not, respectively, not satisfy predicate.
(scheme set) procedure (bag-copy (bag bag?) ) ⟹ bag?
Returns a newly allocated bag containing the elements of bag, and using the same comparator.
(scheme set) procedure (bag->list (bag bag?) ) ⟹ list?
Returns a newly allocated list containing the members of bag in unspecified order.
(scheme set) procedure (list->bag (comparator comparator?) (list list?) ) ⟹ bag?
Returns a newly allocated bag, created as if by bag using comparator, that contains the elements of list. Duplicate elements (in the sense of the equality predicate) are omitted.
(scheme set) procedure (list->bag! (bag bag?) (list list?) ) ⟹ bag?
Returns a bag that contains the elements of both bag and list. Duplicate elements (in the sense of the equality predicate) are omitted.
(scheme set) procedure (bag=? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag contains the same elements.
(scheme set) procedure (bag<? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag other than the last is a proper subbag of the following bag, and #f otherwise.
(scheme set) procedure (bag>? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag other than the last is a proper superbag of the following bag, and #f otherwise.
(scheme set) procedure (bag<=? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag other than the last is a subbag of the following bag, and #f otherwise.
(scheme set) procedure (bag>=? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag other than the last is a superbag of the following bag, and #f otherwise.
(scheme set) procedure (bag-union (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Return a newly allocated bag that is the union of the bags.
(scheme set) procedure (bag-intersection (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Return a newly allocated bag that is the intersection of the bags.
(scheme set) procedure (bag-difference (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Return a newly allocated bag that is the asymmetric difference of the bags. Asymmetric difference is extended to more than two bags by taking the difference between the first bag and the union of the others.
(scheme set) procedure (bag-xor (bag1 bag?) (bag2 bag?) ) ⟹ bag?
Return a newly allocated bag that is the symmetric difference of the bags. Symmetric difference is not extended beyond two bags. Elements in the result bag are drawn from the first bag in which they appear.
(scheme set) procedure (bag-union! (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Linear update returning a bag that is the union of the bags.
(scheme set) procedure (bag-intersection! (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Linear update returning a bag that is the intersection of the bags.
(scheme set) procedure (bag-difference! (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Linear update returning a bag that is the asymmetric difference of the bags. Asymmetric difference is extended to more than two bags by taking the difference between the first bag and the union of the others.
(scheme set) procedure (bag-xor! (bag1 bag?) (bag2 bag?) ) ⟹ bag?
Linear update returning a bag that is the symmetric difference of the bags. Symmetric difference is not extended beyond two bags. Elements in the result bag are drawn from the first bag in which they appear.
(scheme set) procedure (bag-sum (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
The bag-sum procedure returns a newly allocated bag containing all the unique elements in all the bags, such that the count of each unique element in the result is equal to the sum of the counts of that element in the arguments. It differs from bag-union by treating identical elements as potentially distinct rather than attempting to match them up.
(scheme set) procedure (bag-sum! (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Linear update returning a bag containing all the unique elements in all the bags, such that the count of each unique element in the result is equal to the sum of the counts of that element in the arguments. It differs from bag-union by treating identical elements as potentially distinct rather than attempting to match them up.
(scheme set) procedure (bag-product (n integer?) (bag bag?) ) ⟹ bag?
The bag-product procedure returns a newly allocated bag containing all the unique elements in bag, where the count of each unique element in the bag is equal to the count of that element in bag multiplied by n.
(scheme set) procedure (bag-product! (n integer?) (bag bag?) ) ⟹ bag?
Linear update returning a bag containing all the unique elements in bag, where the count of each unique element in the bag is equal to the count of that element in bag multiplied by n.
(scheme set) procedure (bag-unique-size (bag bag?) ) ⟹ integer?
Returns the number of unique elements of bag.
(scheme set) procedure (bag-element-count (bag bag?) element ) ⟹ integer?
Returns an exact integer representing the number of times that element appears in bag.
(scheme set) procedure (bag-for-each-unique (proc procedure?) (bag bag?) ) ⟹ undefined
(proc obj ) ⟹ undefined
Applies proc to each unique element of bag in arbitrary order, passing the element and the number of times it occurs in bag, and discarding the returned values. Returns an unspecified result.
(scheme set) procedure (bag-fold-unique (proc procedure?) nil (bag bag?) ) ⟹ *
(proc obj state ) ⟹ *
Invokes proc on each unique element of bag in arbitrary order, passing the number of occurrences as a second argument and the result of the previous invocation as a third argument. For the first invocation, nil is used as the third argument. Returns the result of the last invocation.
(scheme set) procedure (bag-increment! (bag bag?) element count ) ⟹ bag?
Linear update procedure that returns a bag with the same elements as bag, but with the element count of element in bag increased by the exact integer count (but not less than zero).
(scheme set) procedure (bag-decrement! (bag bag?) element count ) ⟹ bag?
Linear update procedure that returns a bag with the same elements as bag, but with the element count of element in bag decreased by the exact integer count (but not less than zero).
(scheme set) procedure (bag->set (bag bag?) ) ⟹ set?
The bag->set procedure returns a newly allocated set containing the unique elements (in the sense of the equality predicate) of bag.
(scheme set) procedure (set->bag (set set?) ) ⟹ bag?
The set->bag procedure returns a newly allocated bag containing the elements of set.
(scheme set) procedure (set->bag! (set set?) ) ⟹ bag?
The set->bag! procedure returns a bag containing the elements of both bag and set.
(scheme set) procedure (bag->alist (bag bag?) ) ⟹ list?
The bag->alist procedure returns a newly allocated alist whose keys are the unique elements of bag and whose values are the number of occurrences of each element.
(scheme set) procedure (alist->bag (comparator comparator?) (alist list?) ) ⟹ bag?
The alist->bag returning a newly allocated bag based on comparator, where the keys of alist specify the elements and the corresponding values of alist specify how many times they occur.
set-comparator ⟹ comparator?
Set comparator. The comparator does not provide comparison procedures, as there is no ordering between sets. It is an error to compare sets with different element comparators.
bag-comparator ⟹ comparator?
Bag comparator. The comparator does not provide comparison procedures, as there is no ordering between bags. It is an error to compare bags with different element comparators.
library (scheme stream)
stream-null ⟹ stream-null?
Stream-null is a promise that, when forced, is a single object, distinguishable from all other objects, that represents the null stream. Stream-null is immutable and unique.
(scheme stream) syntax (stream-cons () ((_ obj stream) stream-pair? ) )
stream ⟹ stream?
Stream-cons is a macro that accepts an object and a stream and creates a newly-allocated stream containing a promise that, when forced, is a stream-pair with the object in its stream-car and the stream in its stream-cdr. Stream-cons must be syntactic, not procedural, because neither object nor stream is evaluated when stream-cons is called. Since stream is not evaluated, when the stream-pair is created, it is not an error to call stream-cons with a stream that is not of type stream; however, doing so will cause an error later when the stream-cdr of the stream-pair is accessed. Once created, a stream-pair is immutable; there is no stream-set-car! or stream-set-cdr! that modifies an existing stream-pair. There is no dotted-pair or improper stream as with lists.
(scheme stream) procedure (stream? obj ) ⟹ boolean?
Stream? is a procedure that takes an object and returns #t if the object is a stream and #f otherwise. If object is a stream, stream? does not force its promise. If (stream? obj) is #t, then one of (stream-null? obj) and (stream-pair? obj) will be #t and the other will be #f; if (stream? obj) is #f, both (stream-null? obj) and (stream-pair? obj) will be #f.
(scheme stream) procedure (stream-null? obj ) ⟹ boolean?
Stream-null? is a procedure that takes an object and returns #t if the object is the distinguished null stream and #f otherwise. If object is a stream, stream-null? must force its promise in order to distinguish stream-null from stream-pair.
(scheme stream) procedure (stream-pair? obj ) ⟹ boolean?
Stream-pair? is a procedure that takes an object and returns #t if the object is a stream-pair constructed by stream-cons and #f otherwise. If object is a stream, stream-pair? must force its promise in order to distinguish stream-null from stream-pair.
(scheme stream) procedure (stream-car (stream stream-pair?) ) ⟹ *
Stream-car is a procedure that takes a stream and returns the object stored in the stream-car of the stream. Stream-car signals an error if the object passed to it is not a stream-pair. Calling stream-car causes the object stored there to be evaluated if it has not yet been; the object’s value is cached in case it is needed again.
(scheme stream) procedure (stream-cdr (stream stream-pair?) ) ⟹ stream?
Stream-car is a procedure that takes a stream and returns the object stored in the stream-car of the stream. Stream-car signals an error if the object passed to it is not a stream-pair. Calling stream-car causes the object stored there to be evaluated if it has not yet been; the object’s value is cached in case it is needed again.
(scheme stream) syntax (stream-lambda () ((_ formals body) procedure? ) )
(variable1 ...) variable (variable1 ... variable_n . variable_n+1)
Stream-lambda creates a procedure that returns a promise to evaluate the body of the procedure. The last body expression to be evaluated must yield a stream. As with normal lambda, args may be a single variable name, in which case all the formal arguments are collected into a single list, or a list of variable names, which may be null if there are no arguments, proper if there are an exact number of arguments, or dotted if a fixed number of arguments is to be followed by zero or more arguments collected into a list. Body must contain at least one expression, and may contain internal definitions preceding any expressions to be evaluated.
(scheme stream) syntax (define-stream () ((_ (variable parameter1 ...) body)) ((_ (variable parameter1 ... . parameter) body)) )
Define-stream creates a procedure that returns a stream, and may appear anywhere a normal define may appear, including as an internal definition, and may have internal definitions of its own, including other define-streams. The defined procedure takes arguments in the same way as stream-lambda. Define-stream is syntactic sugar on stream-lambda; see also stream-let, which is also a sugaring of stream-lambda.
(scheme stream) procedure (list->stream (list-of-objects list?) ) ⟹ stream?
[α] → {α}
List->stream takes a list of objects and returns a newly-allocated stream containing in its elements the objects in the list. Since the objects are given in a list, they are evaluated when list->stream is called, before the stream is created. If the list of objects is null, as in (list->stream '()), the null stream is returned. See also stream.
(scheme stream) procedure (port->stream ) ⟹ stream?
(scheme stream) procedure (port->stream (port input-port?) ) ⟹ stream?
port → {char}
Port->stream takes a port and returns a newly-allocated stream containing in its elements the characters on the port. If port is not given it defaults to the current input port. The returned stream has finite length and is terminated by stream-null.
(scheme stream) syntax (stream () ((_ object ...) stream? ) )
Stream is syntax that takes zero or more objects and creates a newly-allocated stream containing in its elements the objects, in order. Since stream is syntactic, the objects are evaluated when they are accessed, not when the stream is created. If no objects are given, as in (stream), the null stream is returned. See also list->stream.
(scheme stream) procedure (stream->list (stream stream?) ) ⟹ list?
(scheme stream) procedure (stream->list (n integer?) (stream stream?) ) ⟹ list?
nat × {α} → [α]
Stream->list takes a natural number n and a stream and returns a newly-allocated list containing in its elements the first n items in the stream. If the stream has less than n items all the items in the stream will be included in the returned list. If n is not given it defaults to infinity, which means that unless stream is finite stream->list will never return.
(scheme stream) procedure (stream-append (stream stream?) ... ) ⟹ stream?
{α} ... → {α}
Stream-append returns a newly-allocated stream containing in its elements those elements contained in its input streams, in order of input. If any of the input streams is infinite, no elements of any of the succeeding input streams will appear in the output stream; thus, if x is infinite, (stream-append x y) ≡ x. See also stream-concat.
(scheme stream) procedure (stream-concat (stream-of-streams stream?) ) ⟹ stream?
{{α}} ... → {α}
Stream-concat takes a stream consisting of one or more streams and returns a newly-allocated stream containing all the elements of the input streams. If any of the streams in the input stream is infinite, any remaining streams in the input stream will never appear in the output stream. See also stream-append.
(scheme stream) procedure (stream-constant object ... ) ⟹ stream?
α ... → {α}
Stream-constant takes one or more objects and returns a newly-allocated stream containing in its elements the objects, repeating the objects in succession forever.
(scheme stream) procedure (stream-drop (n integer?) (stream stream?) ) ⟹ stream?
nat × {α} → {α}
Stream-drop returns the suffix of the input stream that starts at the next element after the first n elements. The output stream shares structure with the input stream; thus, promises forced in one instance of the stream are also forced in the other instance of the stream. If the input stream has less than n elements, stream-drop returns the null stream. See also stream-take.
(scheme stream) procedure (stream-drop-while (pred? procedure?) (stream stream?) ) ⟹ stream?
(pred? obj ) ⟹ boolean?
(α → boolean) × {α} → {α}
Stream-drop-while returns the suffix of the input stream that starts at the first element x for which (pred? x) is #f. The output stream shares structure with the input stream. See also stream-take-while.
(scheme stream) procedure (stream-filter (pred? procedure?) (stream stream?) ) ⟹ stream?
(pred? obj ) ⟹ boolean?
(α → boolean) × {α} → {α}
Stream-filter returns a newly-allocated stream that contains only those elements x of the input stream for which (pred? x) is non-#f.
(scheme stream) procedure (stream-fold (proc procedure?) base (stream stream?) ) ⟹ *
(proc base element ) ⟹ *
(α × β → α) × α × {β} → α
Stream-fold applies a binary procedure to base and the first element of stream to compute a new base, then applies the procedure to the new base and the next element of stream to compute a succeeding base, and so on, accumulating a value that is finally returned as the value of stream-fold when the end of the stream is reached. Stream must be finite, or stream-fold will enter an infinite loop. See also stream-scan, which is similar to stream-fold, but useful for infinite streams. For readers familiar with other functional languages, this is a left-fold; there is no corresponding right-fold, since right-fold relies on finite streams that are fully-evaluated, at which time they may as well be converted to a list.
(scheme stream) procedure (stream-for-each (proc procedure?) (stream1 stream?) ... ) ⟹ undefined
(proc element1 ... ) ⟹ undefined
(α × β × ...) × {α} × {β} ...
Stream-for-each applies a procedure element-wise to corresponding elements of the input streams for its side-effects; it returns nothing. Stream-for-each stops as soon as any of its input streams is exhausted.
(scheme stream) procedure (stream-from (from number?) ) ⟹ stream?
(scheme stream) procedure (stream-from (from number?) (step number?) ) ⟹ stream?
number × number → {number}
Stream-from creates a newly-allocated stream that contains first as its first element and increments each succeeding element by step. If step is not given it defaults to 1. First and step may be of any numeric type. Stream-from is frequently useful as a generator in stream-of expressions. See also stream-range for a similar procedure that creates finite streams.
(scheme stream) procedure (stream-iterate (proc procedure?) base ) ⟹ stream?
(proc element ) ⟹ *
(α → α) × α → {α}
Stream-iterate creates a newly-allocated stream containing base in its first element and applies proc to each element in turn to determine the succeeding element. See also stream-unfold and stream-unfolds.
(scheme stream) procedure (stream-length (stream stream?) ) ⟹ integer?
{α} → nat
Stream-length takes an input stream and returns the number of elements in the stream; it does not evaluate its elements. Stream-length may only be used on finite streams; it enters an infinite loop with infinite streams.
(scheme stream) syntax (stream-let () ((_ tag ((var expr) ...) body)) )
Stream-let creates a local scope that binds each variable to the value of its corresponding expression. It additionally binds tag to a procedure which takes the bound variables as arguments and body as its defining expressions, binding the tag with stream-lambda. Tag is in scope within body, and may be called recursively. When the expanded expression defined by the stream-let is evaluated, stream-let evaluates the expressions in its body in an environment containing the newly-bound variables, returning the value of the last expression evaluated, which must yield a stream.
Stream-let provides syntactic sugar on stream-lambda, in the same manner as normal let provides syntactic sugar on normal lambda. However, unlike normal let, the tag is required, not optional, because unnamed stream-let is meaningless.
(scheme stream) procedure (stream-map (proc procedure?) (stream1 stream?) ... ) ⟹ stream?
(proc element1 ... ) ⟹ *
(α × β ... → ω) × {α} × {β} ... → {ω}
Stream-map applies a procedure element-wise to corresponding elements of the input streams, returning a newly-allocated stream containing elements that are the results of those procedure applications. The output stream has as many elements as the minimum-length input stream, and may be infinite.
(scheme stream) syntax (stream-match (_ ) ((_ stream clause ...)) )
() (pat0 pat1 ...) (pat0 pat1 ... . pat_rest) pat
identifier _
stream ⟹ stream?
Stream-match provides the syntax of pattern-matching for streams. The input stream is an expression that evaluates to a stream. Clauses are of the form (pattern [fender] expr), consisting of a pattern that matches a stream of a particular shape, an optional fender that must succeed if the pattern is to match, and an expression that is evaluated if the pattern matches. There are four types of patterns:
* () — Matches the null stream.
* (pat0 pat1 ...) — Matches a finite stream with length exactly equal to the number of pattern elements.
* (pat0 pat1 ... . patrest) — Matches an infinite stream, or a finite stream with length at least as great as the number of pattern elements before the literal dot.
* pat — Matches an entire stream. Should always appear last in the list of clauses; it’s not an error to appear elsewhere, but subsequent clauses could never match.
Each pattern element pati may be either:
* An identifier — Matches any stream element. Additionally, the value of the stream element is bound to the variable named by the identifier, which is in scope in the fender and expression of the corresponding clause. Each identifier in a single pattern must be unique.
* A literal underscore — Matches any stream element, but creates no bindings.
The patterns are tested in order, left-to-right, until a matching pattern is found; if fender is present, it must evaluate as non-#f for the match to be successful. Pattern variables are bound in the corresponding fender and expression. Once the matching pattern is found, the corresponding expression is evaluated and returned as the result of the match. An error is signaled if no pattern matches the input stream.
(scheme stream) syntax (stream-of (in is ) ((_ expr clause ...) stream? ) )
(var in stream-expr) (var is expr) (pred? expr)
Stream-of provides the syntax of stream comprehensions, which generate streams by means of looping expressions. The result is a stream of objects of the type returned by expr. There are four types of clauses:
* (var in stream-expr) — Loop over the elements of stream-expr, in order from the start of the stream, binding each element of the stream in turn to var. Stream-from and stream-range are frequently useful as generators for stream-expr.
* (var is expr) — Bind var to the value obtained by evaluating expr.
* (pred? expr) — Include in the output stream only those elements x for which (pred? x) is non-#f.
The scope of variables bound in the stream comprehension is the clauses to the right of the binding clause (but not the binding clause itself) plus the result expression.
When two or more generators are present, the loops are processed as if they are nested from left to right; that is, the rightmost generator varies fastest. A consequence of this is that only the first generator may be infinite and all subsequent generators must be finite. If no generators are present, the result of a stream comprehension is a stream containing the result expression; thus, (stream-of 1) produces a finite stream containing only the element 1.
(scheme stream) procedure (stream-range (first real?) (past real?) ) ⟹ stream?
(scheme stream) procedure (stream-range (first real?) (past real?) (step real?) ) ⟹ stream?
number × number × number → {number}
Stream-range creates a newly-allocated stream that contains first as its first element and increments each succeeding element by step. The stream is finite and ends before past, which is not an element of the stream. If step is not given it defaults to 1 if first is less than past and -1 otherwise. First, past and step may be of any numeric type. Stream-range is frequently useful as a generator in stream-of expressions. See also stream-from for a similar procedure that creates infinite streams.
Successive elements of the stream are calculated by adding step to first, so if any of first, past or step are inexact, the length of the output stream may differ from (ceiling (- (/ (- past first) step) 1).
(scheme stream) procedure (stream-ref (stream stream?) (n integer?) ) ⟹ *
{α} × nat → α
Stream-ref returns the nth element of stream, counting from zero. An error is signaled if n is greater than or equal to the length of stream.
(scheme stream) procedure (stream-reverse (stream stream?) ) ⟹ stream?
{α} → {α}
Stream-reverse returns a newly-allocated stream containing the elements of the input stream but in reverse order. Stream-reverse may only be used with finite streams; it enters an infinite loop with infinite streams. Stream-reverse does not force evaluation of the elements of the stream.
(scheme stream) procedure (stream-scan (proc procedure?) base (stream stream?) ) ⟹ stream?
(proc base element ) ⟹ *
(α × β → α) × α × {β} → {α}
Stream-scan accumulates the partial folds of an input stream into a newly-allocated output stream. The output stream is the base followed by (stream-fold proc base (stream-take i stream)) for each of the first i elements of stream.
(scheme stream) procedure (stream-take (n integer?) (stream stream?) ) ⟹ stream?
nat × {α} → {α}
Stream-take takes a non-negative integer n and a stream and returns a newly-allocated stream containing the first n elements of the input stream. If the input stream has less than n elements, so does the output stream. See also stream-drop.
(scheme stream) procedure (stream-take-while (pred? procedure?) (stream stream?) ) ⟹ stream?
(pred? obj ) ⟹ boolean?
(α → boolean) × {α} → {α}
Stream-take-while takes a predicate and a stream and returns a newly-allocated stream containing those elements x that form the maximal prefix of the input stream for which (pred? x) is non-#f. See also stream-drop-while.
(scheme stream) procedure (stream-unfold (map procedure?) (pred? procedure?) (gen procedure?) base ) ⟹ stream?
(map base ) ⟹ *
(pred? base ) ⟹ boolean?
(gen base ) ⟹ *
(α → β) × (α → boolean) × (α → α) × α → {β}
Stream-unfold is the fundamental recursive stream constructor. It constructs a stream by repeatedly applying gen to successive values of base, in the manner of stream-iterate, then applying map to each of the values so generated, appending each of the mapped values to the output stream as long as (pred? base) is non-#f. See also stream-iterate and stream-unfolds.
(scheme stream) procedure (stream-unfolds (proc procedure?) seed ) ⟹ (values stream?...)
(proc seed ) ⟹ (values list? / #f / *...)
(α → (values α × β ...)) × α → (values {β} ...)
Stream-unfolds returns n newly-allocated streams containing those elements produced by successive calls to the generator proc, which takes the current seed as its argument and returns n+1 values
(proc seed → seed result0 ... resultn-1
where the returned seed is the input seed to the next call to the generator and resulti indicates how to produce the next element of the ith result stream:
* (value) — value is the next car of the result stream
* #f — no value produced by this iteration of the generator proc for the result stream
* () — the end of the result stream
It may require multiple calls of proc to produce the next element of any particular result stream. See also stream-iterate and stream-unfold.
(scheme stream) procedure (stream-zip (stream stream?) ... ) ⟹ stream?
{α} × {β} × ... → {[α β ...]}
Stream-zip takes one or more input streams and returns a newly-allocated stream in which each element is a list (not a stream) of the corresponding elements of the input streams. The output stream is as long as the shortest input stream, if any of the input streams is finite, or is infinite if all the input streams are infinite.
A common use of stream-zip is to add an index to a stream, as in (stream-finds eql? obj strm), which returns all the zero-based indices in strm at which obj appears; (stream-find eql? obj strm) returns the first such index, or #f if obj is not in strm.
library (scheme sort)
(scheme sort) procedure (list-sorted? (< procedure?) (lis list?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sorted?, vector-sorted?) These procedures return true iff their input list or vector is in sorted order, as determined by <. Specifically, they return #f iff there is an adjacent pair ... X Y ... in the input list or vector such that Y < X in the sense of <. The optional start and end range arguments restrict vector-sorted? to examining the indicated subvector.
These procedures are equivalent to the SRFI 95 sorted? procedure when applied to lists or vectors respectively, except that they do not accept a key procedure.
(scheme sort) procedure (vector-sorted? (< procedure?) (v vector?) ) ⟹ boolean?
(scheme sort) procedure (vector-sorted? (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(scheme sort) procedure (vector-sorted? (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sorted?, vector-sorted?) These procedures return true iff their input list or vector is in sorted order, as determined by <. Specifically, they return #f iff there is an adjacent pair ... X Y ... in the input list or vector such that Y < X in the sense of <. The optional start and end range arguments restrict vector-sorted? to examining the indicated subvector.
These procedures are equivalent to the SRFI 95 sorted? procedure when applied to lists or vectors respectively, except that they do not accept a key procedure.
(scheme sort) procedure (list-sort (< procedure?) (lis list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sort, list-stable-sort) These procedures do not alter their inputs, but are allowed to return a value that shares a common tail with a list argument.
The list-stable-sort procedure is equivalent to the R6RS list-sort procedure. It is also equivalent to the SRFI 95 sort procedure when applied to lists, except that it does not accept a key procedure.
(scheme sort) procedure (list-stable-sort (< procedure?) (lis list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sort, list-stable-sort) These procedures do not alter their inputs, but are allowed to return a value that shares a common tail with a list argument.
The list-stable-sort procedure is equivalent to the R6RS list-sort procedure. It is also equivalent to the SRFI 95 sort procedure when applied to lists, except that it does not accept a key procedure.
(scheme sort) procedure (list-sort! (< procedure?) (lis list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sort!, list-stable-sort!) These procedures are linear update operators — they are allowed, but not required, to alter the cons cells of their arguments to produce their results. They return a sorted list containing the same elements as lis.
The list-stable-sort! procedure is equivalent to the SRFI 95 sort! procedure when applied to lists, except that it does not accept a key procedure.
(scheme sort) procedure (list-stable-sort! (< procedure?) (lis list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sort!, list-stable-sort!) These procedures are linear update operators — they are allowed, but not required, to alter the cons cells of their arguments to produce their results. They return a sorted list containing the same elements as lis.
The list-stable-sort! procedure is equivalent to the SRFI 95 sort! procedure when applied to lists, except that it does not accept a key procedure.
(scheme sort) procedure (vector-sort (< procedure?) (v vector?) ) ⟹ boolean?
(scheme sort) procedure (vector-sort (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(scheme sort) procedure (vector-sort (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for vector-sort, vector-stable-sort) These procedures do not alter their inputs, but allocate a fresh vector as their result, of length end - start. The vector-stable-sort procedure with no optional arguments is equivalent to the R6RS vector-sort procedure. It is also equivalent to the SRFI 95 sort procedure when applied to vectors, except that it does not accept a key procedure.
(scheme sort) procedure (vector-stable-sort (< procedure?) (v vector?) ) ⟹ boolean?
(scheme sort) procedure (vector-stable-sort (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(scheme sort) procedure (vector-stable-sort (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for vector-sort, vector-stable-sort) These procedures do not alter their inputs, but allocate a fresh vector as their result, of length end - start. The vector-stable-sort procedure with no optional arguments is equivalent to the R6RS vector-sort procedure. It is also equivalent to the SRFI 95 sort procedure when applied to vectors, except that it does not accept a key procedure.
(scheme sort) procedure (vector-sort! (< procedure?) (v vector?) ) ⟹ boolean?
(scheme sort) procedure (vector-sort! (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(scheme sort) procedure (vector-sort! (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for vector-sort!, vector-stable-sort!) These procedures sort their data in-place. (But note that vector-stable-sort! may allocate temporary storage proportional to the size of the input — there are no known O(n lg n) stable vector sorting algorithms that run in constant space.) They return an unspecified value.
The vector-sort! procedure with no optional arguments is equivalent to the R6RS vector-sort! procedure.
(scheme sort) procedure (vector-stable-sort! (< procedure?) (v vector?) ) ⟹ boolean?
(scheme sort) procedure (vector-stable-sort! (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(scheme sort) procedure (vector-stable-sort! (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for vector-sort!, vector-stable-sort!) These procedures sort their data in-place. (But note that vector-stable-sort! may allocate temporary storage proportional to the size of the input — there are no known O(n lg n) stable vector sorting algorithms that run in constant space.) They return an unspecified value.
The vector-sort! procedure with no optional arguments is equivalent to the R6RS vector-sort! procedure.
(scheme sort) procedure (list-merge (< procedure?) (lis1 list?) (lis2 list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
This procedure does not alter its inputs, and is allowed to return a value that shares a common tail with a list argument.
This procedure is equivalent to the SRFI 95 merge procedure when applied to lists, except that it does not accept a key procedure.
(scheme sort) procedure (list-merge! (< procedure?) (lis1 list?) (lis2 list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
This procedure makes only a single, iterative, linear-time pass over its argument lists, using set-cdr!s to rearrange the cells of the lists into the list that is returned — it works "in place." Hence, any cons cell appearing in the result must have originally appeared in an input. It returns the sorted input.
Additionally, list-merge! is iterative, not recursive — it can operate on arguments of arbitrary size without requiring an unbounded amount of stack space. The intent of this iterative-algorithm commitment is to allow the programmer to be sure that if, for example, list-merge! is asked to merge two ten-million-element lists, the operation will complete without performing some extremely (possibly twenty-million) deep recursion.
This procedure is equivalent to the SRFI 95 merge! procedure when applied to lists, except that it does not accept a key procedure.
(scheme sort) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) ) ⟹ vector?
(scheme sort) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) ) ⟹ vector?
(scheme sort) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) ) ⟹ vector?
(scheme sort) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ vector?
(scheme sort) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ vector?
(< obj1 obj2 ) ⟹ boolean?
This procedure does not alter its inputs, and returns a newly allocated vector of length (end1 - start1) + (end2 - start2).
This procedure is equivalent to the SRFI 95 merge procedure when applied to vectors, except that it does not accept a key procedure.
(scheme sort) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) ) ⟹ vector?
(scheme sort) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) ) ⟹ vector?
(scheme sort) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) ) ⟹ vector?
(scheme sort) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ vector?
(scheme sort) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ vector?
(< obj1 obj2 ) ⟹ boolean?
This procedure writes its result into vector to, beginning at index start, for indices less than end, which is defined as start + (end1 - start1) + (end2 - start2). The target subvector to[start, end) may not overlap either of the source subvectors from1[start1, end1] and from2[start2, end2]. It returns an unspecified value.
This procedure is equivalent to the SRFI 95 merge! procedure when applied to lists, except that it does not accept a key procedure.
(scheme sort) procedure (list-delete-neighbor-dups (= procedure?) (lis list?) ) ⟹ list?
(= obj1 obj2 ) ⟹ boolean?
This procedure does not alter its input list, but its result may share storage with the input list.
(scheme sort) procedure (list-delete-neighbor-dups! (= procedure?) (lis list?) ) ⟹ list?
(= obj1 obj2 ) ⟹ boolean?
This procedure mutates its input list in order to construct its result. It makes only a single, iterative, linear-time pass over its argument, using set-cdr!s to rearrange the cells of the list into the final result — it works "in place." Hence, any cons cell appearing in the result must have originally appeared in the input.
(scheme sort) procedure (vector-delete-neighbor-dups (= procedure?) (v vector?) ) ⟹ vector?
(scheme sort) procedure (vector-delete-neighbor-dups (= procedure?) (v vector?) (start integer?) ) ⟹ vector?
(scheme sort) procedure (vector-delete-neighbor-dups (= procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ vector?
(= obj1 obj2 ) ⟹ boolean?
This procedure does not alter its input vector, but rather newly allocates and returns a vector to hold the result.
(scheme sort) procedure (vector-delete-neighbor-dups! (= procedure?) (v vector?) ) ⟹ vector?
(scheme sort) procedure (vector-delete-neighbor-dups! (= procedure?) (v vector?) (start integer?) ) ⟹ vector?
(scheme sort) procedure (vector-delete-neighbor-dups! (= procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ vector?
(= obj1 obj2 ) ⟹ boolean?
This procedure reuses its input vector to hold the answer, packing it into the index range [start, newend), where newend is the non-negative exact integer that is returned as its value. The vector is not altered outside the range [start, newend).
(scheme sort) procedure (vector-find-median (< procedure?) (v vector?) knil ) ⟹ *
(scheme sort) procedure (vector-find-median (< procedure?) (v vector?) knil (mean procedure?) ) ⟹ *
(< obj1 obj2 ) ⟹ boolean?
(mean obj1 obj2 ) ⟹ *
This procedure does not alter its input vector, but rather newly allocates a vector to hold the intermediate result. Runs in O(n) time.
(scheme sort) procedure (vector-find-median! (< procedure?) (v vector?) knil ) ⟹ *
(scheme sort) procedure (vector-find-median! (< procedure?) (v vector?) knil (mean procedure?) ) ⟹ *
(< obj1 obj2 ) ⟹ boolean?
(mean obj1 obj2 ) ⟹ *
This procedure reuses its input vector to hold the intermediate result, leaving it sorted, but is otherwise the same as vector-find-median. Runs in O(n ln n) time.
(scheme sort) procedure (vector-select! (< procedure?) (v vector?) (k integer?) ) ⟹ *
(scheme sort) procedure (vector-select! (< procedure?) (v vector?) (k integer?) (start integer?) ) ⟹ *
(scheme sort) procedure (vector-select! (< procedure?) (v vector?) (k integer?) (start integer?) (end integer?) ) ⟹ *
(< obj1 obj2 ) ⟹ boolean?
This procedure returns the kth smallest element (in the sense of the < argument) of the region of a vector between start and end. Elements within the range may be reordered, whereas those outside the range are left alone. Runs in O(n) time.
(scheme sort) procedure (vector-separate! (< procedure?) (v vector?) (k integer?) ) ⟹ undefined
(scheme sort) procedure (vector-separate! (< procedure?) (v vector?) (k integer?) (start integer?) ) ⟹ undefined
(scheme sort) procedure (vector-separate! (< procedure?) (v vector?) (k integer?) (start integer?) (end integer?) ) ⟹ undefined
(< obj1 obj2 ) ⟹ boolean?
This procedure places the smallest k elements (in the sense of the < argument) of the region of a vector between start and end into the first k positions of that range, and the remaining elements into the remaining positions. Otherwise, the elements are not in any particular order. Elements outside the range are left alone. Runs in O(n) time. Returns an unspecified value.
library (scheme text)
(scheme text) procedure (text? obj ) ⟹ boolean?
Is obj an immutable text? In particular, (text? obj) returns false if (string? obj) returns true, which implies string? returns false if text? returns true. Must execute in O(1) time.
(scheme text) procedure (textual? obj ) ⟹ boolean?
Returns true if and only if obj is an immutable text or a string. Must execute in O(1) time.
(scheme text) procedure (textual-null? (textual textual?) ) ⟹ boolean?
Is textual the empty text or the empty string? Must execute in O(1) time.
(scheme text) procedure (textual-every (pred procedure?) (textual textual?) ) ⟹ *
(scheme text) procedure (textual-every (pred procedure?) (textual textual?) (start integer?) ) ⟹ *
(scheme text) procedure (textual-every (pred procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ *
(pred (char char?) ) ⟹ *
(scheme text) procedure (textual-any (pred procedure?) (textual textual?) ) ⟹ *
(scheme text) procedure (textual-any (pred procedure?) (textual textual?) (start integer?) ) ⟹ *
(scheme text) procedure (textual-any (pred procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ *
(pred (char char?) ) ⟹ *
Checks to see if every/any character in textual satisfies pred, proceeding from left (index start) to right (index end). textual-every These procedures are short-circuiting: if pred returns false, textual-every does not call pred on subsequent characters; if pred returns true, textual-any does not call pred on subsequent characters; Both procedures are "witness-generating":
Note: The names of these procedures do not end with a question mark. This indicates a general value is returned instead of a simple boolean (#t or #f).
(scheme text) procedure (make-text (len integer?) (char char?) ) ⟹ text?
Returns a text of the given length filled with the given character.
(scheme text) procedure (text (char char?) ... ) ⟹ text?
Returns a text consisting of the given characters.
(scheme text) procedure (text-tabulate (proc procedure?) (len integer?) ) ⟹ text?
(proc (k integer?) ) ⟹ char?
Proc is a procedure that accepts an exact integer as its argument and returns a character. Constructs a text of size len by calling proc on each value from 0 (inclusive) to len (exclusive) to produce the corresponding element of the text. The order in which proc is called on those indexes is not specified.
(scheme text) procedure (text-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ text?
(scheme text) procedure (text-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base textual?) ) ⟹ text?
(scheme text) procedure (text-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base textual?) (make-final procedure?) ) ⟹ text?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char? / string? / text? /
(success seed ) ⟹ *
(make-final seed ) ⟹ char? / string? / text? /
This is a fundamental constructor for texts.
text-unfold is a fairly powerful text constructor. You can use it to convert a list to a text, read a port into a text, reverse a text, copy a text, and so forth.
(scheme text) procedure (text-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ text?
(scheme text) procedure (text-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base textual?) ) ⟹ text?
(scheme text) procedure (text-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base textual?) (make-final procedure?) ) ⟹ text?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char? / string? / text? /
(success seed ) ⟹ *
(make-final seed ) ⟹ char? / string? / text? /
This is a fundamental constructor for texts. It is the same as text-unfold except the results of mapper are assembled into the text in right-to-left order, base is the optional rightmost portion of the constructed text, and make-final produces the leftmost portion of the constructed text.
(scheme text) procedure (textual->text (textual textual?) ) ⟹ text?
When given a text, textual->text just returns that text. When given a string, textual->text returns the result of calling string->text on that string. Signals an error when its argument is neither string nor text.
(scheme text) procedure (textual->string (textual textual?) ) ⟹ string?
(scheme text) procedure (textual->string (textual textual?) (start integer?) ) ⟹ string?
(scheme text) procedure (textual->string (textual textual?) (start integer?) (end integer?) ) ⟹ string?
(scheme text) procedure (textual->vector (textual textual?) ) ⟹ vector?
(scheme text) procedure (textual->vector (textual textual?) (start integer?) ) ⟹ vector?
(scheme text) procedure (textual->vector (textual textual?) (start integer?) (end integer?) ) ⟹ vector?
return ⟹ (vector (c char?) )
(scheme text) procedure (textual->list (textual textual?) ) ⟹ list?
(scheme text) procedure (textual->list (textual textual?) (start integer?) ) ⟹ list?
(scheme text) procedure (textual->list (textual textual?) (start integer?) (end integer?) ) ⟹ list?
return ⟹ (list (c char?) )
textual->string, textual->vector, and textual->list return a newly allocated (unless empty) mutable string, vector, or list of the characters that make up the given subtext or substring.
(scheme text) procedure (string->text (string string?) ) ⟹ text?
(scheme text) procedure (string->text (string string?) (start integer?) ) ⟹ text?
(scheme text) procedure (string->text (string string?) (start integer?) (end integer?) ) ⟹ text?
(scheme text) procedure (vector->text (vector vector?) ) ⟹ text?
(scheme text) procedure (vector->text (vector vector?) (start integer?) ) ⟹ text?
(scheme text) procedure (vector->text (vector vector?) (start integer?) (end integer?) ) ⟹ text?
vector ⟹ (vector (c char?) )
(scheme text) procedure (list->text (list list?) ) ⟹ text?
(scheme text) procedure (list->text (list list?) (start integer?) ) ⟹ text?
(scheme text) procedure (list->text (list list?) (start integer?) (end integer?) ) ⟹ text?
list ⟹ (list (c char?) )
These procedures return a text containing the characters of the given substring, subvector, or sublist. The behavior of the text will not be affected by subsequent mutation of the given string, vector, or list.
(scheme text) procedure (reverse-list->text (char-list list?) ) ⟹ text?
char-list ⟹ (list (c char?) )
An efficient implementation of (compose list->text reverse):
(reverse-list->text '(#\a #\B #\c)) → "cBa"
This is a common idiom in the epilogue of text-processing loops that accumulate their result using a list in reverse order. (See also textual-concatenate-reverse for the "chunked" variant.)
(scheme text) procedure (textual->utf8 (textual textual?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf8 (textual textual?) (start integer?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf8 (textual textual?) (start integer?) (end integer?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf16 (textual textual?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf16 (textual textual?) (start integer?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf16 (textual textual?) (start integer?) (end integer?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf16be (textual textual?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf16be (textual textual?) (start integer?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf16be (textual textual?) (start integer?) (end integer?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf16le (textual textual?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf16le (textual textual?) (start integer?) ) ⟹ bytevector?
(scheme text) procedure (textual->utf16le (textual textual?) (start integer?) (end integer?) ) ⟹ bytevector?
These procedures return a newly allocated (unless empty) bytevector containing a UTF-8 or UTF-16 encoding of the given subtext or substring.
The bytevectors returned by textual->utf8, textual->utf16be, and textual->utf16le do not contain a byte-order mark (BOM). textual->utf16be returns a big-endian encoding, while textual->utf16le returns a little-endian encoding.
The bytevectors returned by textual->utf16 begin with a BOM that declares an implementation-dependent endianness, and the bytevector elements following that BOM encode the given subtext or substring using that endianness.
(scheme text) procedure (utf8->text (bytevector bytevector?) ) ⟹ text?
(scheme text) procedure (utf8->text (bytevector bytevector?) (start integer?) ) ⟹ text?
(scheme text) procedure (utf8->text (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ text?
(scheme text) procedure (utf16->text (bytevector bytevector?) ) ⟹ text?
(scheme text) procedure (utf16->text (bytevector bytevector?) (start integer?) ) ⟹ text?
(scheme text) procedure (utf16->text (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ text?
(scheme text) procedure (utf16be->text (bytevector bytevector?) ) ⟹ text?
(scheme text) procedure (utf16be->text (bytevector bytevector?) (start integer?) ) ⟹ text?
(scheme text) procedure (utf16be->text (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ text?
(scheme text) procedure (utf16le->text (bytevector bytevector?) ) ⟹ text?
(scheme text) procedure (utf16le->text (bytevector bytevector?) (start integer?) ) ⟹ text?
(scheme text) procedure (utf16le->text (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ text?
These procedures interpret their bytevector argument as a UTF-8 or UTF-16 encoding of a sequence of characters, and return a text containing that sequence.
The bytevector subrange given to utf16->text may begin with a byte order mark (BOM); if so, that BOM determines whether the rest of the subrange is to be interpreted as big-endian or little-endian; in either case, the BOM will not become a character in the returned text. If the subrange does not begin with a BOM, it is decoded using the same implementation-dependent endianness used by textual->utf16.
The utf16be->text and utf16le->text procedures interpret their inputs as big-endian or little-endian, respectively. If a BOM is present, it is treated as a normal character and will become part of the result.
It is an error if the bytevector subrange given to utf8->text contains invalid UTF-8 byte sequences. For the other three procedures, it is an error if start or end are odd, or if the bytevector subrange contains invalid UTF-16 byte sequences.
(scheme text) procedure (text-length (text text?) ) ⟹ integer?
Returns the number of characters within the given text. Must execute in O(1) time.
(scheme text) procedure (text-ref (text text?) (idx integer?) ) ⟹ char?
Returns character text[idx], using 0-origin indexing. Must execute in O(1) time.
(scheme text) procedure (textual-length (textual textual?) ) ⟹ integer?
Returns the number of characters within the given textual. Generalization of text-length to accept strings as well as texts.
(scheme text) procedure (textual-ref (text textual?) (idx integer?) ) ⟹ char?
Returns character text[idx], using 0-origin indexing. Generalization of text-ref to accept strings as well as texts.
(scheme text) procedure (subtext (text text?) (start integer?) (end integer?) ) ⟹ text?
(scheme text) procedure (subtextual (text textual?) (start integer?) (end integer?) ) ⟹ text?
These procedures return a text containing the characters of text or textual beginning with index start (inclusive) and ending with index end (exclusive).
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by subtextual. When the first argument is a text, as is required by subtext, implementations are encouraged to return a result that shares storage with that text, to whatever extent sharing is possible while maintaining some small fixed bound on the ratio of storage used by the shared representation divided by the storage that would be used by an unshared representation. In particular, these procedures should just return their first argument when that argument is a text, start is 0, and end is the length of that text.
(scheme text) procedure (textual-copy (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-copy (textual textual?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-copy (textual textual?) (start integer?) (end integer?) ) ⟹ text?
Returns a text containing the characters of textual beginning with index start (inclusive) and ending with index end (exclusive).
Unlike subtext and subtextual, the result of textual-copy never shares substructures that would retain characters or sequences of characters that are substructures of its first argument or previously allocated objects.
If textual-copy returns an empty text, that empty text may be eq? or eqv? to the text returned by (text). If the text returned by textual-copy is non-empty, then it is not eqv? to any previously extant object.
(scheme text) procedure (textual-take (textual textual?) (nchars integer?) ) ⟹ text?
(scheme text) procedure (textual-drop (textual textual?) (nchars integer?) ) ⟹ text?
(scheme text) procedure (textual-take-right (textual textual?) (nchars integer?) ) ⟹ text?
(scheme text) procedure (textual-drop-right (textual textual?) (nchars integer?) ) ⟹ text?
textual-take returns a text containing the first nchars of textual; textual-drop returns a text containing all but the first nchars of textual. textual-take-right returns a text containing the last nchars of textual; textual-drop-right returns a text containing all but the last nchars of textual.
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by these procedures. If textual is a text, implementations are encouraged to return a result that shares storage with that text (which is easily accomplished by using subtext to create the result).
(scheme text) procedure (textual-pad (textual textual?) (len integer?) ) ⟹ text?
(scheme text) procedure (textual-pad (textual textual?) (len integer?) (char char?) ) ⟹ text?
(scheme text) procedure (textual-pad (textual textual?) (len integer?) (char char?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-pad (textual textual?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ text?
(scheme text) procedure (textual-pad-right (textual textual?) (len integer?) ) ⟹ text?
(scheme text) procedure (textual-pad-right (textual textual?) (len integer?) (char char?) ) ⟹ text?
(scheme text) procedure (textual-pad-right (textual textual?) (len integer?) (char char?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-pad-right (textual textual?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ text?
Returns a text of length len comprised of the characters drawn from the given subrange of textual, padded on the left (right) by as many occurrences of the character char as needed. If textual has more than len chars, it is truncated on the left (right) to length len. char defaults to #\space.
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by these procedures. If textual is a text, implementations are encouraged to return a result that shares storage with that text whenever sharing would be space-efficient.
(scheme text) procedure (textual-trim (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-trim (textual textual?) (pred procedure?) ) ⟹ text?
(scheme text) procedure (textual-trim (textual textual?) (pred procedure?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-trim (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
(scheme text) procedure (textual-trim-right (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-trim-right (textual textual?) (pred procedure?) ) ⟹ text?
(scheme text) procedure (textual-trim-right (textual textual?) (pred procedure?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-trim-right (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
(scheme text) procedure (textual-trim-both (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-trim-both (textual textual?) (pred procedure?) ) ⟹ text?
(scheme text) procedure (textual-trim-both (textual textual?) (pred procedure?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-trim-both (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
Returns a text obtained from the given subrange of textual by skipping over all characters on the left / on the right / on both sides that satisfy the second argument pred: pred defaults to char-whitespace?.
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by these procedures. If textual is a text, implementations are encouraged to return a result that shares storage with that text whenever sharing would be space-efficient.
(scheme text) procedure (textual-replace (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ text?
(scheme text) procedure (textual-replace (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ text?
(scheme text) procedure (textual-replace (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ text?
Returns
(textual-append (subtextual textual1 0 start1)
(subtextual textual2 start2 end2)
(subtextual textual1 end1 (textual-length textual1)))
That is, the segment of characters in textual1 from start1 to end1 is replaced by the segment of characters in textual2 from start2 to end2. If start1=end1, this simply splices the characters drawn from textual2 into textual1 at that position.
(scheme text) procedure (textual=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
Returns #t if all the texts have the same length and contain exactly the same characters in the same positions; otherwise returns #f.
(scheme text) procedure (textual<? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(scheme text) procedure (textual>? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(scheme text) procedure (textual<=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(scheme text) procedure (textual>=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
These procedures return #t if their arguments are (respectively): monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically non-increasing.
These comparison predicates are required to be transitive.
These procedures compare texts in an implementation-defined way. One approach is to make them the lexicographic extensions to texts of the corresponding orderings on characters. In that case, text<? would be the lexicographic ordering on texts induced by the ordering char<? on characters, and if two texts differ in length but are the same up to the length of the shorter text, the shorter text would be considered to be lexicographically less than the longer string. However, implementations are also allowed to use more sophisticated locale-specific orderings.
In all cases, a pair of texts must satisfy exactly one of textual<?, textual=?, and textual>?, must satisfy textual<=? if and only if they do not satisfy textual>?, and must satisfy textual>=? if and only if they do not satisfy textual<?.
(scheme text) procedure (textual-ci=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
Returns #t if, after calling textual-foldcase on each of the arguments, all of the case-folded texts would have the same length and contain the same characters in the same positions; otherwise returns #f.
(scheme text) procedure (textual-ci<? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(scheme text) procedure (textual-ci>? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(scheme text) procedure (textual-ci<=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(scheme text) procedure (textual-ci>=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
These procedures behave as though they had called textual-foldcase on their arguments before applying the corresponding procedures without "-ci".
(scheme text) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) ) ⟹ integer?
(scheme text) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ integer?
(scheme text) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(scheme text) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(scheme text) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
(scheme text) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) ) ⟹ integer?
(scheme text) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ integer?
(scheme text) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(scheme text) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(scheme text) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
Return the length of the longest common prefix/suffix of textual1 and textual2. For prefixes, this is equivalent to their "mismatch index" (relative to the start indexes).
The optional start/end indexes restrict the comparison to the indicated subtexts of textual1 and textual2.
(scheme text) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) ) ⟹ boolean?
(scheme text) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ boolean?
(scheme text) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(scheme text) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(scheme text) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
(scheme text) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) ) ⟹ boolean?
(scheme text) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ boolean?
(scheme text) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(scheme text) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(scheme text) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Is textual1 a prefix/suffix of textual2?
The optional start/end indexes restrict the comparison to the indicated subtexts of textual1 and textual2.
(scheme text) procedure (textual-index (textual textual?) (pred procedure?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-index (textual textual?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-index (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
(scheme text) procedure (textual-index-right (textual textual?) (pred procedure?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-index-right (textual textual?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-index-right (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
(scheme text) procedure (textual-skip (textual textual?) (pred procedure?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-skip (textual textual?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-skip (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
(scheme text) procedure (textual-skip-right (textual textual?) (pred procedure?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-skip-right (textual textual?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-skip-right (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
textual-index searches through the given subtext or substring from the left, returning the index of the leftmost character satisfying the predicate pred. textual-index-right searches from the right, returning the index of the rightmost character satisfying the predicate pred. If no match is found, these procedures return #f.
Rationale: The SRFI 130 analogues of these procedures return cursors, even when no match is found, and SRFI 130's string-index-right returns the successor of the cursor for the first character that satisfies the predicate. As there are no cursors in this SRFI, it seems best to follow the more intuitive and long-standing precedent set by SRFI 13.
The start and end arguments specify the beginning and end of the search; the valid indexes relevant to the search include start but exclude end. Beware of "fencepost" errors: when searching right-to-left, the first index considered is (- end 1), whereas when searching left-to-right, the first index considered is start. That is, the start/end indexes describe the same half-open interval [start,end) in these procedures that they do in all other procedures specified by this SRFI.
The skip functions are similar, but use the complement of the criterion: they search for the first char that doesn't satisfy pred.
(scheme text) procedure (textual-contains (textual1 textual?) (textual2 textual?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-contains (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-contains (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-contains (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-contains (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ #f / integer? /
(scheme text) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ #f / integer? /
Does the subtext of textual1 specified by start1 and end1 contain the sequence of characters given by the subtext of textual2 specified by start2 and end2?
Returns #f if there is no match. If start2 = end2, textual-contains returns start1 but textual-contains-right returns end1. Otherwise returns the index in textual1 for the first character of the first/last match; that index lies within the half-open interval [start1,end1), and the match lies entirely within the [start1,end1) range of textual1.
(scheme text) procedure (textual-upcase (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-downcase (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-foldcase (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-titlecase (textual textual?) ) ⟹ text?
These procedures return the text obtained by applying Unicode's full uppercasing, lowercasing, case-folding, or title-casing algorithms to their argument. In some cases, the length of the result may be different from the length of the argument. Note that language-sensitive mappings and foldings are not used.
(scheme text) procedure (textual-append (textual textual?) ... ) ⟹ text?
Returns a text whose sequence of characters is the concatenation of the sequences of characters in the given arguments.
(scheme text) procedure (textual-concatenate (textual-list list?) ) ⟹ text?
Concatenates the elements of textual-list together into a single text.
If any elements of textual-list are strings, then those strings do not share any storage with the result, so subsequent mutation of those string will not affect the text returned by this procedure. Implementations are encouraged to return a result that shares storage with some of the texts in the list if that sharing would be space-efficient.
Rationale: Some implementations of Scheme limit the number of arguments that may be passed to an n-ary procedure, so the (apply textual-append textual-list) idiom, which is otherwise equivalent to using this procedure, is not as portable.
(scheme text) procedure (textual-concatenate-reverse (textual-list list?) ) ⟹ text?
(scheme text) procedure (textual-concatenate-reverse (textual-list list?) (final-textual textual?) ) ⟹ text?
(scheme text) procedure (textual-concatenate-reverse (textual-list list?) (final-textual textual?) (end integer?) ) ⟹ text?
With no optional arguments, calling this procedure is equivalent to
(textual-concatenate (reverse textual-list))
If the optional argument final-textual is specified, it is effectively consed onto the beginning of textual-list before performing the list-reverse and textual-concatenate operations.
If the optional argument end is given, only the characters up to but not including end in final-textual are added to the result, thus producing
(textual-concatenate
(reverse (cons (subtext final-textual 0 end)
textual-list)))
(scheme text) procedure (textual-join (textual-list list?) ) ⟹ text?
(scheme text) procedure (textual-join (textual-list list?) (delimiter textual?) ) ⟹ text?
(scheme text) procedure (textual-join (textual-list list?) (delimiter textual?) (grammar symbol?) ) ⟹ text?
This procedure is a simple unparser; it pastes texts together using the delimiter text.
textual-list is a list of texts and/or strings. delimiter is a text or a string. The grammar argument is a symbol that determines how the delimiter is used, and defaults to 'infix. It is an error for grammar to be any symbol other than these four:
'infix means an infix or separator grammar: insert the delimiter between list elements. An empty list will produce an empty text.
'strict-infix means the same as 'infix if the textual-list is non-empty, but will signal an error if given an empty list. (This avoids an ambiguity shown in the examples below.)
'suffix means a suffix or terminator grammar: insert the delimiter after every list element.
'prefix means a prefix grammar: insert the delimiter before every list element.
The delimiter is the text used to delimit elements; it defaults to a single space " ".
(scheme text) procedure (textual-fold (kons procedure?) knil (textual textual?) ) ⟹ *
(scheme text) procedure (textual-fold (kons procedure?) knil (textual textual?) (start integer?) ) ⟹ *
(scheme text) procedure (textual-fold (kons procedure?) knil (textual textual?) (start integer?) (end integer?) ) ⟹ *
(kons (char char?) state ) ⟹ *
(scheme text) procedure (textual-fold-right (kons procedure?) knil (textual textual?) ) ⟹ *
(scheme text) procedure (textual-fold-right (kons procedure?) knil (textual textual?) (start integer?) ) ⟹ *
(scheme text) procedure (textual-fold-right (kons procedure?) knil (textual textual?) (start integer?) (end integer?) ) ⟹ *
(kons (char char?) state ) ⟹ *
These are the fundamental iterators for texts.
The textual-fold procedure maps the kons procedure across the given text or string from left to right:
(... (kons textual[2] (kons textual[1] (kons textual[0] knil))))
The textual-fold-right procedure maps kons across the given text or string from right to left:
(kons textual[0]
(... (kons textual[end-3]
(kons textual[end-2]
(kons textual[end-1]
knil)))))
(scheme text) procedure (textual-map (proc procedure?) (textual1 textual?) (textual2 textual?) ... ) ⟹ text?
(proc (char1 char?) (char2 char?) ... ) ⟹ textual? / char? /
It is an error if proc does not accept as many arguments as the number of textual arguments passed to textual-map, does not accept characters as arguments, or returns a value that is not a character, string, or text.
The textual-map procedure applies proc element-wise to the characters of the textual arguments, converts each value returned by proc to a text, and returns the concatenation of those texts. If more than one textual argument is given and not all have the same length, then textual-map terminates when the shortest textual argument runs out. The dynamic order in which proc is called on the characters of the textual arguments is unspecified, as is the dynamic order in which the coercions are performed. If any strings returned by proc are mutated after they have been returned and before the call to textual-map has returned, then textual-map returns a text with unspecified contents; the textual-map procedure itself does not mutate those strings.
(scheme text) procedure (textual-for-each (proc procedure?) (textual1 textual?) (textual2 textual?) ... ) ⟹ undefined
(proc (char1 char?) (char2 char?) ... ) ⟹ undefined
It is an error if proc does not accept as many arguments as the number of textual arguments passed to textual-map or does not accept characters as arguments.
The textual-for-each procedure applies proc element-wise to the characters of the textual arguments, going from left to right. If more than one textual argument is given and not all have the same length, then textual-for-each terminates when the shortest textual argument runs out.
(scheme text) procedure (textual-map-index (proc procedure?) (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-map-index (proc procedure?) (textual textual?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-map-index (proc procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ text?
(proc (char char?) ) ⟹ textual? / char? /
Calls proc on each valid index of the specified subtext or substring, converts the results of those calls into texts, and returns the concatenation of those texts. It is an error for proc to return anything other than a character, string, or text. The dynamic order in which proc is called on the indexes is unspecified, as is the dynamic order in which the coercions are performed. If any strings returned by proc are mutated after they have been returned and before the call to textual-map-index has returned, then textual-map-index returns a text with unspecified contents; the textual-map-index procedure itself does not mutate those strings.
(scheme text) procedure (textual-for-each-index (proc procedure?) (textual textual?) ) ⟹ undefined
(scheme text) procedure (textual-for-each-index (proc procedure?) (textual textual?) (start integer?) ) ⟹ undefined
(scheme text) procedure (textual-for-each-index (proc procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ undefined
(proc (char char?) ) ⟹ undefined
Calls proc on each valid index of the specified subtext or substring, in increasing order, discarding the results of those calls. This is simply a safe and correct way to loop over a subtext or substring.
(scheme text) procedure (textual-count (textual textual?) (pred procedure?) ) ⟹ integer?
(scheme text) procedure (textual-count (textual textual?) (pred procedure?) (start integer?) ) ⟹ integer?
(scheme text) procedure (textual-count (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ integer?
(pred (char char?) ) ⟹ boolean?
Returns a count of the number of characters in the specified subtext of textual that satisfy the given predicate.
(scheme text) procedure (textual-filter (pred procedure?) (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-filter (pred procedure?) (textual textual?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-filter (pred procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
(scheme text) procedure (textual-remove (pred procedure?) (textual textual?) ) ⟹ text?
(scheme text) procedure (textual-remove (pred procedure?) (textual textual?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-remove (pred procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
Filter the given subtext of textual, retaining only those characters that satisfy / do not satisfy pred.
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by these procedures. If textual is a text, implementations are encouraged to return a result that shares storage with that text whenever sharing would be space-efficient.
(scheme text) procedure (textual-replicate (textual textual?) (from integer?) (to integer?) ) ⟹ text?
(scheme text) procedure (textual-replicate (textual textual?) (from integer?) (to integer?) (start integer?) ) ⟹ text?
(scheme text) procedure (textual-replicate (textual textual?) (from integer?) (to integer?) (start integer?) (end integer?) ) ⟹ text?
This is an "extended subtext" procedure that implements replicated copying of a subtext or substring.
textual is a text or string; start and end are optional arguments that specify a subtext of textual, defaulting to 0 and the length of textual. This subtext is conceptually replicated both up and down the index space, in both the positive and negative directions. textual-replicate returns the subtext of this text beginning at index from, and ending at to. It is an error if from is greater than to.
Note that
It is an error if start=end, unless from=to, which is allowed as a special case.
(scheme text) procedure (textual-split (textual textual?) (delimiter textual?) ) ⟹ list?
(scheme text) procedure (textual-split (textual textual?) (delimiter textual?) (grammar symbol?) ) ⟹ list?
(scheme text) procedure (textual-split (textual textual?) (delimiter textual?) (grammar symbol?) (limit (or #finteger?)) ) ⟹ list?
(scheme text) procedure (textual-split (textual textual?) (delimiter textual?) (grammar symbol?) (limit (or #finteger?)) (start integer?) ) ⟹ list?
(scheme text) procedure (textual-split (textual textual?) (delimiter textual?) (grammar symbol?) (limit (or #finteger?)) (start integer?) (end integer?) ) ⟹ list?
Returns a list of texts representing the words contained in the subtext of textual from start (inclusive) to end (exclusive). The delimiter is a text or string to be used as the word separator. This will often be a single character, but multiple characters are allowed for use cases such as splitting on "\r\n". The returned list will have one more item than the number of non-overlapping occurrences of the delimiter in the text. If delimiter is an empty text, then the returned list contains a list of texts, each of which contains a single character.
The grammar is a symbol with the same meaning as in the textual-join procedure. If it is infix, which is the default, processing is done as described above, except an empty textual produces the empty list; if grammar is strict-infix, then an empty textual signals an error. The values prefix and suffix cause a leading/trailing empty text in the result to be suppressed.
If limit is a non-negative exact integer, at most that many splits occur, and the remainder of textual is returned as the final element of the list (so the result will have at most limit+1 elements). If limit is not specified or is #f, then as many splits as possible are made. It is an error if limit is any other value.
library (scheme vector)
(scheme vector) procedure (make-vector (k integer?) ) ⟹ vector?
(scheme vector) procedure (make-vector (k integer?) fill ) ⟹ vector?
Creates and returns a vector of size size. If fill is specified, all the elements of the vector are initialized to fill. Otherwise, their contents are indeterminate.
(scheme vector) procedure (vector obj ... ) ⟹ vector?
Creates and returns a vector whose elements are x ....
(scheme vector) procedure (vector-unfold (f procedure?) (length integer?) initial-seed ... ) ⟹ vector?
(f (index integer?) seed ... ) ⟹ (values **...)
The fundamental vector constructor. Creates a vector whose length is length and iterates across each index k between 0 and length, applying f at each iteration to the current index and current seeds, in that order, to receive n + 1 values: first, the element to put in the kth slot of the new vector and n new seeds for the next iteration. It is an error for the number of seeds to vary between iterations. Note that the termination condition is different from the unfold procedure of SRFI 1.
(scheme vector) procedure (vector-unfold-right (f procedure?) (length integer?) initial-seed ... ) ⟹ vector?
(f (index integer?) seed ... ) ⟹ (values **...)
Like vector-unfold, but it uses f to generate elements from right-to-left, rather than left-to-right. The first index used is length - 1. Note that the termination condition is different from the unfold-right procedure of SRFI 1.
(scheme vector) procedure (vector-copy (vector vector?) ) ⟹ vector?
(scheme vector) procedure (vector-copy (vector vector?) (start integer?) ) ⟹ vector?
(scheme vector) procedure (vector-copy (vector vector?) (start integer?) (end integer?) ) ⟹ vector?
Allocates a new vector whose length is end - start and fills it with elements from vec, taking elements from vec starting at index start and stopping at index end. Start defaults to 0 and end defaults to the value of (vector-length vec). SRFI 43 provides an optional fill argument to supply values if end is greater than the length of vec. Neither R7RS-small nor this SRFI requires support for this argument.
(scheme vector) procedure (vector-reverse-copy (vector vector?) ) ⟹ vector?
(scheme vector) procedure (vector-reverse-copy (vector vector?) (start integer?) ) ⟹ vector?
(scheme vector) procedure (vector-reverse-copy (vector vector?) (start integer?) (end integer?) ) ⟹ vector?
Like vector-copy, but it copies the elements in the reverse order from vec.
(scheme vector) procedure (vector-append (vector vector?) ... ) ⟹ vector?
Returns a newly allocated vector that contains all elements in order from the subsequent locations in vec ....
(scheme vector) procedure (vector-concatenate (list-of-vectors list?) ... ) ⟹ vector?
list-of-vectors ⟹ (list (vec vector?) )
Appends each vector in list-of-vectors.
(scheme vector) procedure (vector-append-subvectors (vec1 vector?) (start1 integer?) (end1 integer?) ... ) ⟹ vector?
Returns a vector that contains every element of each vec from start to end in the specified order. This procedure is a generalization of vector-append.
(scheme vector) procedure (vector? obj ) ⟹ boolean?
Disjoint type predicate for vectors: this returns #t if x is a vector, and #f if otherwise.
(scheme vector) procedure (vector-empty? (vec vector?) ) ⟹ boolean?
Returns #t if vec is empty, i.e. its length is 0, and #f if not.
(scheme vector) procedure (vector= (elt=? procedure?) (vec vector?) ... ) ⟹ boolean?
(elt=? a b ) ⟹ boolean?
Vector structure comparator, generalized across user-specified element comparators. Vectors a and b are considered equal by vector= iff their lengths are the same, and for each respective element Ea and Eb, (elt=? Ea Eb) returns a true value. Elt=? is always applied to two arguments.
If there are only zero or one vector arguments, #t is automatically returned. The dynamic order in which comparisons of elements and of vectors are performed is left completely unspecified; do not rely on a particular order.
(scheme vector) procedure (vector-ref (vector vector?) (k integer?) ) ⟹ *
Vector element dereferencing: returns the value that the location in vec at i is mapped to in the store. Indexing is based on zero. I must be within the range [0, (vector-length vec)).
(scheme vector) procedure (vector-length (vector vector?) ) ⟹ integer?
Returns the length of vec, the number of locations reachable from vec. (The careful word 'reachable' is used to allow for 'vector slices,' whereby vec refers to a larger vector that contains more locations that are unreachable from vec. This SRFI does not define vector slices, but later SRFIs may.)
(scheme vector) procedure (vector-fold (kons procedure?) knil (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(kons state obj1 obj2 ... ) ⟹ *
The fundamental vector iterator. Kons is iterated over each value in all of the vectors, stopping at the end of the shortest; kons is applied as (kons state (vector-ref vec1 i) (vector-ref vec2 i) ...) where state is the current state value — the current state value begins with knil, and becomes whatever kons returned on the previous iteration —, and i is the current index.
The iteration is strictly left-to-right.
(scheme vector) procedure (vector-fold-right (kons procedure?) knil (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(kons state obj1 obj2 ... ) ⟹ *
Similar to vector-fold, but it iterates right to left instead of left to right.
(scheme vector) procedure (vector-map (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ vector?
(proc obj ... ) ⟹ *
Constructs a new vector of the shortest size of the vector arguments. Each element at index i of the new vector is mapped from the old vectors by (f (vector-ref vec1 i) (vector-ref vec2 i) ...). The dynamic order of application of f is unspecified.
(scheme vector) procedure (vector-map! (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ undefined
(proc obj ... ) ⟹ *
Similar to vector-map, but rather than mapping the new elements into a new vector, the new mapped elements are destructively inserted into vec1. Again, the dynamic order of application of f unspecified, so it is dangerous for f to apply either vector-ref or vector-set! to vec1 in f.
(scheme vector) procedure (vector-for-each (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ undefined
(proc obj ... ) ⟹ undefined
Simple vector iterator: applies f to the corresponding list of parallel elements from vec1 vec2 ... in the range [0, length), where length is the length of the smallest vector argument passed, In contrast with vector-map, f is reliably applied to each subsequent element, starting at index 0, in the vectors.
(scheme vector) procedure (vector-count (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer?
(pred? obj1 obj2 ... ) ⟹ *
Counts the number of parallel elements in the vectors that satisfy pred?, which is applied, for each index i in the range [0, length) where length is the length of the smallest vector argument, to each parallel element in the vectors, in order.
(scheme vector) procedure (vector-cumulate (f procedure?) knil (vec vector?) ) ⟹ vector?
(f obj1 obj2 ) ⟹ *
Returns a newly allocated vector new with the same length as vec. Each element i of new is set to the result of invoking f on newi-1 and veci, except that for the first call on f, the first argument is knil. The new vector is returned.
Note that the order of arguments to vector-cumulate was changed by errata-3 on 2016-09-02.
(scheme vector) procedure (vector-index (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Finds & returns the index of the first elements in vec1 vec2 ... that satisfy pred?. If no matching element is found by the end of the shortest vector, #f is returned.
(scheme vector) procedure (vector-index-right (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Like vector-index, but it searches right-to-left, rather than left-to-right, and all of the vectors must have the same length.
(scheme vector) procedure (vector-skip (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Finds & returns the index of the first elements in vec1 vec2 ... that do not satisfy pred?. If all the values in the vectors satisfy pred? until the end of the shortest vector, this returns #f.
(scheme vector) procedure (vector-skip-right (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Like vector-skip, but it searches for a non-matching element right-to-left, rather than left-to-right, and it is an error if all of the vectors do not have the same length.
(scheme vector) procedure (vector-binary-search (vec vector?) value (cmp procedure?) ) ⟹ integer? / #f /
(cmp a b ) ⟹ integer?
Similar to vector-index and vector-index-right, but instead of searching left to right or right to left, this performs a binary search. If there is more than one element of vec that matches value in the sense of cmp, vector-binary-search may return the index of any of them.
cmp should be a procedure of two arguments and return a negative integer, which indicates that its first argument is less than its second, zero, which indicates that they are equal, or a positive integer, which indicates that the first argument is greater than the second argument.
(scheme vector) procedure (vector-any (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(pred? obj1 obj2 ... ) ⟹ *
Finds the first set of elements in parallel from vec1 vec2 ... for which pred? returns a true value. If such a parallel set of elements exists, vector-any returns the value that pred? returned for that set of elements. The iteration is strictly left-to-right.
(scheme vector) procedure (vector-every (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(pred? obj1 obj2 ... ) ⟹ *
If, for every index i between 0 and the length of the shortest vector argument, the set of elements (vector-ref vec1 i) (vector-ref vec2 i) ... satisfies pred?, vector-every returns the value that pred? returned for the last set of elements, at the last index of the shortest vector. The iteration is strictly left-to-right.
(scheme vector) procedure (vector-partition (pred? procedure?) (vec vector?) ) ⟹ (values vector?integer?)
(pred? obj ) ⟹ boolean?
A vector the same size as vec is newly allocated and filled with all the elements of vec that satisfy pred? in their original order followed by all the elements that do not satisfy pred?, also in their original order.
Two values are returned, the newly allocated vector and the index of the leftmost element that does not satisfy pred?.
(scheme vector) procedure (vector-set! (vector vector?) (k integer?) obj ) ⟹ undefined
Assigns the contents of the location at i in vec to value.
(scheme vector) procedure (vector-swap! (vector vector?) (i integer?) (j integer?) ) ⟹ undefined
Swaps or exchanges the values of the locations in vec at i & j.
(scheme vector) procedure (vector-fill! (vector vector?) fill ) ⟹ undefined
(scheme vector) procedure (vector-fill! (vector vector?) fill (start integer?) ) ⟹ undefined
(scheme vector) procedure (vector-fill! (vector vector?) fill (start integer?) (end integer?) ) ⟹ undefined
Assigns the value of every location in vec between start, which defaults to 0 and end, which defaults to the length of vec, to fill.
(scheme vector) procedure (vector-reverse! (vector vector?) ) ⟹ undefined
(scheme vector) procedure (vector-reverse! (vector vector?) (start integer?) ) ⟹ undefined
(scheme vector) procedure (vector-reverse! (vector vector?) (start integer?) (end integer?) ) ⟹ undefined
Destructively reverses the contents of the sequence of locations in vec between start and end. Start defaults to 0 and end defaults to the length of vec. Note that this does not deeply reverse.
(scheme vector) procedure (vector-copy! (to vector?) (at integer?) (from vector?) ) ⟹ undefined
(scheme vector) procedure (vector-copy! (to vector?) (at integer?) (from vector?) (start integer?) ) ⟹ undefined
(scheme vector) procedure (vector-copy! (to vector?) (at integer?) (from vector?) (start integer?) (end integer?) ) ⟹ undefined
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 vector) procedure (vector-reverse-copy! (to vector?) (at integer?) (from vector?) ) ⟹ undefined
(scheme vector) procedure (vector-reverse-copy! (to vector?) (at integer?) (from vector?) (start integer?) ) ⟹ undefined
(scheme vector) procedure (vector-reverse-copy! (to vector?) (at integer?) (from vector?) (start integer?) (end integer?) ) ⟹ undefined
Like vector-copy!, but the elements appear in to in reverse order.
(scheme vector) procedure (vector-unfold! (f procedure?) (vec vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like vector-unfold, but the elements are copied into the vector vec starting at element start rather than into a newly allocated vector. Terminates when end-start elements have been generated.
(scheme vector) procedure (vector-unfold-right! (f procedure?) (vec vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like vector-unfold!, but the elements are copied in reverse order into the vector vec starting at the index preceding end.
(scheme vector) procedure (vector->list (vector vector?) ) ⟹ list?
(scheme vector) procedure (vector->list (vector vector?) (start integer?) ) ⟹ list?
(scheme vector) procedure (vector->list (vector vector?) (start integer?) (end integer?) ) ⟹ list?
Creates a list containing the elements in vec between start, which defaults to 0, and end, which defaults to the length of vec.
(scheme vector) procedure (reverse-vector->list (vector vector?) ) ⟹ list?
(scheme vector) procedure (reverse-vector->list (vector vector?) (start integer?) ) ⟹ list?
(scheme vector) procedure (reverse-vector->list (vector vector?) (start integer?) (end integer?) ) ⟹ list?
Like vector->list, but the resulting list contains the elements in reverse of vec.
(scheme vector) procedure (list->vector (list list?) ) ⟹ vector?
Creates a vector of elements from proper-list.
(scheme vector) procedure (reverse-list->vector (list list?) ) ⟹ vector?
Like list->vector, but the resulting vector contains the elements in reverse of proper-list.
(scheme vector) procedure (string->vector (string string?) ) ⟹ vector?
(scheme vector) procedure (string->vector (string string?) (start integer?) ) ⟹ vector?
(scheme vector) procedure (string->vector (string string?) (start integer?) (end integer?) ) ⟹ vector?
Creates a vector containing the elements in string between start, which defaults to 0, and end, which defaults to the length of string.
(scheme vector) procedure (vector->string (vector vector?) ) ⟹ string?
(scheme vector) procedure (vector->string (vector vector?) (start integer?) ) ⟹ string?
(scheme vector) procedure (vector->string (vector vector?) (start integer?) (end integer?) ) ⟹ string?
Creates a string containing the elements in vec between start, which defaults to 0, and end, which defaults to the length of vec. It is an error if the elements are not characters.
library (scheme bitwise)
(scheme bitwise) procedure (bitwise-not (i integer?) ) ⟹ integer?
Returns the bitwise complement of i; that is, all 1 bits are changed to 0 bits and all 0 bits to 1 bits.
(scheme bitwise) procedure (bitwise-and (i integer?) ... ) ⟹ integer?
(scheme bitwise) procedure (bitwise-ior (i integer?) ... ) ⟹ integer?
(scheme bitwise) procedure (bitwise-xor (i integer?) ... ) ⟹ integer?
(scheme bitwise) procedure (bitwise-eqv (i integer?) ... ) ⟹ integer?
For each function, the corresponding bitwise operator maps that function across a pair of bitstrings in a bit-wise fashion. These operations are associative. When passed no arguments, the procedures return the identity values -1, 0, 0, and -1 respectively.
(scheme bitwise) procedure (bitwise-nand (i integer?) (j integer?) ) ⟹ integer?
(scheme bitwise) procedure (bitwise-nor (i integer?) (j integer?) ) ⟹ integer?
(scheme bitwise) procedure (bitwise-andc1 (i integer?) (j integer?) ) ⟹ integer?
(scheme bitwise) procedure (bitwise-andc2 (i integer?) (j integer?) ) ⟹ integer?
(scheme bitwise) procedure (bitwise-orc1 (i integer?) (j integer?) ) ⟹ integer?
(scheme bitwise) procedure (bitwise-orc2 (i integer?) (j integer?) ) ⟹ integer?
For each function, the corresponding bitwise operator maps that function across a pair of bitstrings in a bit-wise fashion. These operations are not associative.
(scheme bitwise) procedure (arithmetic-shift (i integer?) (count integer?) ) ⟹ integer?
Returns the arithmetic left shift when count>0; right shift when count<0.
(scheme bitwise) procedure (bit-count (i integer?) ) ⟹ integer?
Returns the population count of 1's (i >= 0) or 0's (i < 0). The result is always non-negative.
(scheme bitwise) procedure (integer-length (i integer?) ) ⟹ integer?
The number of bits needed to represent i
(scheme bitwise) procedure (bitwise-if (mask integer?) (i integer?) (j integer?) ) ⟹ integer?
Merge the bitstrings i and j, with bitstring mask determining from which string to take each bit. That is, if the kth bit of mask is 1, then the kth bit of the result is the kth bit of i, otherwise the kth bit of j.
(scheme bitwise) procedure (bit-set? (index integer?) (i integer?) ) ⟹ boolean?
Is bit index set in bitstring i (where index is a non-negative exact integer)?
(scheme bitwise) procedure (copy-bit (index integer?) (i integer?) (boolean boolean?) ) ⟹ integer?
Returns an integer the same as i except in the indexth bit, which is 1 if boolean is #t and 0 if boolean is #f.
(scheme bitwise) procedure (bit-swap (index1 integer?) (index2 integer?) (i integer?) ) ⟹ integer?
Returns an integer the same as i except that the index1th bit and the index2th bit have been exchanged.
(scheme bitwise) procedure (any-bit-set? (test-bits integer?) (i integer?) ) ⟹ boolean?
(scheme bitwise) procedure (every-bit-set? (test-bits integer?) (i integer?) ) ⟹ boolean?
Determines if any/all of the bits set in bitstring test-bits are set in bitstring i. I.e., returns (not (zero? (bitwise-and test-bits i))) and (= test-bits (bitwise-and test-bits i))) respectively.
(scheme bitwise) procedure (first-set-bit (i integer?) ) ⟹ integer?
Return the index of the first (smallest index) 1 bit in bitstring i. Return -1 if i contains no 1 bits (i.e., if i is zero).
(scheme bitwise) procedure (bit-field (i integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns the field from i, shifted down to the least-significant position in the result.
(scheme bitwise) procedure (bit-field-any? (i integer?) (start integer?) (end integer?) ) ⟹ boolean?
Returns true if any of the field's bits are set in bitstring i, and false otherwise.
(scheme bitwise) procedure (bit-field-every? (i integer?) (start integer?) (end integer?) ) ⟹ boolean?
Returns false if any of the field's bits are not set in bitstring i, and true otherwise.
(scheme bitwise) procedure (bit-field-clear (i integer?) (start integer?) (end integer?) ) ⟹ integer?
(scheme bitwise) procedure (bit-field-set (i integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns i with the field's bits set to all 0s/1s.
(scheme bitwise) procedure (bit-field-replace (dest integer?) (source integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns dest with the field replaced by the least-significant end-start bits in source.
(scheme bitwise) procedure (bit-field-replace-same (dest integer?) (source integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns dest with its field replaced by the corresponding field in source.
(scheme bitwise) procedure (bit-field-rotate (i integer?) (count integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns i with the field cyclically permuted by count bits towards high-order.
(scheme bitwise) procedure (bit-field-reverse (i integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns i with the order of the bits in the field reversed.
(scheme bitwise) procedure (bits->list (i integer?) ) ⟹ list?
(scheme bitwise) procedure (bits->list (i integer?) (len integer?) ) ⟹ list?
return ⟹ (list (b boolean?) )
(scheme bitwise) procedure (bits->vector (i integer?) ) ⟹ vector?
(scheme bitwise) procedure (bits->vector (i integer?) (len integer?) ) ⟹ vector?
return ⟹ (vector (b boolean?) )
Returns a list/vector of len booleans corresponding to each bit of the non-negative integer i, returning bit #0 as the first element, bit #1 as the second, and so on. #t is returned for each 1; #f for 0.
(scheme bitwise) procedure (list->bits (list list?) ) ⟹ integer?
list ⟹ (list (b boolean?) )
(scheme bitwise) procedure (vector->bits (vector vector?) ) ⟹ integer?
vector ⟹ (vector (b boolean?) )
Returns an integer formed from the booleans in list/vector, using the first element as bit #0, the second element as bit #1, and so on. It is an error if list/vector contains non-booleans. A 1 bit is coded for each #t; a 0 bit for #f. Note that the result is never a negative integer.
(scheme bitwise) procedure (bits (bool boolean?) ... ) ⟹ integer?
Returns the integer coded by the bool arguments. The first argument is bit #0, the second argument is bit #1, and so on. Note that the result is never a negative integer.
(scheme bitwise) procedure (bitwise-fold (proc procedure?) seed (i integer?) ) ⟹ *
(proc (bit boolean?) state ) ⟹ *
For each bit b of i from bit #0 (inclusive) to bit (integer-length i) (exclusive), proc is called as (proc b r), where r is the current accumulated result. The initial value of r is seed, and the value returned by proc becomes the next accumulated result. When the last bit has been processed, the final accumulated result becomes the result of bitwise-fold.
(scheme bitwise) procedure (bitwise-for-each (proc procedure?) (i integer?) ) ⟹ undefined
(proc (bit boolean?) ) ⟹ undefined
Repeatedly applies proc to the bits of i starting with bit #0 (inclusive) and ending with bit (integer-length i) (exclusive). The values returned by proc are discarded. Returns an unspecified value.
(scheme bitwise) procedure (bitwise-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ integer?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ boolean?
(successor seed ) ⟹ *
Generates a non-negative integer bit by bit, starting with bit 0. If the result of applying stop? to the current state (whose initial value is seed) is true, return the currently accumulated bits as an integer. Otherwise, apply mapper to the current state to obtain the next bit of the result by interpreting a true value as a 1 bit and a false value as a 0 bit. Then get a new state by applying successor to the current state, and repeat this algorithm.
(scheme bitwise) procedure (make-bitwise-generator (i integer?) ) ⟹ procedure?
(return ) ⟹ boolean?
Returns a SRFI 121 generator that generates all the bits of i starting with bit #0. Note that the generator is infinite.
library (scheme bytevector)
(scheme bytevector) syntax (endianness () ((_ endianness-symbol)) )
The name of <endianness symbol> must be a symbol describing an endianness. An implementation must support at least the symbols big and little, but may support other endianness symbols. (endianness <endianness symbol>) evaluates to the symbol named <endianness symbol>. Whenever one of the procedures operating on bytevectors accepts an endianness as an argument, that argument must be one of these symbols. It is a syntax violation for <endianness symbol> to be anything other than an endianness symbol supported by the implementation.
Note: Implementors should use widely accepted designations for endianness symbols other than big and little.
Note: Only the name of <endianness symbol> is significant.
(scheme bytevector) procedure (native-endianness ) ⟹ symbol?
Returns the endianness symbol associated implementation's preferred endianness (usually that of the underlying machine architecture). This may be any <endianness symbol>, including a symbol other than big and little.
(scheme bytevector) procedure (bytevector? obj ) ⟹ boolean?
Returns #t if obj is a bytevector, otherwise returns #f.
(scheme bytevector) procedure (make-bytevector (k integer?) ) ⟹ bytevector?
(scheme bytevector) procedure (make-bytevector (k integer?) (byte integer?) ) ⟹ bytevector?
Returns a newly allocated bytevector of k bytes. If the fill argument is missing, the initial contents of the returned bytevector are unspecified. If the fill argument is present, it must be an exact integer object in the interval {−128, ... 255} that specifies the initial value for the bytes of the bytevector: If fill is positive, it is interpreted as an octet; if it is negative, it is interpreted as a byte.
(scheme bytevector) procedure (bytevector-length (bytevector bytevector?) ) ⟹ integer?
Returns, as an exact integer object, the number of bytes in bytevector.
(scheme bytevector) procedure (bytevector=? (bytevector1 bytevector?) (bytevector2 bytevector?) ) ⟹ boolean?
Returns #t if bytevector1 and bytevector2 are equal - that is, if they have the same length and equal bytes at all valid indices. It returns #f otherwise.
(scheme bytevector) procedure (bytevector-fill! (bytevector bytevector?) (k integer?) ) ⟹ undefined
The fill argument is as in the description of the make-bytevector procedure. The bytevector-fill! procedure stores fill in every element of bytevector and returns unspecified values. Analogous to vector-fill!.
(scheme bytevector) procedure (bytevector-copy! (source bytevector?) (source-start integer?) (target bytevector?) (target-start integer?) (k integer?) ) ⟹ undefined
Source and target must be bytevectors. Source-start, target-start, and k must be non-negative exact integer objects that satisfy
0 <= source-start <= source-start + k <= lsource
0 <= target-start <= target-start + k <= ltarget
where lsource is the length of source and ltarget is the length of target. The bytevector-copy! procedure copies the bytes from source at indices source-start, ..., source-start + k - 1 to consecutive indices in target starting at target-index. This must work even if the memory regions for the source and the target overlap, i.e., the bytes at the target location after the copy must be equal to the bytes at the source location before the copy. This returns unspecified values.
(scheme bytevector) procedure (bytevector-copy (bytevector bytevector?) ) ⟹ bytevector?
Returns a newly allocated copy of bytevector.
(scheme bytevector) procedure (bytevector-u8-ref (bytevector bytevector?) (k integer?) ) ⟹ integer?
K must be a valid index of bytevector. The bytevector-u8-ref procedure returns the byte at index k of bytevector, as an octet.
(scheme bytevector) procedure (bytevector-s8-ref (bytevector bytevector?) (k integer?) ) ⟹ integer?
K must be a valid index of bytevector. The bytevector-s8-ref procedure returns the byte at index k of bytevector, as a (signed) byte.
(scheme bytevector) procedure (bytevector-u8-set! (bytevector bytevector?) (k integer?) (octet integer?) ) ⟹ undefined
K must be a valid index of bytevector. The bytevector-u8-set! procedure stores octet in element k of bytevector.
(scheme bytevector) procedure (bytevector-s8-set! (bytevector bytevector?) (k integer?) (byte integer?) ) ⟹ undefined
K must be a valid index of bytevector. The bytevector-s8-set! procedure stores the two's-complement representation of byte in element k of bytevector.
(scheme bytevector) procedure (bytevector->u8-list (bytevector bytevector?) ) ⟹ list?
The bytevector->u8-list procedure returns a newly allocated list of the octets of bytevector in the same order.
(scheme bytevector) procedure (u8-list->bytevector (list list?) ) ⟹ bytevector?
list ⟹ (list (octet integer?) )
List must be a list of octets. The u8-list->bytevector procedure returns a newly allocated bytevector whose elements are the elements of list list, in the same order. It is analogous to list->vector.
(scheme bytevector) procedure (bytevector-uint-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?
The bytevector-uint-ref procedure retrieves the exact integer object corresponding to the unsigned representation of size size and specified by endianness at indices k, ..., k + size − 1.
(scheme bytevector) procedure (bytevector-sint-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?
The bytevector-sint-ref procedure retrieves the exact integer object corresponding to the two's-complement representation of size size and specified by endianness at indices k, ..., k + size − 1.
(scheme bytevector) procedure (bytevector-uint-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined
The bytevector-uint-set! procedure stores the unsigned representation of size size and specified by endianness into bytevector at indices k, ..., k + size − 1.
(scheme bytevector) procedure (bytevector-sint-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined
bytevector-sint-set! stores the two's-complement representation of size size and specified by endianness into bytevector at indices k, ..., k + size − 1.
(scheme bytevector) procedure (bytevector->uint-list (bytevector bytevector?) (endianness symbol?) (size integer?) ) ⟹ list?
(scheme bytevector) procedure (bytevector->sint-list (bytevector bytevector?) (endianness symbol?) (size integer?) ) ⟹ list?
(scheme bytevector) procedure (uint-list->bytevector (list list?) (endianness symbol?) (size integer?) ) ⟹ bytevector?
(scheme bytevector) procedure (sint-list->bytevector (list list?) (endianness symbol?) (size integer?) ) ⟹ bytevector?
Size must be a positive exact integer object. For uint-list->bytevector, list must be a list of exact integer objects in the interval {0, ..., 256^mathitsize−1}. For sint-list->bytevector, list must be a list of exact integer objects in the interval {−256^mathitsize/2, ..., 256^mathitsize/2−1}. The length of bytevector or, respectively, of list must be divisible by size.
These procedures convert between lists of integer objects and their consecutive representations according to size and endianness in the bytevector objects in the same way as bytevector->u8-list and u8-list->bytevector do for one-byte representations.
(scheme bytevector) procedure (bytevector-u16-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-s16-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-u16-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-s16-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-u16-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined
(scheme bytevector) procedure (bytevector-s16-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined
(scheme bytevector) procedure (bytevector-u16-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined
(scheme bytevector) procedure (bytevector-s16-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined
K must be a valid index of bytevector; so must k + 1. For bytevector-u16-set! and bytevector-u16-native-set!, n must be an exact integer object in the interval {0, ..., 2^16−1}. For bytevector-s16-set! and bytevector-s16-native-set!, n must be an exact integer object in the interval {−2^15, ..., 2^15−1}.
These retrieve and set two-byte representations of numbers at indices k and k + 1, according to the endianness specified by endianness. The procedures with u16 in their names deal with the unsigned representation; those with s16 in their names deal with the two's-complement representation.
The procedures with native in their names employ the native endianness, and work only at aligned indices: k must be a multiple of 2.
The ...-set! procedures return unspecified values.
(scheme bytevector) procedure (bytevector-u32-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-s32-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-u32-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-s32-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-u32-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined
(scheme bytevector) procedure (bytevector-s32-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined
(scheme bytevector) procedure (bytevector-u32-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined
(scheme bytevector) procedure (bytevector-s32-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined
K, ..., k + 3 must be valid indices of bytevector. For bytevector-u32-set! and bytevector-u32-native-set!, n must be an exact integer object in the interval {0, ..., 2^32−1}. For bytevector-s32-set! and bytevector-s32-native-set!, n must be an exact integer object in the interval {−2^31, ..., 2^32−1}.
These retrieve and set four-byte representations of numbers at indices k, ..., k + 3, according to the endianness specified by endianness. The procedures with u32 in their names deal with the unsigned representation; those with s32 with the two's-complement representation.
The procedures with native in their names employ the native endianness, and work only at aligned indices: k must be a multiple of 4.
The ...-set! procedures return unspecified values.
(scheme bytevector) procedure (bytevector-u64-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-s64-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-u64-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-s64-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ integer?
(scheme bytevector) procedure (bytevector-u64-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined
(scheme bytevector) procedure (bytevector-s64-set! (bytevector bytevector?) (k integer?) (n integer?) (endianness symbol?) (size integer?) ) ⟹ undefined
(scheme bytevector) procedure (bytevector-u64-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined
(scheme bytevector) procedure (bytevector-s64-native-set! (bytevector bytevector?) (k integer?) (n integer?) (size integer?) ) ⟹ undefined
K, ..., k + 7 must be valid indices of bytevector. For bytevector-u64-set! and bytevector-u64-native-set!, n must be an exact integer object in the interval {0, ..., 2^64−1}. For bytevector-s64-set! and bytevector-s64-native-set!, n must be an exact integer object in the interval {−2^63, ..., 2^64−1}.
These retrieve and set eight-byte representations of numbers at indices k, ..., k + 7, according to the endianness specified by endianness. The procedures with u64 in their names deal with the unsigned representation; those with s64 with the two's-complement representation.
The procedures with native in their names employ the native endianness, and work only at aligned indices: k must be a multiple of 8.
The ...-set! procedures return unspecified values.
(scheme bytevector) procedure (bytevector-ieee-single-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ real?
K, ..., k + 3 must be valid indices of bytevector. The procedure returns the inexact real number object that best represents the IEEE-754 single-precision number represented by the four bytes beginning at index k.
(scheme bytevector) procedure (bytevector-ieee-double-ref (bytevector bytevector?) (k integer?) (endianness symbol?) (size integer?) ) ⟹ real?
K, ..., k + 7 must be valid indices of bytevector. The procedure returns the inexact real number object that best represents the IEEE-754 double-precision number represented by the eight bytes beginning at index k.
(scheme bytevector) procedure (bytevector-ieee-single-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ real?
K, ..., k + 3 must be valid indices of bytevector. K must be a multiple of 4. The procedure returns the inexact real number object that best represents the IEEE-754 single-precision number represented by the four bytes beginning at index k.
(scheme bytevector) procedure (bytevector-ieee-double-native-ref (bytevector bytevector?) (k integer?) (size integer?) ) ⟹ real?
K, ..., k + 7 must be valid indices of bytevector. K must be a multiple of 8. The procedure returns the inexact real number object that best represents the IEEE-754 double-precision number represented by the eight bytes beginning at index k.
(scheme bytevector) procedure (bytevector-ieee-single-set! (bytevector bytevector?) (k integer?) (x real?) (endianness symbol?) (size integer?) ) ⟹ undefined
K, ..., k + 3 must be valid indices of bytevector. The procedure stores an IEEE-754 single-precision representation of x into elements k through k + 3 of bytevector, and returns unspecified values.
(scheme bytevector) procedure (bytevector-ieee-double-set! (bytevector bytevector?) (k integer?) (x real?) (endianness symbol?) (size integer?) ) ⟹ undefined
K, ..., k + 7 must be valid indices of bytevector. The procedure stores an IEEE-754 double-precision representation of x into elements k through k + 7 of bytevector, and returns unspecified values.
(scheme bytevector) procedure (bytevector-ieee-single-native-set! (bytevector bytevector?) (k integer?) (x real?) (size integer?) ) ⟹ undefined
K, ..., k + 3 must be valid indices of bytevector. K must be a multiple of 4. The procedure stores an IEEE-754 single-precision representation of x into elements k through k + 3 of bytevector, and returns unspecified values.
(scheme bytevector) procedure (bytevector-ieee-double-native-set! (bytevector bytevector?) (k integer?) (x real?) (size integer?) ) ⟹ undefined
K, ..., k + 7 must be valid indices of bytevector. K must be a multiple of 8. The procedure stores an IEEE-754 double-precision representation of x into elements k through k + 7 of bytevector, and returns unspecified values.
(scheme bytevector) procedure (string->utf8 (string string?) ) ⟹ bytevector?
Returns a newly allocated (unless empty) bytevector that contains the UTF-8 encoding of the given string.
(scheme bytevector) procedure (string->utf16 (string string?) ) ⟹ bytevector?
(scheme bytevector) procedure (string->utf16 (string string?) (endianness symbol?) ) ⟹ bytevector?
If endianness is specified, it must be the symbol big or the symbol little. The string->utf16 procedure returns a newly allocated (unless empty) bytevector that contains the UTF-16BE or UTF-16LE encoding of the given string (with no byte-order mark). If endianness is not specified or is big, then UTF-16BE is used. If endianness is little, then UTF-16LE is used.
(scheme bytevector) procedure (string->utf32 (string string?) ) ⟹ bytevector?
(scheme bytevector) procedure (string->utf32 (string string?) (endianness symbol?) ) ⟹ bytevector?
If endianness is specified, it must be the symbol big or the symbol little. The string->utf32 procedure returns a newly allocated (unless empty) bytevector that contains the UTF-32BE or UTF-32LE encoding of the given string (with no byte mark). If endianness is not specified or is big, then UTF-32BE is used. If endianness is little, then UTF-32LE is used.
(scheme bytevector) procedure (utf8->string (bytevector bytevector?) ) ⟹ string?
Returns a newly allocated (unless empty) string whose character sequence is encoded by the given bytevector.
(scheme bytevector) procedure (utf16->string (bytevector bytevector?) (endianness symbol?) ) ⟹ string?
(scheme bytevector) procedure (utf16->string (bytevector bytevector?) (endianness symbol?) (endianness-mandatory? boolean?) ) ⟹ string?
Endianness must be the symbol big or the symbol little. The utf16->string procedure returns a newly allocated (unless empty) string whose character sequence is encoded by the given bytevector. Bytevector is decoded according to UTF-16BE or UTF-16LE: If endianness-mandatory? is absent or #f, utf16->string determines the endianness according to a UTF-16 BOM at the beginning of bytevector if a BOM is present; in this case, the BOM is not decoded as a character. Also in this case, if no UTF-16 BOM is present, endianness specifies the endianness of the encoding. If endianness-mandatory? is a true value, endianness specifies the endianness of the encoding, and any UTF-16 BOM in the encoding is decoded as a regular character.
Note: A UTF-16 BOM is either a sequence of bytes #xFE, #xFF specifying big and UTF-16BE, or #xFF, #xFE specifying little and UTF-16LE.
(scheme bytevector) procedure (utf32->string (bytevector bytevector?) (endianness symbol?) ) ⟹ string?
(scheme bytevector) procedure (utf32->string (bytevector bytevector?) (endianness symbol?) (endianness-mandatory? boolean?) ) ⟹ string?
Endianness must be the symbol big or the symbol little. The utf32->string procedure returns a newly allocated (unless empty) string whose character sequence is encoded by the given bytevector. Bytevector is decoded according to UTF-32BE or UTF-32LE: If endianness-mandatory? is absent or #f, utf32->string determines the endianness according to a UTF-32 BOM at the beginning of bytevector if a BOM is present; in this case, the BOM is not decoded as a character. Also in this case, if no UTF-32 BOM is present, endianness specifies the endianness of the encoding. If endianness-mandatory? is a true value, endianness specifies the endianness of the encoding, and any UTF-32 BOM in the encoding is decoded as a regular character.
Note: A UTF-32 BOM is either a sequence of bytes #x00, #x00, #xFE, #xFF specifying big and UTF-32BE, or #xFF, #xFE, #x00, #x00, specifying little and UTF-32LE.
library (scheme division)
(scheme division) procedure (floor/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(scheme division) procedure (floor-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(scheme division) procedure (floor-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
q = floor(n/d)
Thus a nonzero r is negative iff d is negative.
(scheme division) procedure (ceiling/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(scheme division) procedure (ceiling-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(scheme division) procedure (ceiling-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
q = ceiling(n/d)
Thus a nonzero r is negative iff d is non-negative.
If denominator is the number of units in a block, and numerator; is some number of units, then (ceiling-quotient numerator denominator) gives the number of blocks needed to cover numerator units. For example, denominator might be the number of bytes in a disk sector, and numerator the number of bytes in a file; then the quotient is the number of disk sectors needed to store the contents of the file. For another example, denominator might be the number of octets in the output of a cryptographic hash function, and numerator the number of octets desired in a key for a symmetric cipher, to be derived using the cryptographic hash function; then the quotient is the number of hash values needed to concatenate to make a key.
(scheme division) procedure (truncate/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(scheme division) procedure (truncate-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(scheme division) procedure (truncate-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
q = truncate(n/d)
Thus a nonzero r is negative iff n is negative. With the truncate operator pair, the quotient of +1, 0, or -1 by any non-unit denominator is 0; that is, three contiguous numerators divided by a common denominator share a common quotient. Of the other division operator pairs, only the round pair exhibits this property.
(scheme division) procedure (round/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(scheme division) procedure (round-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(scheme division) procedure (round-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
q = round(n/d)
The round function rounds to the nearest integer, breaking ties by choosing the nearest even integer. Nothing general can be said about the sign of r. Like the truncate operator pair, the quotient of +1, 0, or -1 by any non-unit denominator is 0, so that three contiguous numerators by a common denominator share a common quotient.
(scheme division) procedure (euclidean/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(scheme division) procedure (euclidean-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(scheme division) procedure (euclidean-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
If d > 0, q = floor(n/d); if d < 0, q = ceiling(n/d).
This division operator pair satisfies the stronger property
0 <= r < |d|,
used often in mathematics. Thus, for example, (euclidean-remainder numerator denominator) is always a valid index into a vector whose length is at least the absolute value of denominator. This division operator pair is so named because it is the subject of the Euclidean division algorithm.
(scheme division) procedure (balanced/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(scheme division) procedure (balanced-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(scheme division) procedure (balanced-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
This division operator pair satisfies the property
-|d/2| <= r < |d/2|.
When d is a power of 2, say 2k for some k, this reduces to
-2(k - 1) <= r < 2(k - 1).
Computer scientists will immediately recognize this as the interval of integers representable in two's-complement with k bits.
library (scheme fixnum)
fx-width ⟹ integer?
Bound to the value w that specifies the implementation-defined range. (R6RS fixnum-width is a procedure that always returns this value.)
fx-greatest ⟹ fixnum?
Bound to the value 2^(w-1)-1, the largest representable fixnum. (R6RS greatest-fixnum is a procedure that always returns this value.)
fx-least ⟹ fixnum?
Bound to the value -2^(w-1), the smallest representable fixnum. (R6RS least-fixnum is a procedure that always returns this value.)
(scheme fixnum) procedure (fixnum? obj ) ⟹ boolean?
Returns #t if obj is an exact integer within the fixnum range, and #f otherwise.
(scheme fixnum) procedure (fx=? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to =.
(scheme fixnum) procedure (fx<? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to <.
(scheme fixnum) procedure (fx>? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to >.
(scheme fixnum) procedure (fx<=? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to <=.
(scheme fixnum) procedure (fx>=? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to >=.
(scheme fixnum) procedure (fxzero? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to zero?.
(scheme fixnum) procedure (fxpositive? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to positive?.
(scheme fixnum) procedure (fxnegative? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to negative?.
(scheme fixnum) procedure (fxodd? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to odd?.
(scheme fixnum) procedure (fxeven? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to even?.
(scheme fixnum) procedure (fxmax (i fixnum?) (j fixnum?) ... ) ⟹ fixnum?
Semantically equivalent to max.
(scheme fixnum) procedure (fxmin (i fixnum?) (j fixnum?) ... ) ⟹ fixnum?
Semantically equivalent to min.
(scheme fixnum) procedure (fx+ (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to +, but accepts exactly two arguments.
(scheme fixnum) procedure (fx- (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to -, but accepts exactly two arguments.
(scheme fixnum) procedure (fxneg (i fixnum?) ) ⟹ fixnum?
Semantically equivalent to -, but accepts exactly one argument.
(scheme fixnum) procedure (fx* (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to *, but accepts exactly two arguments.
(scheme fixnum) procedure (fxquotient (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to quotient.
(scheme fixnum) procedure (fxremainder (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to remainder.
(scheme fixnum) procedure (fxabs (i fixnum?) ) ⟹ fixnum?
Semantically equivalent to abs. In accordance with the fixnum rule, has undefined results when applied to fx-least.
(scheme fixnum) procedure (fxsquare (i fixnum?) ) ⟹ fixnum?
Semantically equivalent to square.
(scheme fixnum) procedure (fxsqrt (i fixnum?) ) ⟹ fixnum?
Semantically equivalent to exact-integer-sqrt (not sqrt).
(scheme fixnum) procedure (fx+/carry (i fixnum?) (j fixnum?) (k fixnum?) ) ⟹ (values fixnum?fixnum?)
Returns the two fixnum results of the following computation:
(let*-values (((s) (+ i j k))
((q r) (balanced/ s (expt 2 fx-width))))
(values r q))
(scheme fixnum) procedure (fx-/carry (i fixnum?) (j fixnum?) (k fixnum?) ) ⟹ (values fixnum?fixnum?)
Returns the two fixnum results of the following computation:
(let*-values (((d) (- i j k))
((q r) (balanced/ d (expt 2 fx-width))))
(values r q))
(scheme fixnum) procedure (fx*/carry (i fixnum?) (j fixnum?) (k fixnum?) ) ⟹ (values fixnum?fixnum?)
Returns the two fixnum results of the following computation:
(let*-values (((s) (+ (* i j) k))
((q r) (balanced/ s (expt 2 fx-width))))
(values r q))
(scheme fixnum) procedure (fxnot (i integer?) ) ⟹ integer?
Semantically equivalent to bitwise-not.
(scheme fixnum) procedure (fxand (i integer?) ... ) ⟹ integer?
Semantically equivalent to bitwise-and.
(scheme fixnum) procedure (fxior (i integer?) ... ) ⟹ integer?
Semantically equivalent to bitwise-ior.
(scheme fixnum) procedure (fxxor (i integer?) ... ) ⟹ integer?
Semantically equivalent to bitwise-xor.
(scheme fixnum) procedure (fxarithmetic-shift (i fixnum?) (count integer?) ) ⟹ fixnum?
Semantically equivalent to arithmetic-shift, except that it is an error for the absolute value of count to exceed w-1.
(scheme fixnum) procedure (fxarithmetic-shift-left (i fixnum?) (count integer?) ) ⟹ fixnum?
The same as fxarithmetic-shift except that a negative value of count is an error. This is provided for additional efficiency.
(scheme fixnum) procedure (fxarithmetic-shift-right (i fixnum?) (count integer?) ) ⟹ fixnum?
The same as fxarithmetic-shift except that a non-negative value of count specifies the number of bits to shift right, and a negative value is an error. This is provided for additional efficiency.
(scheme fixnum) procedure (fxbit-count (i fixnum?) ) ⟹ integer?
Semantically equivalent to SRFI 151 bit-count.
(scheme fixnum) procedure (fxlength (i fixnum?) ) ⟹ integer?
Semantically equivalent to integer-length.
(scheme fixnum) procedure (fxif (mask fixnum?) (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to bitwise-if. It can be implemented as (fxior (fxand mask i) (fxand (fxnot mask) j))).
(scheme fixnum) procedure (fxbit-set? (index integer?) (i fixnum?) ) ⟹ boolean?
Semantically equivalent to SRFI 151 bit-set?, except that it is an error for index to be larger than or equal to fx-width.
(scheme fixnum) procedure (fxcopy-bit (index integer?) (i fixnum?) (boolean boolean?) ) ⟹ fixnum?
Semantically equivalent to SRFI 151 copy-bit, except that it is an error for index to be larger than or equal to fx-width.
(scheme fixnum) procedure (fxfirst-set-bit (i fixnum?) ) ⟹ integer?
Semantically equivalent to first-set-bit.
(scheme fixnum) procedure (fxbit-field (i fixnum?) (start integer?) (end integer?) ) ⟹ fixnum?
Semantically equivalent to bit-field.
(scheme fixnum) procedure (fxbit-field-rotate (i fixnum?) (count integer?) (start integer?) (end integer?) ) ⟹ fixnum?
Semantically equivalent to SRFI 151 bit-field-rotate.
(scheme fixnum) procedure (bit-field-reverse (i fixnum?) (start integer?) (end integer?) ) ⟹ fixnum?
Semantically equivalent to bit-field-reverse.
library (scheme flonum)
fl-e ⟹ flonum?
Bound to the mathematical constant e. (C99 M_E)
fl-1/e ⟹ flonum?
Bound to 1/e. (C99 M_E)
fl-e-2 ⟹ flonum?
Bound to e^2.
fl-e-pi/4 ⟹ flonum?
Bound to e^(pi/4).
fl-log2-e ⟹ flonum?
Bound to log2 e. (C99 M_LOG2E)
fl-log10-e ⟹ flonum?
Bound to log10 e. (C99 M_LOG10E)
fl-log-2 ⟹ flonum?
Bound to loge 2. (C99 M_LN2)
fl-1/log-2 ⟹ flonum?
Bound to 1/(loge 2)
fl-log-3 ⟹ flonum?
Bound to loge 3.
fl-log-pi ⟹ flonum?
Bound to loge pi.
fl-log-10 ⟹ flonum?
Bound to loge 10. (C99 M_LN10)
fl-1/log-10 ⟹ flonum?
Bound to 1/(loge 10). (C99 M_LN10)
fl-pi ⟹ flonum?
Bound to the mathematical constant pi. (C99 M_PI)
fl-1/pi ⟹ flonum?
Bound to 1/pi. (C99 M_1_PI)
fl-2pi ⟹ flonum?
Bound to 2pi.
fl-pi/2 ⟹ flonum?
Bound to pi/2. (C99 M_PI_2)
fl-pi/4 ⟹ flonum?
Bound to pi/4. (C99 M_PI_4)
fl-pi-squared ⟹ flonum?
Bound to pi^2.
fl-degree ⟹ flonum?
Bound to pi/180, the number of radians in a degree.
fl-2/pi ⟹ flonum?
Bound to 2/pi. (C99 M_2_PI)
fl-2/sqrt-pi ⟹ flonum?
Bound to 2/(pi^0.5). (C99 M_2_SQRTPI)
fl-sqrt-2 ⟹ flonum?
Bound to 2^0.5. (C99 M_SQRT2)
fl-sqrt-3 ⟹ flonum?
Bound to 3^0.5.
fl-sqrt-5 ⟹ flonum?
Bound to 5^0.5.
fl-sqrt-10 ⟹ flonum?
Bound to 10^0.5.
fl-1/sqrt-2 ⟹ flonum?
Bound to 1/(2^0.5). (C99 M_SQRT1_2)
fl-cbrt-2 ⟹ flonum?
Bound to 2^(1/3).
fl-cbrt-3 ⟹ flonum?
Bound to 3^(1/3).
fl-4thrt-2 ⟹ flonum?
Bound to 2^(1/4).
fl-phi ⟹ flonum?
Bound to the mathematical constant φ.
fl-log-phi ⟹ flonum?
Bound to log(φ).
fl-1/log-phi ⟹ flonum?
Bound to 1/log(φ).
fl-euler ⟹ flonum?
Bound to the mathematical constant γ (Euler's constant).
fl-e-euler ⟹ flonum?
Bound to e^γ.
fl-sin-1 ⟹ flonum?
Bound to sin 1.
fl-cos-1 ⟹ flonum?
Bound to cos 1.
fl-gamma-1/2 ⟹ flonum?
Bound to Γ(1/2).
fl-gamma-1/3 ⟹ flonum?
Bound to Γ(1/3).
fl-gamma-2/3 ⟹ flonum?
Bound to Γ(2/3).
fl-greatest ⟹ flonum?
Bound to the largest positive finite flonum. (C99 DBL_MAX)
fl-least ⟹ flonum?
Bound to the smallest positive finite flonum. (C99 DBL_TRUE_MIN)
fl-epsilon ⟹ flonum?
Bound to the appropriate machine epsilon for the hardware representation of flonums. (C99 DBL_EPSILON in <float.h>)
fl-fast-fl+* ⟹ boolean?
Bound to #t if (fl+* x y z) executes about as fast as, or faster than, (fl+ (fl* x y) z); bound to #f otherwise. (C99 FP_FAST_FMA)
So that the value of this variable can be determined at compile time, R7RS implementations and other implementations that provide a features function should provide the feature fl-fast-fl+* if this variable is true, and not if it is false or the value is unknown at compile time.
fl-integer-exponent-zero ⟹ integer?
Bound to whatever exact integer is returned by (flinteger-exponent 0.0). (C99 FP_ILOGB0)
fl-integer-exponent-nan ⟹ integer?
Bound to whatever exact integer is returned by (flinteger-exponent +nan.0). (C99 FP_ILOGBNAN)
(scheme flonum) procedure (flonum (number real?) ) ⟹ flonum?
If number is an inexact real number and there exists a flonum that is the same (in the sense of =) to number, returns that flonum. If number is a negative zero, an infinity, or a NaN, return its flonum equivalent. If such a flonum does not exist, returns the nearest flonum, where "nearest" is implementation-dependent. If number is not a real number, it is an error. If number is exact, applies inexact or exact->inexact to number first.
(scheme flonum) procedure (fladjacent (x flonum?) (y flonum?) ) ⟹ flonum?
Returns a flonum adjacent to x in the direction of y. Specifically: if x < y, returns the smallest flonum larger than x; if x > y, returns the largest flonum smaller than x; if x = y, returns x. (C99 nextafter)
(scheme flonum) procedure (flcopysign (x flonum?) (y flonum?) ) ⟹ flonum?
Returns a flonum whose magnitude is the magnitude of x and whose sign is the sign of y. (C99 copysign)
(scheme flonum) procedure (make-flonum (x flonum?) (n integer?) ) ⟹ flonum?
Returns x * 2^n, where n is an integer with an implementation-dependent range. (C99 ldexp)
(scheme flonum) procedure (flinteger-fraction (x flonum?) ) ⟹ (values flonum?flonum?)
Returns two values, the integral part of x as a flonum and the fractional part of x as a flonum. (C99 modf)
(scheme flonum) procedure (flexponent (x flonum?) ) ⟹ flonum?
Returns the exponent of x. (C99 logb)
(scheme flonum) procedure (flinteger-exponent (x flonum?) ) ⟹ integer?
Returns the same as flexponent truncated to an exact integer. If x is zero, returns fl-integer-exponent-zero; if x is a NaN, returns fl-integer-exponent-nan; if x is infinite, returns a large implementation-dependent exact integer. (C99 ilogb)
(scheme flonum) procedure (flnormalized-fraction-exponent (x flonum?) ) ⟹ (values flonum?integer?)
Returns two values, a correctly signed fraction y whose absolute value is between 0.5 (inclusive) and 1.0 (exclusive), and an exact integer exponent n such that x = y(2^n). (C99 frexp)
(scheme flonum) procedure (flsign-bit (x flonum?) ) ⟹ integer?
Returns 0 for positive flonums and 1 for negative flonums and -0.0. The value of (flsign-bit +nan.0) is implementation-dependent, reflecting the sign bit of the underlying representation of NaNs. (C99 signbit)
(scheme flonum) procedure (flonum? obj ) ⟹ boolean?
Returns #t if obj is a flonum and #f otherwise.
(scheme flonum) procedure (fl=? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
(scheme flonum) procedure (fl<? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
(scheme flonum) procedure (fl>? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
(scheme flonum) procedure (fl<=? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
(scheme flonum) procedure (fl>=? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
These procedures return #t if their arguments are (respectively): equal, monotonically increasing, monotonically decreasing, monotonically nondecreasing, or monotonically nonincreasing; they return #f otherwise. These predicates must be transitive. (C99 =, <, > <=, >= operators respectively)
(scheme flonum) procedure (flunordered? (x flonum?) (y flonum?) ) ⟹ boolean?
Returns #t if x and y are unordered according to IEEE rules. This means that one of them is a NaN.
(scheme flonum) procedure (flinteger? (x flonum?) ) ⟹ boolean?
Tests whether x is an integral flonum.
(scheme flonum) procedure (flzero? (x flonum?) ) ⟹ boolean?
Tests whether x is zero. Beware of roundoff errors.
(scheme flonum) procedure (flpositive? (x flonum?) ) ⟹ boolean?
Tests whether x is positive.
(scheme flonum) procedure (flnegative? (x flonum?) ) ⟹ boolean?
Tests whether x is negative. Note that (flnegative? -0.0) must return #f; otherwise it would lose the correspondence with (fl<? -0.0 0.0), which is #f according to IEEE 754.
(scheme flonum) procedure (flodd? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is odd. It is an error if x is not an integer.
(scheme flonum) procedure (fleven? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is even. It is an error if x is not an integer.
(scheme flonum) procedure (flfinite? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is finite. (C99 isfinite)
(scheme flonum) procedure (flinfinite? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is infinite. (C99 isinf)
(scheme flonum) procedure (flnan? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is NaN. (C99 isnan)
(scheme flonum) procedure (flnormalized? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is normalized. (C11 isnormal; in C99, use fpclassify(x) == FP_NORMAL)
(scheme flonum) procedure (fldenormalized? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is denormalized. (C11 issubnormal; in C99, use fpclassify(x) == FP_SUBNORMAL)
(scheme flonum) procedure (flmax (x flonum?) ... ) ⟹ flonum?
(scheme flonum) procedure (flmin (x flonum?) ... ) ⟹ flonum?
Return the maximum/minimum argument. If there are no arguments, these procedures return -inf.0 or +inf.0 if the implementation provides these numbers, and (fl- fl-greatest) or fl-greatest otherwise. (C99 fmax fmin)
(scheme flonum) procedure (fl+ (x flonum?) ... ) ⟹ flonum?
(scheme flonum) procedure (fl* (x flonum?) ... ) ⟹ flonum?
Return the flonum sum or product of their flonum arguments. (C99 + * operators respectively)
(scheme flonum) procedure (fl+* (x flonum?) (y flonum?) (z flonum?) ) ⟹ flonum?
Returns xy + z as if to infinite precision and rounded only once. The boolean constant fl-fast-fl+* indicates whether this procedure executes about as fast as, or faster than, a multiply and an add of flonums. (C99 fma)
(scheme flonum) procedure (fl- (x flonum?) (y flonum?) ... ) ⟹ flonum?
(scheme flonum) procedure (fl/ (x flonum?) (y flonum?) ... ) ⟹ flonum?
With two or more arguments, these procedures return the difference or quotient of their arguments, associating to the left. With one argument, however, they return the additive or multiplicative inverse of their argument. (C99 - / operators respectively)
(scheme flonum) procedure (flabs (x flonum?) ) ⟹ flonum?
Returns the absolute value of x. (C99 fabs)
(scheme flonum) procedure (flabsdiff (x flonum?) (y flonum?) ) ⟹ flonum?
Returns |x - y|.
(scheme flonum) procedure (flposdiff (x flonum?) (y flonum?) ) ⟹ flonum?
Returns the difference of x and y if it is non-negative, or zero if the difference is negative. (C99 fdim)
(scheme flonum) procedure (flsgn (x flonum?) ) ⟹ flonum?
Returns (flcopysign 1.0 x).
(scheme flonum) procedure (flnumerator (x flonum?) ) ⟹ flonum?
(scheme flonum) procedure (fldenominator (x flonum?) ) ⟹ flonum?
Returns the numerator/denominator of x as a flonum; the result is computed as if x was represented as a fraction in lowest terms. The denominator is always positive. The numerator of an infinite flonum is itself. The denominator of an infinite or zero flonum is 1.0. The numerator and denominator of a NaN is a NaN.
(scheme flonum) procedure (flfloor (x flonum?) ) ⟹ flonum?
Returns the largest integral flonum not larger than x. (C99 floor)
(scheme flonum) procedure (flceiling (x flonum?) ) ⟹ flonum?
Returns the smallest integral flonum not smaller than x. (C99 ceil)
(scheme flonum) procedure (flround (x flonum?) ) ⟹ flonum?
Returns the closest integral flonum to x, rounding to even when x represents a number halfway between two integers. (Not the same as C99 round, which rounds away from zero)
(scheme flonum) procedure (fltruncate (x flonum?) ) ⟹ flonum?
Returns the closest integral flonum to x whose absolute value is not larger than the absolute value of x (C99 trunc)
(scheme flonum) procedure (flexp (x flonum?) ) ⟹ flonum?
Returns e^x. (C99 exp)
(scheme flonum) procedure (flexp2 (x flonum?) ) ⟹ flonum?
Returns 2^x. (C99 exp2)
(scheme flonum) procedure (flexp-1 (x flonum?) ) ⟹ flonum?
Returns e^x - 1, but is much more accurate than flexp for very small values of x. It is recommended for use in algorithms where accuracy is important. (C99 expm1)
(scheme flonum) procedure (flsquare (x flonum?) ) ⟹ flonum?
Returns x^2.
(scheme flonum) procedure (flsqrt (x flonum?) ) ⟹ flonum?
Returns x^0.5. For -0.0, flsqrt should return -0.0. (C99 sqrt)
(scheme flonum) procedure (flcbrt (x flonum?) ) ⟹ flonum?
Returns x^(1/3). (C99 cbrt)
(scheme flonum) procedure (flhypot (x flonum?) (y flonum?) ) ⟹ flonum?
Returns the length of the hypotenuse of a right triangle whose sides are of length |x| and |y|. (C99 hypot)
(scheme flonum) procedure (flexpt (x flonum?) (y flonum?) ) ⟹ flonum?
Returns x^y. If x is zero, then the result is zero. (C99 pow)
(scheme flonum) procedure (fllog (x flonum?) ) ⟹ flonum?
Returns loge x. (C99 log)
(scheme flonum) procedure (fllog1+ (x flonum?) ) ⟹ flonum?
Returns loge (x+ 1), but is much more accurate than fllog for values of x near 0. It is recommended for use in algorithms where accuracy is important. (C99 log1p)
(scheme flonum) procedure (fllog2 (x flonum?) ) ⟹ flonum?
Returns log2 x. (C99 log2)
(scheme flonum) procedure (fllog10 (x flonum?) ) ⟹ flonum?
Returns log10 x. (C99 log10)
(scheme flonum) procedure (make-fllog-base (base flonum?) ) ⟹ procedure?
(return (x flonum?) ) ⟹ flonum?
Returns a procedure that calculates the base-x logarithm of its argument. If x is 1.0 or less than 1.0, it is an error.
(scheme flonum) procedure (flsin (x flonum?) ) ⟹ flonum?
Returns sin x. (C99 sin)
(scheme flonum) procedure (flcos (x flonum?) ) ⟹ flonum?
Returns cos x. (C99 cos)
(scheme flonum) procedure (fltan (x flonum?) ) ⟹ flonum?
Returns tan x. (C99 tan)
(scheme flonum) procedure (flasin (x flonum?) ) ⟹ flonum?
Returns arcsin x. (C99 asin)
(scheme flonum) procedure (flacos (x flonum?) ) ⟹ flonum?
Returns arccos x. (C99 acos)
(scheme flonum) procedure (flatan (x flonum?) ) ⟹ flonum?
(scheme flonum) procedure (flatan (y flonum?) (x flonum?) ) ⟹ flonum?
Returns arctan x. (C99 atan)
With two arguments, returns arctan(y/x). in the range [-π,π], using the signs of x and y to choose the correct quadrant for the result. (C99 atan2)
(scheme flonum) procedure (flsinh (x flonum?) ) ⟹ flonum?
Returns sinh x. (C99 sinh)
(scheme flonum) procedure (flcosh (x flonum?) ) ⟹ flonum?
Returns cosh x. (C99 cosh)
(scheme flonum) procedure (fltanh (x flonum?) ) ⟹ flonum?
Returns tanh x. (C99 tanh)
(scheme flonum) procedure (flasinh (x flonum?) ) ⟹ flonum?
Returns arcsinh x. (C99 asinh)
(scheme flonum) procedure (flacosh (x flonum?) ) ⟹ flonum?
Returns arccosh x. (C99 acosh)
(scheme flonum) procedure (flatanh (x flonum?) ) ⟹ flonum?
Returns arctanh x. (C99 atanh)
(scheme flonum) procedure (flquotient (x flonum?) (y flonum?) ) ⟹ flonum?
Returns the quotient of x/y as an integral flonum, truncated towards zero.
(scheme flonum) procedure (flremainder (x flonum?) (y flonum?) ) ⟹ flonum?
Returns the truncating remainder of x/y as an integral flonum.
(scheme flonum) procedure (flremquo (x flonum?) (y flonum?) ) ⟹ (values flonum?integer?)
Returns two values, the rounded remainder of x/y and the low-order n bits (as a correctly signed exact integer) of the rounded quotient. The value of n is implementation-dependent but at least 3. This procedure can be used to reduce the argument of the inverse trigonometric functions, while preserving the correct quadrant or octant. (C99 remquo)
(scheme flonum) procedure (flgamma (x flonum?) ) ⟹ flonum?
Returns Γ(x), the gamma function applied to x. This is equal to (x-1)! for integers. (C99 tgamma)
(scheme flonum) procedure (flloggamma (x flonum?) ) ⟹ flonum?
Returns two values, log |Γ(x)| without internal overflow, and the sign of Γ(x) as 1.0 if it is positive and -1.0 if it is negative. (C99 lgamma)
(scheme flonum) procedure (flfirst-bessel (n integer?) (x flonum?) ) ⟹ flonum?
Returns the nth order Bessel function of the first kind applied to x, Jn(x). (jn, which is an XSI Extension of C99)
(scheme flonum) procedure (flsecond-bessel (n integer?) (x flonum?) ) ⟹ flonum?
Returns the nth order Bessel function of the second kind applied to x, Yn(x). (yn, which is an XSI Extension of C99)
(scheme flonum) procedure (flerf (x flonum?) ) ⟹ flonum?
Returns the error function erf(x). (C99 erf)
(scheme flonum) procedure (flerfc (x flonum?) ) ⟹ flonum?
Returns the complementary error function, 1 - erf(x). (C99 erfc)
library (scheme mapping)
(scheme mapping) procedure (mapping (comparator comparator?) arg ... ) ⟹ mapping?
Returns a newly allocated mapping. The comparator argument is a SRFI 128 comparator, which is used to control and distinguish the keys of the mapping. The args alternate between keys and values and are used to initialize the mapping. In particular, the number of args has to be even. Earlier associations with equal keys take precedence over later arguments.
(scheme mapping) procedure (mapping-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (comparator comparator?) ) ⟹ mapping?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ (values **)
(successor seed ) ⟹ *
Create a newly allocated mapping as if by mapping using comparator. If the result of applying the predicate stop? to seed is true, return the mapping. Otherwise, apply the procedure mapper to seed. Mapper returns two values which are added to the mapping as the key and the value, respectively. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm. Associations earlier in the list take precedence over those that come later.
(scheme mapping) procedure (mapping? obj ) ⟹ boolean?
Returns #t if obj is a mapping, and #f otherwise.
(scheme mapping) procedure (mapping-contains? (mapping mapping?) key ) ⟹ boolean?
Returns #t if key is the key of an association of mapping and #f otherwise.
(scheme mapping) procedure (mapping-empty? (mapping mapping?) ) ⟹ boolean?
Returns #t if mapping has no associations and #f otherwise.
(scheme mapping) procedure (mapping-disjoint? (mapping1 mapping?) (mapping2 mapping?) ) ⟹ boolean?
Returns #t if mapping1 and mapping2 have no keys in common and #f otherwise.
(scheme mapping) procedure (mapping-ref (mapping mapping?) key ) ⟹ *
(scheme mapping) procedure (mapping-ref (mapping mapping?) key (failure procedure?) ) ⟹ *
(scheme mapping) procedure (mapping-ref (mapping mapping?) key (failure procedure?) (success procedure?) ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Extracts the value associated to key in the mapping mapping, invokes the procedure success in tail context on it, and returns its result; if success is not provided, then the value itself is returned. If key is not contained in mapping and failure is supplied, then failure is invoked in tail context on no arguments and its values are returned. Otherwise, it is an error.
(scheme mapping) procedure (mapping-ref/default (mapping mapping?) key default ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(mapping-ref mapping key (lambda () default))
(scheme mapping) procedure (mapping-key-comparator (mapping mapping?) ) ⟹ comparator?
Returns the comparator used to compare the keys of the mapping mapping.
(scheme mapping) procedure (mapping-adjoin (mapping mapping?) key1 value1 ... ) ⟹ mapping?
The mapping-adjoin procedure returns a newly allocated mapping that uses the same comparator as the mapping mapping and contains all the associations of mapping, and in addition new associations by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, the previous association prevails and the new association is skipped. It is an error to add an association to mapping whose key that does not return #t when passed to the type test procedure of the comparator.
(scheme mapping) procedure (mapping-adjoin! (mapping mapping?) key1 value1 ... ) ⟹ mapping?
The mapping-adjoin! procedure is the same as mapping-adjoin, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(scheme mapping) procedure (mapping-set (mapping mapping?) key1 value1 ... ) ⟹ mapping?
The mapping-set procedure returns a newly allocated mapping that uses the same comparator as the mapping mapping and contains all the associations of mapping, and in addition new associations by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, it is deleted. It is an error to add an association to mapping whose key that does not return #t when passed to the type test procedure of the comparator.
(scheme mapping) procedure (mapping-set! (mapping mapping?) key1 value1 ... ) ⟹ mapping?
The mapping-set! procedure is the same as mapping-set, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(scheme mapping) procedure (mapping-replace (mapping mapping?) key value ) ⟹ mapping?
The mapping-replace procedure returns a newly allocated mapping that uses the same comparator as the mapping mapping and contains all the associations of mapping except as follows: If key is equal (in the sense of mapping's comparator) to an existing key of mapping, then the association for that key is omitted and replaced the association defined by the pair key and value. If there is no such key in mapping, then mapping is returned unchanged.
(scheme mapping) procedure (mapping-replace! (mapping mapping?) key value ) ⟹ mapping?
The mapping-replace! procedure is the same as mapping-replace, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(scheme mapping) procedure (mapping-delete (mapping mapping?) key ... ) ⟹ mapping?
(scheme mapping) procedure (mapping-delete! (mapping mapping?) key ... ) ⟹ mapping?
(scheme mapping) procedure (mapping-delete-all (mapping mapping?) (keys list?) ) ⟹ mapping?
(scheme mapping) procedure (mapping-delete-all! (mapping mapping?) (keys list?) ) ⟹ mapping?
The mapping-delete procedure returns a newly allocated mapping containing all the associations of the mapping mapping except for any whose keys are equal (in the sense of mapping's comparator) to one or more of the keys. Any key that is not equal to some key of the mapping is ignored.
The mapping-delete! procedure is the same as mapping-delete, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
The mapping-delete-all and mapping-delete-all! procedures are the same as mapping-delete and mapping-delete!, respectively, except that they accept a single argument which is a list of keys whose associations are to be deleted.
(scheme mapping) procedure (mapping-intern (mapping mapping?) key (failure procedure?) ) ⟹ (values mapping?*)
(failure ) ⟹ *
Extracts the value associated to key in the mapping mapping, and returns mapping and the value as two values. If key is not contained in mapping, failure is invoked on no arguments. The procedure then returns two values, a newly allocated mapping that uses the same comparator as the mapping and contains all the associations of mapping, and in addition a new association mapping key to the result of invoking failure, and the result of invoking failure.
(scheme mapping) procedure (mapping-intern! (mapping mapping?) key (failure procedure?) ) ⟹ (values mapping?*)
(failure ) ⟹ *
The mapping-intern! procedure is the same as mapping-intern, except that it is permitted to mutate and return the mapping argument as its first value rather than allocating a new mapping.
(scheme mapping) procedure (mapping-update (mapping mapping?) key (updater procedure?) ) ⟹ mapping?
(scheme mapping) procedure (mapping-update (mapping mapping?) key (updater procedure?) (failure procedure?) ) ⟹ mapping?
(scheme mapping) procedure (mapping-update (mapping mapping?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ mapping?
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code
(mapping-set mapping key (updater (mapping-ref mapping key failure success)))
(scheme mapping) procedure (mapping-update! (mapping mapping?) key (updater procedure?) ) ⟹ mapping?
(scheme mapping) procedure (mapping-update! (mapping mapping?) key (updater procedure?) (failure procedure?) ) ⟹ mapping?
(scheme mapping) procedure (mapping-update! (mapping mapping?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ mapping?
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
The mapping-update! procedure is the same as mapping-update, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(scheme mapping) procedure (mapping-update/default (mapping mapping?) key (updater procedure?) default ) ⟹ mapping?
(updater value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code
(mapping-set mapping key (updater (mapping-ref/default mapping key default)))
(scheme mapping) procedure (mapping-update!/default (mapping mapping?) key (updater procedure?) default ) ⟹ mapping?
(updater value ) ⟹ *
The mapping-update!/default procedure is the same as mapping-update/default, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(scheme mapping) procedure (mapping-pop (mapping mapping?) ) ⟹ (values mapping?**)
(scheme mapping) procedure (mapping-pop (mapping mapping?) (failure procedure?) ) ⟹ (values mapping?**)
(failure ) ⟹ (values mapping?**)
The mapping-pop procedure exported from (srfi 146) chooses the association with the least key from mapping and returns three values, a newly allocated mapping that uses the same comparator as mapping and contains all associations of mapping except the chosen one, and the key and the value of the chosen association. If mapping contains no association and failure is supplied, then failure is invoked in tail context on no arguments and its values returned. Otherwise, it is an error.
(scheme mapping) procedure (mapping-pop! (mapping mapping?) ) ⟹ (values mapping?**)
(scheme mapping) procedure (mapping-pop! (mapping mapping?) (failure procedure?) ) ⟹ (values mapping?**)
(failure ) ⟹ (values mapping?**)
The mapping-pop! procedure is the same as mapping-pop, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(scheme mapping) procedure (mapping-search (mapping mapping?) key (failure procedure?) (success procedure?) ) ⟹ (values mapping?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert value obj ) ⟹ *
(ignore obj ) ⟹ *
(success key value (update procedure?) (remove procedure?) ) ⟹ *
(update new-key new-value obj ) ⟹ *
(remove obj ) ⟹ *
The mapping mapping is searched in order (that is in the order of the stored keys) for an association with key key. If it is not found, then the failure procedure is tail-called with two continuation arguments, insert and ignore, and is expected to tail-call one of them. If an association with key key is found, then the success procedure is tail-called with the matching key of mapping, the associated value, and two continuations, update and remove, and is expected to tail-call one of them.
It is an error if the continuation arguments are invoked, but not in tail position in the failure and success procedures. It is also an error if the failure and success procedures return to their implicit continuation without invoking one of their continuation arguments.
The effects of the continuations are as follows (where obj is any Scheme object):
In all cases, two values are returned: the possibly newly allocated mapping and obj.
(scheme mapping) procedure (mapping-search! (mapping mapping?) key (failure procedure?) (success procedure?) ) ⟹ (values mapping?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert value obj ) ⟹ *
(ignore obj ) ⟹ *
(success key value (update procedure?) (remove procedure?) ) ⟹ *
(update new-key new-value obj ) ⟹ *
(remove obj ) ⟹ *
The mapping-search! procedure is the same as mapping-search, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(scheme mapping) procedure (mapping-size (mapping mapping?) ) ⟹ integer?
Returns the number of associations in mapping as an exact integer.
(scheme mapping) procedure (mapping-find (predicate procedure?) (mapping mapping?) (failure procedure?) ) ⟹ (values **)
(predicate key value ) ⟹ boolean?
(failure ) ⟹ *
Returns the association with the least key of the mapping mapping consisting of a key and value as two values such that predicate returns a true value when invoked with key and value as arguments, or the result of tail-calling failure with no arguments if there is none. There are no guarantees how many times and with which keys and values predicate is invoked.
(scheme mapping) procedure (mapping-count (predicate procedure?) (mapping mapping?) ) ⟹ integer?
(predicate key value ) ⟹ boolean?
Returns the number of associations of the mapping mapping that satisfy predicate (in the sense of mapping-find) as an exact integer. There are no guarantees how many times and with which keys and values predicate is invoked.
(scheme mapping) procedure (mapping-any? (predicate procedure?) (mapping mapping?) ) ⟹ boolean?
(predicate key value ) ⟹ boolean?
Returns #t if any association of the mapping mapping satisfies predicate (in the sense of mapping-find), or #f otherwise. There are no guarantees how many times and with which keys and values predicate is invoked.
(scheme mapping) procedure (mapping-every? (predicate procedure?) (mapping mapping?) ) ⟹ boolean?
(predicate key value ) ⟹ boolean?
Returns #t if every association of the mapping mapping satisfies predicate (in the sense of mapping-find), or #f otherwise. There are no guarantees how many times and with which keys and values predicate is invoked.
(scheme mapping) procedure (mapping-keys (mapping mapping?) ) ⟹ list?
Returns a newly allocated list of all the keys in increasing order in the mapping mapping.
(scheme mapping) procedure (mapping-values (mapping mapping?) ) ⟹ list?
Returns a newly allocated list of all the values in increasing order of the keys in the mapping mapping.
(scheme mapping) procedure (mapping-entries (mapping mapping?) ) ⟹ (values list?list?)
Returns two values, a newly allocated list of all the keys in the mapping mapping, and a newly allocated list of all the values in the mapping mapping in increasing order of the keys.
(scheme mapping) procedure (mapping-map (proc procedure?) (comparator comparator?) (mapping mapping?) ) ⟹ mapping?
(proc key value ) ⟹ (values **)
Applies proc, which returns two values, on two arguments, the key and value of each association of mapping in increasing order of the keys and returns a newly allocated mapping that uses the comparator comparator, and which contains the results of the applications inserted as keys and values.
Note that, when proc defines a mapping that is not 1:1 between the keys, some of the mapped objects may be equivalent in the sense of the comparator's equality predicate, and in this case duplicate associations are omitted as in the mapping constructor. It is unpredictable which one will be preserved in the result.
(scheme mapping) procedure (mapping-for-each (proc procedure?) (comparator comparator?) (mapping mapping?) ) ⟹ undefined
(proc key value ) ⟹ undefined
Invokes proc for every association in the mapping mapping in increasing order of the keys, discarding the returned values, with two arguments: the key of the association and the value of the association. Returns an unspecified value.
(scheme mapping) procedure (mapping-fold (proc procedure?) nil (mapping mapping?) ) ⟹ *
(proc key value state ) ⟹ *
Invokes proc for each association of the mapping mapping in increasing order of the keys with three arguments: the key of the association, the value of the association, and an accumulated result of the previous invocation. For the first invocation, nil is used as the third argument. Returns the result of the last invocation, or nil if there was no invocation.
(scheme mapping) procedure (mapping-map->list (proc procedure?) (mapping mapping?) ) ⟹ list?
(proc key value ) ⟹ *
Calls proc for every association in increasing order of the keys in the mapping mapping with two arguments: the key of the association and the value of the association. The values returned by the invocations of proc are accumulated into a list, which is returned.
(scheme mapping) procedure (mapping-filter (predicate procedure?) (mapping mapping?) ) ⟹ mapping?
(predicate key value ) ⟹ boolean?
Returns a newly allocated mapping with the same comparator as the mapping mapping, containing just the associations of mapping that satisfy predicate (in the sense of mapping-find).
(scheme mapping) procedure (mapping-filter! (predicate procedure?) (mapping mapping?) ) ⟹ mapping?
(predicate key value ) ⟹ boolean?
A linear update procedure that returns a mapping containing just the associations of mapping that satisfy predicate.
(scheme mapping) procedure (mapping-remove (predicate procedure?) (mapping mapping?) ) ⟹ mapping?
(predicate key value ) ⟹ boolean?
Returns a newly allocated mapping with the same comparator as the mapping mapping, containing just the associations of mapping that do not satisfy predicate (in the sense of mapping-find).
(scheme mapping) procedure (mapping-remove! (predicate procedure?) (mapping mapping?) ) ⟹ mapping?
(predicate key value ) ⟹ boolean?
A linear update procedure that returns a mapping containing just the associations of mapping that do not satisfy predicate.
(scheme mapping) procedure (mapping-partition (predicate procedure?) (mapping mapping?) ) ⟹ (values mapping?mapping?)
(predicate key value ) ⟹ boolean?
Returns two values: a newly allocated mapping with the same comparator as the mapping mapping that contains just the associations of mapping that satisfy predicate (in the sense of mapping-find), and another newly allocated mapping, also with the same comparator, that contains just the associations of mapping that do not satisfy predicate.
(scheme mapping) procedure (mapping-partition! (predicate procedure?) (mapping mapping?) ) ⟹ (values mapping?mapping?)
(predicate key value ) ⟹ boolean?
A linear update procedure that returns two mappings containing the associations of mapping that do and do not, respectively, satisfy predicate.
(scheme mapping) procedure (mapping-copy (mapping mapping?) ) ⟹ mapping?
Returns a newly allocated mapping containing the associations of the mapping mapping, and using the same comparator.
(scheme mapping) procedure (mapping->alist (mapping mapping?) ) ⟹ list?
Returns a newly allocated association list containing the associations of the mapping in increasing order of the keys. Each association in the list is a pair whose car is the key and whose cdr is the associated value.
(scheme mapping) procedure (alist->mapping (comparator comparator?) (alist list?) ) ⟹ mapping?
Returns a newly allocated mapping, created as if by mapping using the comparator comparator, that contains the associations in the list, which consist of a pair whose car is the key and whose cdr is the value. Associations earlier in the list take precedence over those that come later.
(scheme mapping) procedure (alist->mapping! (mapping mapping?) (alist list?) ) ⟹ mapping?
A linear update procedure that returns a mapping that contains the associations of both mapping and alist. Associations in the mapping and those earlier in the list take precedence over those that come later.
(scheme mapping) procedure (mapping=? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if each mapping mapping contains the same associations, and #f otherwise.
Furthermore, it is explicitly not an error if mapping=? is invoked on mappings that do not share the same (key) comparator. In that case, #f is returned.
(scheme mapping) procedure (mapping<? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if the set of associations of each mapping mapping other than the last is a proper subset of the following mapping, and #f otherwise.
(scheme mapping) procedure (mapping>? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if the set of associations of each mapping mapping other than the last is a proper superset of the following mapping, and #f otherwise.
(scheme mapping) procedure (mapping<=? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if the set of associations of each mapping mapping other than the last is a subset of the following mapping, and #f otherwise.
(scheme mapping) procedure (mapping>=? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if the set of associations of each mapping mapping other than the last is a superset of the following mapping, and #f otherwise.
(scheme mapping) procedure (mapping-union (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(scheme mapping) procedure (mapping-intersection (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(scheme mapping) procedure (mapping-difference (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(scheme mapping) procedure (mapping-xor (mapping1 mapping?) (mapping2 mapping?) ) ⟹ mapping?
Return a newly allocated mapping whose set of associations is the union, intersection, asymmetric difference, or symmetric difference of the sets of associations of the mappings mappings. Asymmetric difference is extended to more than two mappings by taking the difference between the first mapping and the union of the others. Symmetric difference is not extended beyond two mappings. When comparing associations, only the keys are compared. In case of duplicate keys (in the sense of the mappings comparators), associations in the result mapping are drawn from the first mapping in which they appear.
(scheme mapping) procedure (mapping-union! (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(scheme mapping) procedure (mapping-intersection! (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(scheme mapping) procedure (mapping-difference! (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(scheme mapping) procedure (mapping-xor! (mapping1 mapping?) (mapping2 mapping?) ) ⟹ mapping?
These procedures are the linear update analogs of the corresponding pure functional procedures above.
(scheme mapping) procedure (mapping/ordered (comparator comparator?) arg ... ) ⟹ mapping?
(scheme mapping) procedure (mapping-unfold/ordered (stop? procedure?) (mapper procedure?) (successor procedure?) seed (comparator comparator?) ) ⟹ mapping?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ (values **)
(successor seed ) ⟹ *
These are the same as mapping and mapping-unfold, except that it is an error if the keys are not in order, and they may be more efficient.
(scheme mapping) procedure (alist->mapping/ordered (comparator comparator?) (alist list?) ) ⟹ mapping?
(scheme mapping) procedure (alist->mapping/ordered! (mapping mapping?) (alist list?) ) ⟹ mapping?
These are the same as alist->mapping and alist->mapping!, except that it is an error if the keys are not in order, and they may be more efficient.
(scheme mapping) procedure (mapping-min-key (mapping mapping?) ) ⟹ *
(scheme mapping) procedure (mapping-max-key (mapping mapping?) ) ⟹ *
Returns the least/greatest key contained in the mapping mapping. It is an error for mapping to be empty.
(scheme mapping) procedure (mapping-min-value (mapping mapping?) ) ⟹ *
(scheme mapping) procedure (mapping-max-value (mapping mapping?) ) ⟹ *
Returns the value associated with the least/greatest key contained in the mapping mapping. It is an error for mapping to be empty.
(scheme mapping) procedure (mapping-min-entry (mapping mapping?) ) ⟹ (values **)
(scheme mapping) procedure (mapping-max-entry (mapping mapping?) ) ⟹ (values **)
Returns the entry associated with the least/greatest key contained in the mapping mapping as two values, the key and its associated value. It is an error for mapping to be empty.
(scheme mapping) procedure (mapping-key-predecessor (mapping mapping?) obj (failure procedure?) ) ⟹ *
(failure ) ⟹ *
(scheme mapping) procedure (mapping-key-successor (mapping mapping?) obj (failure procedure?) ) ⟹ *
(failure ) ⟹ *
Returns the key contained in the mapping mapping that immediately precedes/succeeds obj in the mapping's order of keys. If no such key is contained in mapping (because obj is the minimum/maximum key, or because mapping is empty), returns the result of tail-calling the thunk failure.
(scheme mapping) procedure (mapping-range= (mapping mapping?) obj ) ⟹ mapping?
(scheme mapping) procedure (mapping-range< (mapping mapping?) obj ) ⟹ mapping?
(scheme mapping) procedure (mapping-range> (mapping mapping?) obj ) ⟹ mapping?
(scheme mapping) procedure (mapping-range<= (mapping mapping?) obj ) ⟹ mapping?
(scheme mapping) procedure (mapping-range>= (mapping mapping?) obj ) ⟹ mapping?
Returns a mapping containing only the associations of the mapping whose keys are equal to, less than, greater than, less than or equal to, or greater than or equal to obj.
(scheme mapping) procedure (mapping-range=! (mapping mapping?) obj ) ⟹ mapping?
(scheme mapping) procedure (mapping-range<! (mapping mapping?) obj ) ⟹ mapping?
(scheme mapping) procedure (mapping-range>! (mapping mapping?) obj ) ⟹ mapping?
(scheme mapping) procedure (mapping-range<=! (mapping mapping?) obj ) ⟹ mapping?
(scheme mapping) procedure (mapping-range>=! (mapping mapping?) obj ) ⟹ mapping?
Linear update procedures returning a mapping containing only the associations of the mapping whose keys are equal to, less than, greater than, less than or equal to, or greater than or equal to obj.
(scheme mapping) procedure (mapping-split (mapping mapping?) obj ) ⟹ (values mapping?mapping?mapping?mapping?mapping?)
Returns five values, equivalent to the results of invoking (mapping-range< mapping obj), (mapping-range<= mapping obj), (mapping-range= mapping obj), (mapping-range>= mapping obj), and (mapping-range> mapping obj), but may be more efficient.
(scheme mapping) procedure (mapping-split! (mapping mapping?) obj ) ⟹ (values mapping?mapping?mapping?mapping?mapping?)
The mapping-split! procedure is the same as mapping-split, except that it is permitted to mutate and return the mapping rather than allocating a new mapping.
(scheme mapping) procedure (mapping-catenate (mapping1 mapping?) key value (mapping2 mapping?) ) ⟹ mapping?
Returns a newly allocated mapping using the comparator comparator whose set of associations is the union of the sets of associations of the mapping mapping1, the association mapping key to value, and the associations of mapping2. It is an error if the keys contained in mapping1 in their natural order, the key key, and the keys contained in mapping2 in their natural order (in that order) do not form a strictly monotone sequence with respect to the ordering of comparator.
(scheme mapping) procedure (mapping-catenate! (mapping1 mapping?) key value (mapping2 mapping?) ) ⟹ mapping?
The mapping-catenate! procedure is the same as mapping-catenate, except that it is permitted to mutate and return one of the mappings rather than allocating a new mapping.
(scheme mapping) procedure (mapping-map/monotone (proc procedure?) (comparator comparator?) (mapping mapping?) ) ⟹ mapping?
(proc key value ) ⟹ (values **)
Equivalent to (mapping-map proc comparator mapping), but it is an error if proc does not induce a strictly monotone mapping between the keys with respect to the ordering of the comparator of mapping and the ordering of comparator. Maybe be implemented more efficiently than mapping-map.
(scheme mapping) procedure (mapping-map/monotone! (proc procedure?) (comparator comparator?) (mapping mapping?) ) ⟹ mapping?
(proc key value ) ⟹ (values **)
The mapping-map/monotone! procedure is the same as mapping-map/monotone, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(scheme mapping) procedure (mapping-fold/reverse (proc procedure?) nil (mapping mapping?) ) ⟹ *
(proc key value state ) ⟹ *
Equivalent to (mapping-fold proc nil mapping) except that the associations are processed in reverse order with respect to the natural ordering of the keys.
(scheme mapping) procedure (comparator? obj ) ⟹ boolean?
Type predicate for comparators as exported by (srfi 128).
(scheme mapping) procedure (make-mapping-comparator (comparator comparator?) ) ⟹ comparator?
Returns a comparator for mappings that is compatible with the equality predicate (mapping=? comparator mapping1 mapping2). It provides a (partial) ordering predicate that is applicable to pairs of mappings with the same (key) comparator. The lexicographic ordering with respect to the keys (and, in case a tiebreak is necessary, with respect to the ordering of the values) is used for mappings sharing a comparator. The existence of comparators returned by make-mapping-comparator allows mappings whose keys are mappings themselves, and it allows to compare mappings whose values are mappings.
mapping-comparator ⟹ comparator?
mapping-comparator is constructed by invoking make-mapping-comparator on (make-default-comparator).
library (scheme hashmap)
(scheme hashmap) procedure (hashmap (comparator comparator?) arg ... ) ⟹ hashmap?
Returns a newly allocated hashmap. The comparator argument is a SRFI 128 comparator, which is used to control and distinguish the keys of the hashmap. The args alternate between keys and values and are used to initialize the hashmap. In particular, the number of args has to be even. Earlier associations with equal keys take precedence over later arguments.
(scheme hashmap) procedure (hashmap-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (comparator comparator?) ) ⟹ hashmap?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ (values **)
(successor seed ) ⟹ *
Create a newly allocated hashmap as if by hashmap using comparator. If the result of applying the predicate stop? to seed is true, return the hashmap. Otherwise, apply the procedure mapper to seed. Mapper returns two values which are added to the hashmap as the key and the value, respectively. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm. Associations earlier in the list take precedence over those that come later.
(scheme hashmap) procedure (hashmap? obj ) ⟹ boolean?
Returns #t if obj is a hashmap, and #f otherwise.
(scheme hashmap) procedure (hashmap-contains? (hashmap hashmap?) key ) ⟹ boolean?
Returns #t if key is the key of an association of hashmap and #f otherwise.
(scheme hashmap) procedure (hashmap-empty? (hashmap hashmap?) ) ⟹ boolean?
Returns #t if hashmap has no associations and #f otherwise.
(scheme hashmap) procedure (hashmap-disjoint? (hashmap1 hashmap?) (hashmap2 hashmap?) ) ⟹ boolean?
Returns #t if hashmap1 and hashmap2 have no keys in common and #f otherwise.
(scheme hashmap) procedure (hashmap-ref (hashmap hashmap?) key ) ⟹ *
(scheme hashmap) procedure (hashmap-ref (hashmap hashmap?) key (failure procedure?) ) ⟹ *
(scheme hashmap) procedure (hashmap-ref (hashmap hashmap?) key (failure procedure?) (success procedure?) ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Extracts the value associated to key in the hashmap hashmap, invokes the procedure success in tail context on it, and returns its result; if success is not provided, then the value itself is returned. If key is not contained in hashmap and failure is supplied, then failure is invoked in tail context on no arguments and its values are returned. Otherwise, it is an error.
(scheme hashmap) procedure (hashmap-ref/default (hashmap hashmap?) key default ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(hashmap-ref hashmap key (lambda () default))
(scheme hashmap) procedure (hashmap-key-comparator (hashmap hashmap?) ) ⟹ comparator?
Returns the comparator used to compare the keys of the hashmap hashmap.
(scheme hashmap) procedure (hashmap-adjoin (hashmap hashmap?) key1 value1 ... ) ⟹ hashmap?
The hashmap-adjoin procedure returns a newly allocated hashmap that uses the same comparator as the hashmap hashmap and contains all the associations of hashmap, and in addition new associations by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, the previous association prevails and the new association is skipped. It is an error to add an association to hashmap whose key that does not return #t when passed to the type test procedure of the comparator.
(scheme hashmap) procedure (hashmap-adjoin! (hashmap hashmap?) key1 value1 ... ) ⟹ hashmap?
The hashmap-adjoin! procedure is the same as hashmap-adjoin, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(scheme hashmap) procedure (hashmap-set (hashmap hashmap?) key1 value1 ... ) ⟹ hashmap?
The hashmap-set procedure returns a newly allocated hashmap that uses the same comparator as the hashmap hashmap and contains all the associations of hashmap, and in addition new associations by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, it is deleted. It is an error to add an association to hashmap whose key that does not return #t when passed to the type test procedure of the comparator.
(scheme hashmap) procedure (hashmap-set! (hashmap hashmap?) key1 value1 ... ) ⟹ hashmap?
The hashmap-set! procedure is the same as hashmap-set, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(scheme hashmap) procedure (hashmap-replace (hashmap hashmap?) key value ) ⟹ hashmap?
The hashmap-replace procedure returns a newly allocated hashmap that uses the same comparator as the hashmap hashmap and contains all the associations of hashmap except as follows: If key is equal (in the sense of hashmap's comparator) to an existing key of hashmap, then the association for that key is omitted and replaced the association defined by the pair key and value. If there is no such key in hashmap, then hashmap is returned unchanged.
(scheme hashmap) procedure (hashmap-replace! (hashmap hashmap?) key value ) ⟹ hashmap?
The hashmap-replace! procedure is the same as hashmap-replace, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(scheme hashmap) procedure (hashmap-delete (hashmap hashmap?) key ... ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-delete! (hashmap hashmap?) key ... ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-delete-all (hashmap hashmap?) (keys list?) ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-delete-all! (hashmap hashmap?) (keys list?) ) ⟹ hashmap?
The hashmap-delete procedure returns a newly allocated hashmap containing all the associations of the hashmap hashmap except for any whose keys are equal (in the sense of hashmap's comparator) to one or more of the keys. Any key that is not equal to some key of the hashmap is ignored.
The hashmap-delete! procedure is the same as hashmap-delete, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
The hashmap-delete-all and hashmap-delete-all! procedures are the same as hashmap-delete and hashmap-delete!, respectively, except that they accept a single argument which is a list of keys whose associations are to be deleted.
(scheme hashmap) procedure (hashmap-intern (hashmap hashmap?) key (failure procedure?) ) ⟹ (values hashmap?*)
(failure ) ⟹ *
Extracts the value associated to key in the hashmap hashmap, and returns hashmap and the value as two values. If key is not contained in hashmap, failure is invoked on no arguments. The procedure then returns two values, a newly allocated hashmap that uses the same comparator as the hashmap and contains all the associations of hashmap, and in addition a new association hashmap key to the result of invoking failure, and the result of invoking failure.
(scheme hashmap) procedure (hashmap-intern! (hashmap hashmap?) key (failure procedure?) ) ⟹ (values hashmap?*)
(failure ) ⟹ *
The hashmap-intern! procedure is the same as hashmap-intern, except that it is permitted to mutate and return the hashmap argument as its first value rather than allocating a new hashmap.
(scheme hashmap) procedure (hashmap-update (hashmap hashmap?) key (updater procedure?) ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-update (hashmap hashmap?) key (updater procedure?) (failure procedure?) ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-update (hashmap hashmap?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ hashmap?
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code
(hashmap-set hashmap key (updater (hashmap-ref hashmap key failure success)))
(scheme hashmap) procedure (hashmap-update! (hashmap hashmap?) key (updater procedure?) ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-update! (hashmap hashmap?) key (updater procedure?) (failure procedure?) ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-update! (hashmap hashmap?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ hashmap?
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
The hashmap-update! procedure is the same as hashmap-update, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(scheme hashmap) procedure (hashmap-update/default (hashmap hashmap?) key (updater procedure?) default ) ⟹ hashmap?
(updater value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code
(hashmap-set hashmap key (updater (hashmap-ref/default hashmap key default)))
(scheme hashmap) procedure (hashmap-update!/default (hashmap hashmap?) key (updater procedure?) default ) ⟹ hashmap?
(updater value ) ⟹ *
The hashmap-update!/default procedure is the same as hashmap-update/default, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(scheme hashmap) procedure (hashmap-pop (hashmap hashmap?) ) ⟹ (values hashmap?**)
(scheme hashmap) procedure (hashmap-pop (hashmap hashmap?) (failure procedure?) ) ⟹ (values hashmap?**)
(failure ) ⟹ (values hashmap?**)
The hashmap-pop procedure exported from (srfi 146 hash) chooses arbitrary association from hashmap and returns three values, a newly allocated hashmap that uses the same comparator as hashmap and contains all associations of hashmap except the chosen one, and the key and the value of the chosen association. If hashmap contains no association and failure is supplied, then failure is invoked in tail context on no arguments and its values returned. Otherwise, it is an error.
(scheme hashmap) procedure (hashmap-pop! (hashmap hashmap?) ) ⟹ (values hashmap?**)
(scheme hashmap) procedure (hashmap-pop! (hashmap hashmap?) (failure procedure?) ) ⟹ (values hashmap?**)
(failure ) ⟹ (values hashmap?**)
The hashmap-pop! procedure is the same as hashmap-pop, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(scheme hashmap) procedure (hashmap-search (hashmap hashmap?) key (failure procedure?) (success procedure?) ) ⟹ (values hashmap?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert value obj ) ⟹ *
(ignore obj ) ⟹ *
(success key value (update procedure?) (remove procedure?) ) ⟹ *
(update new-key new-value obj ) ⟹ *
(remove obj ) ⟹ *
The hashmap hashmap is searched in arbitrary order for an association with key key. If it is not found, then the failure procedure is tail-called with two continuation arguments, insert and ignore, and is expected to tail-call one of them. If an association with key key is found, then the success procedure is tail-called with the matching key of hashmap, the associated value, and two continuations, update and remove, and is expected to tail-call one of them.
It is an error if the continuation arguments are invoked, but not in tail position in the failure and success procedures. It is also an error if the failure and success procedures return to their implicit continuation without invoking one of their continuation arguments.
The effects of the continuations are as follows (where obj is any Scheme object):
In all cases, two values are returned: the possibly newly allocated hashmap and obj.
(scheme hashmap) procedure (hashmap-search! (hashmap hashmap?) key (failure procedure?) (success procedure?) ) ⟹ (values hashmap?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert value obj ) ⟹ *
(ignore obj ) ⟹ *
(success key value (update procedure?) (remove procedure?) ) ⟹ *
(update new-key new-value obj ) ⟹ *
(remove obj ) ⟹ *
The hashmap-search! procedure is the same as hashmap-search, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(scheme hashmap) procedure (hashmap-size (hashmap hashmap?) ) ⟹ integer?
Returns the number of associations in hashmap as an exact integer.
(scheme hashmap) procedure (hashmap-find (predicate procedure?) (hashmap hashmap?) (failure procedure?) ) ⟹ (values **)
(predicate key value ) ⟹ boolean?
(failure ) ⟹ *
Returns arbitrary association of the hashmap hashmap consisting of a key and value as two values such that predicate returns a true value when invoked with key and value as arguments, or the result of tail-calling failure with no arguments if there is none. There are no guarantees how many times and with which keys and values predicate is invoked.
(scheme hashmap) procedure (hashmap-count (predicate procedure?) (hashmap hashmap?) ) ⟹ integer?
(predicate key value ) ⟹ boolean?
Returns the number of associations of the hashmap hashmap that satisfy predicate (in the sense of hashmap-find) as an exact integer. There are no guarantees how many times and with which keys and values predicate is invoked.
(scheme hashmap) procedure (hashmap-any? (predicate procedure?) (hashmap hashmap?) ) ⟹ boolean?
(predicate key value ) ⟹ boolean?
Returns #t if any association of the hashmap hashmap satisfies predicate (in the sense of hashmap-find), or #f otherwise. There are no guarantees how many times and with which keys and values predicate is invoked.
(scheme hashmap) procedure (hashmap-every? (predicate procedure?) (hashmap hashmap?) ) ⟹ boolean?
(predicate key value ) ⟹ boolean?
Returns #t if every association of the hashmap hashmap satisfies predicate (in the sense of hashmap-find), or #f otherwise. There are no guarantees how many times and with which keys and values predicate is invoked.
(scheme hashmap) procedure (hashmap-keys (hashmap hashmap?) ) ⟹ list?
Returns a newly allocated list of all the keys in arbitrary order in the hashmap hashmap.
(scheme hashmap) procedure (hashmap-values (hashmap hashmap?) ) ⟹ list?
Returns a newly allocated list of all the values in arbitrary order of the keys in the hashmap hashmap.
(scheme hashmap) procedure (hashmap-entries (hashmap hashmap?) ) ⟹ (values list?list?)
Returns two values, a newly allocated list of all the keys in the hashmap hashmap, and a newly allocated list of all the values in the hashmap hashmap in arbitrary but consistent order.
(scheme hashmap) procedure (hashmap-map (proc procedure?) (comparator comparator?) (hashmap hashmap?) ) ⟹ hashmap?
(proc key value ) ⟹ (values **)
Applies proc, which returns two values, on two arguments, the key and value of each association of hashmap in arbitrary order and returns a newly allocated hashmap that uses the comparator comparator, and which contains the results of the applications inserted as keys and values.
Note that, when proc defines a hashmap that is not 1:1 between the keys, some of the mapped objects may be equivalent in the sense of the comparator's equality predicate, and in this case duplicate associations are omitted as in the hashmap constructor. It is unpredictable which one will be preserved in the result.
(scheme hashmap) procedure (hashmap-for-each (proc procedure?) (comparator comparator?) (hashmap hashmap?) ) ⟹ undefined
(proc key value ) ⟹ undefined
Invokes proc for every association in the hashmap hashmap in arbitrary order, discarding the returned values, with two arguments: the key of the association and the value of the association. Returns an unspecified value.
(scheme hashmap) procedure (hashmap-fold (proc procedure?) nil (hashmap hashmap?) ) ⟹ *
(proc key value state ) ⟹ *
Invokes proc for each association of the hashmap hashmap in arbitrary order with three arguments: the key of the association, the value of the association, and an accumulated result of the previous invocation. For the first invocation, nil is used as the third argument. Returns the result of the last invocation, or nil if there was no invocation.
(scheme hashmap) procedure (hashmap-map->list (proc procedure?) (hashmap hashmap?) ) ⟹ list?
(proc key value ) ⟹ *
Calls proc for every association in arbitrary order in the hashmap hashmap with two arguments: the key of the association and the value of the association. The values returned by the invocations of proc are accumulated into a list, which is returned.
(scheme hashmap) procedure (hashmap-filter (predicate procedure?) (hashmap hashmap?) ) ⟹ hashmap?
(predicate key value ) ⟹ boolean?
Returns a newly allocated hashmap with the same comparator as the hashmap hashmap, containing just the associations of hashmap that satisfy predicate (in the sense of hashmap-find).
(scheme hashmap) procedure (hashmap-filter! (predicate procedure?) (hashmap hashmap?) ) ⟹ hashmap?
(predicate key value ) ⟹ boolean?
A linear update procedure that returns a hashmap containing just the associations of hashmap that satisfy predicate.
(scheme hashmap) procedure (hashmap-remove (predicate procedure?) (hashmap hashmap?) ) ⟹ hashmap?
(predicate key value ) ⟹ boolean?
Returns a newly allocated hashmap with the same comparator as the hashmap hashmap, containing just the associations of hashmap that do not satisfy predicate (in the sense of hashmap-find).
(scheme hashmap) procedure (hashmap-remove! (predicate procedure?) (hashmap hashmap?) ) ⟹ hashmap?
(predicate key value ) ⟹ boolean?
A linear update procedure that returns a hashmap containing just the associations of hashmap that do not satisfy predicate.
(scheme hashmap) procedure (hashmap-partition (predicate procedure?) (hashmap hashmap?) ) ⟹ (values hashmap?hashmap?)
(predicate key value ) ⟹ boolean?
Returns two values: a newly allocated hashmap with the same comparator as the hashmap hashmap that contains just the associations of hashmap that satisfy predicate (in the sense of hashmap-find), and another newly allocated hashmap, also with the same comparator, that contains just the associations of hashmap that do not satisfy predicate.
(scheme hashmap) procedure (hashmap-partition! (predicate procedure?) (hashmap hashmap?) ) ⟹ (values hashmap?hashmap?)
(predicate key value ) ⟹ boolean?
A linear update procedure that returns two hashmaps containing the associations of hashmap that do and do not, respectively, satisfy predicate.
(scheme hashmap) procedure (hashmap-copy (hashmap hashmap?) ) ⟹ hashmap?
Returns a newly allocated hashmap containing the associations of the hashmap hashmap, and using the same comparator.
(scheme hashmap) procedure (hashmap->alist (hashmap hashmap?) ) ⟹ list?
Returns a newly allocated association list containing the associations of the hashmap in arbitrary order. Each association in the list is a pair whose car is the key and whose cdr is the associated value.
(scheme hashmap) procedure (alist->hashmap (comparator comparator?) (alist list?) ) ⟹ hashmap?
Returns a newly allocated hashmap, created as if by hashmap using the comparator comparator, that contains the associations in the list, which consist of a pair whose car is the key and whose cdr is the value. Associations earlier in the list take precedence over those that come later.
(scheme hashmap) procedure (alist->hashmap! (hashmap hashmap?) (alist list?) ) ⟹ hashmap?
A linear update procedure that returns a hashmap that contains the associations of both hashmap and alist. Associations in the hashmap and those earlier in the list take precedence over those that come later.
(scheme hashmap) procedure (hashmap=? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if each hashmap hashmap contains the same associations, and #f otherwise.
Furthermore, it is explicitly not an error if hashmap=? is invoked on hashmaps that do not share the same (key) comparator. In that case, #f is returned.
(scheme hashmap) procedure (hashmap<? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if the set of associations of each hashmap hashmap other than the last is a proper subset of the following hashmap, and #f otherwise.
(scheme hashmap) procedure (hashmap>? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if the set of associations of each hashmap hashmap other than the last is a proper superset of the following hashmap, and #f otherwise.
(scheme hashmap) procedure (hashmap<=? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if the set of associations of each hashmap hashmap other than the last is a subset of the following hashmap, and #f otherwise.
(scheme hashmap) procedure (hashmap>=? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if the set of associations of each hashmap hashmap other than the last is a superset of the following hashmap, and #f otherwise.
(scheme hashmap) procedure (hashmap-union (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-intersection (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-difference (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-xor (hashmap1 hashmap?) (hashmap2 hashmap?) ) ⟹ hashmap?
Return a newly allocated hashmap whose set of associations is the union, intersection, asymmetric difference, or symmetric difference of the sets of associations of the hashmaps hashmaps. Asymmetric difference is extended to more than two hashmaps by taking the difference between the first hashmap and the union of the others. Symmetric difference is not extended beyond two hashmaps. When comparing associations, only the keys are compared. In case of duplicate keys (in the sense of the hashmaps comparators), associations in the result hashmap are drawn from the first hashmap in which they appear.
(scheme hashmap) procedure (hashmap-union! (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-intersection! (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-difference! (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(scheme hashmap) procedure (hashmap-xor! (hashmap1 hashmap?) (hashmap2 hashmap?) ) ⟹ hashmap?
These procedures are the linear update analogs of the corresponding pure functional procedures above.
(scheme hashmap) procedure (comparator? obj ) ⟹ boolean?
Type predicate for comparators as exported by (srfi 128).
(scheme hashmap) procedure (make-hashmap-comparator (comparator comparator?) ) ⟹ comparator?
Returns a comparator for hashmaps that is compatible with the equality predicate (hashmap=? comparator hashmap1 hashmap2). It provides an implementation-dependent hash function. The existence of comparators returned by make-hashmap-comparator allows hashmaps whose keys are hashmaps themselves, and it allows to compare hashmaps whose values are hashmaps.
hashmap-comparator ⟹ comparator?
hashmap-comparator is constructed by invoking make-hashmap-comparator on (make-default-comparator).
library (scheme regex)
(scheme regex) procedure (regexp re ) ⟹ regexp?
Compiles a regexp if given an object whose structure matches the SRE syntax. This may be written as a literal or partial literal with quote or quasiquote, or may be generated entirely programmatically. Returns re unmodified if it is already a regexp. Raises an error if re is neither a regexp nor a valid representation of an SRE.
Mutating re may invalidate the resulting regexp, causing unspecified results if subsequently used for matching.
SRE syntax:
<sre> ::=
| <string> ; A literal string match.
| <cset-sre> ; A character set match.
| (* <sre> ...) ; 0 or more matches.
| (zero-or-more <sre> ...)
| (+ <sre> ...) ; 1 or more matches.
| (one-or-more <sre> ...)
| (? <sre> ...) ; 0 or 1 matches.
| (optional <sre> ...)
| (= <n> <sre> ...) ; <n> matches.
| (exactly <n> <sre> ...)
| (>= <n> <sre> ...) ; <n> or more matches.
| (at-least <n> <sre> ...)
| (** <n> <m> <sre> ...) ; <n> to <m> matches.
| (repeated <n> <m> <sre> ...)
| (| <sre> ...) ; Alternation.
| (or <sre> ...)
| (: <sre> ...) ; Sequence.
| (seq <sre> ...)
| ($ <sre> ...) ; Numbered submatch.
| (submatch <sre> ...)
| (-> <name> <sre> ...) ; Named submatch. <name> is
| (submatch-named <name> <sre> ...) ; a symbol.
| (w/case <sre> ...) ; Introduce a case-sensitive context.
| (w/nocase <sre> ...) ; Introduce a case-insensitive context.
| (w/unicode <sre> ...) ; Introduce a unicode context.
| (w/ascii <sre> ...) ; Introduce an ascii context.
| (w/nocapture <sre> ...) ; Ignore all enclosed submatches.
| bos ; Beginning of string.
| eos ; End of string.
| bol ; Beginning of line.
| eol ; End of line.
| bog ; Beginning of grapheme cluster.
| eog ; End of grapheme cluster.
| grapheme ; A single grapheme cluster.
| bow ; Beginning of word.
| eow ; End of word.
| nwb ; A non-word boundary.
| (word <sre> ...) ; An SRE wrapped in word boundaries.
| (word+ <cset-sre> ...) ; A single word restricted to a cset.
| word ; A single word.
| (?? <sre> ...) ; A non-greedy pattern, 0 or 1 match.
| (non-greedy-optional <sre> ...)
| (*? <sre> ...) ; Non-greedy 0 or more matches.
| (non-greedy-zero-or-more <sre> ...)
| (**? <m> <n> <sre> ...) ; Non-greedy <m> to <n> matches.
| (non-greedy-repeated <sre> ...)
| (look-ahead <sre> ...) ; Zero-width look-ahead assertion.
| (look-behind <sre> ...) ; Zero-width look-behind assertion.
| (neg-look-ahead <sre> ...) ; Zero-width negative look-ahead assertion.
| (neg-look-behind <sre> ...) ; Zero-width negative look-behind assertion.
| (backref <n-or-name>) ; Match a previous submatch.
The grammar for cset-sre is as follows.
<cset-sre> ::=
| <char> ; literal char
| "<char>" ; string of one char
| <char-set> ; embedded SRFI 14 char set
| (<string>) ; literal char set
| (char-set <string>)
| (/ <range-spec> ...) ; ranges
| (char-range <range-spec> ...)
| (or <cset-sre> ...) ; union
| (|\|| <cset-sre> ...)
| (and <cset-sre> ...) ; intersection
| (& <cset-sre> ...)
| (- <cset-sre> ...) ; difference
| (- <difference> ...)
| (~ <cset-sre> ...) ; complement of union
| (complement <cset-sre> ...)
| (w/case <cset-sre> ...) ; case and unicode toggling
| (w/nocase <cset-sre> ...)
| (w/ascii <cset-sre> ...)
| (w/unicode <cset-sre> ...)
| any | nonl | ascii | lower-case | lower
| upper-case | upper | title-case | title
| alphabetic | alpha | alphanumeric | alphanum | alnum
| numeric | num | punctuation | punct | symbol
| graphic | graph | whitespace | white | space
| printing | print | control | cntrl | hex-digit | xdigit
<range-spec> ::= <string> | <char>
(scheme regex) syntax (rx (* one-or-more ? optional = exactly at-least ** repeated | or : seq $ submatch -> sumatch-named w/case w/nocase w/unicode w/ascii w/nocapture bos eos bol eol bog eog grapheme bow eow nwb word word+ ?? non-greedy-optional *? non-greedy-zero-or-more **? non-greedy-repeated look-ahead look-behind neg-look-ahead neg-look-behind backref ) ((_ sre ...) regexp? ) )
string charset (* sre ...) (one-or-more sre ...) (? sre ...) (optional sre ...) (= n sre ...) (exactly n sre ...) (>= n sre ...) (at-least n sre ...) (** n m sre ...) (repeated n m sre ...) (|\|| sre ...) (or sre ...) (: sre ...) (seq sre ...) ($ sre ...) (submatch sre ...) (-> name sre ...) (submatch-named name sre ...) (w/case sre ...) (w/nocase sre ...) (w/unicode sre ...) (w/ascii sre ...) (w/nocapture sre ...) bos eos bol eol bog eog grapheme bow eow nwb (word sre ...) (word+ cset-sre ...) word (?? sre ...) (non-greedy-optional sre ...) (*? sre ...) (non-greedy-zero-or-more sre ...) (**? m n sre ...) (non-greedy-repeated sre ...) (look-ahead sre ...) (look-behind sre ...) (neg-look-ahead sre ...) (neg-look-behind sre ...) (backref n-or-name)
Macro shorthand for (regexp `(: sre ...)). May be able to perform some or all computation at compile time if sre is not unquoted. Note because of this equivalence with the procedural constructor regexp, the semantics of unquote differs from the original SCSH implementation in that unquoted expressions can expand into any object matching the SRE syntax, but not a compiled regexp object. Further, unquote and unquote-splicing both expand all matches.
(scheme regex) procedure (regexp->sre (re regexp?) ) ⟹ *
Returns an SRE corresponding to the given regexp re. The SRE will be equivalent to (will match the same strings) but not necessarily equal? to the SRE originally used to compile re. Mutating the result may invalidate re, causing unspecified results if subsequently used for matching.
(scheme regex) procedure (char-set->sre (char-set charset?) ) ⟹ *
Returns an SRE corresponding to the given SRFI 14 character set. The resulting SRE expands the character set into notation which does not make use of embedded SRFI 14 character sets, and so is suitable for writing portably.
(scheme regex) procedure (valid-sre? obj ) ⟹ boolean?
Returns true iff obj can be safely passed to regexp.
(scheme regex) procedure (regexp? obj ) ⟹ boolean?
Returns true iff obj is a regexp.
(scheme regex) procedure (regexp-matches re (str string?) ) ⟹ regexp-match? / #f /
(scheme regex) procedure (regexp-matches re (str string?) (start integer?) ) ⟹ regexp-match? / #f /
(scheme regex) procedure (regexp-matches re (str string?) (start integer?) (end integer?) ) ⟹ regexp-match? / #f /
Returns an regexp-match object if re successfully matches the entire string str from start (inclusive) to end (exclusive), or #f is the match fails. The regexp-match object will contain information needed to extract any submatches.
(scheme regex) procedure (regexp-matches? re (str string?) ) ⟹ boolean?
(scheme regex) procedure (regexp-matches? re (str string?) (start integer?) ) ⟹ boolean?
(scheme regex) procedure (regexp-matches? re (str string?) (start integer?) (end integer?) ) ⟹ boolean?
Returns #t if re matches str as in regexp-matches, or #f otherwise. May be faster than regexp-matches since it doesn't need to return submatch data.
(scheme regex) procedure (regexp-search re (str string?) ) ⟹ regexp-match? / #f /
(scheme regex) procedure (regexp-search re (str string?) (start integer?) ) ⟹ regexp-match? / #f /
(scheme regex) procedure (regexp-search re (str string?) (start integer?) (end integer?) ) ⟹ regexp-match? / #f /
Returns a regexp-match object if re successfully matches a substring of str between start (inclusive) and end (exclusive), or #f if the match fails. The regexp-match object will contain information needed to extract any submatches.
(scheme regex) procedure (regexp-fold re (kons procedure?) knil (str string?) ) ⟹ *
(scheme regex) procedure (regexp-fold re (kons procedure?) knil (str string?) (finish procedure?) ) ⟹ *
(scheme regex) procedure (regexp-fold re (kons procedure?) knil (str string?) (finish procedure?) (start integer?) ) ⟹ *
(scheme regex) procedure (regexp-fold re (kons procedure?) knil (str string?) (finish procedure?) (start integer?) (end integer?) ) ⟹ *
(kons (i integer?) (match regexp-match?) (str string?) acc ) ⟹ *
(finish (i integer?) (match #f) (str string?) acc ) ⟹ *
The fundamental regexp matching iterator. Repeatedly searches str for the regexp re so long as a match can be found. On each successful match, applies (kons i regexp-match str acc) where i is the index since the last match (beginning with start), regexp-match is the resulting match, and acc is the result of the previous kons application, beginning with knil. When no more matches can be found, calls finish with the same arguments, except that regexp-match is #f.
By default finish just returns acc.
(scheme regex) procedure (regexp-extract re (str string?) ) ⟹ list?
(scheme regex) procedure (regexp-extract re (str string?) (start integer?) ) ⟹ list?
(scheme regex) procedure (regexp-extract re (str string?) (start integer?) (end integer?) ) ⟹ list?
Extracts all non-empty substrings of str which match re between start and end as a list of strings.
(scheme regex) procedure (regexp-split re (str string?) ) ⟹ list?
(scheme regex) procedure (regexp-split re (str string?) (start integer?) ) ⟹ list?
(scheme regex) procedure (regexp-split re (str string?) (start integer?) (end integer?) ) ⟹ list?
Splits str into a list of (possibly empty) strings separated by non-empty matches of re.
(scheme regex) procedure (regexp-partition re (str string?) ) ⟹ list?
(scheme regex) procedure (regexp-partition re (str string?) (start integer?) ) ⟹ list?
(scheme regex) procedure (regexp-partition re (str string?) (start integer?) (end integer?) ) ⟹ list?
Partitions str into a list of non-empty strings matching re, interspersed with the unmatched portions of the string. The first and every odd element is an unmatched substring, which will be the empty string if re matches at the beginning of the string or end of the previous match. The second and every even element will be a substring matching re. If the final match ends at the end of the string, no trailing empty string will be included. Thus, in the degenerate case where str is the empty string, the result is ("").
Note that regexp-partition is equivalent to interleaving the results of regexp-split and regexp-extract, starting with the former.
(scheme regex) procedure (regexp-replace re (str string?) (subst (or string?integer?symbol?)) ) ⟹ string?
(scheme regex) procedure (regexp-replace re (str string?) (subst (or string?integer?symbol?)) (start integer?) ) ⟹ string?
(scheme regex) procedure (regexp-replace re (str string?) (subst (or string?integer?symbol?)) (start integer?) (end integer?) ) ⟹ string?
(scheme regex) procedure (regexp-replace re (str string?) (subst (or string?integer?symbol?)) (start integer?) (end integer?) (count integer?) ) ⟹ string?
Returns a new string replacing the countth match of re in str the subst, where the zero-indexed count defaults to zero (i.e. the first match). If there are not count matches, returns the selected substring unmodified.
subst can be a string, an integer or symbol indicating the contents of a numbered or named submatch of re, 'pre for the substring to the left of the match, or 'post for the substring to the right of the match.
The optional parameters start and end restrict both the matching and the substitution, to the given indices, such that the result is equivalent to omitting these parameters and replacing on (substring str start end). As a convenience, a value of #f for end is equivalent to (string-length str).
(scheme regex) procedure (regexp-replace-all re (str string?) (subst (or string?integer?symbol?)) (start integer?) ) ⟹ string?
(scheme regex) procedure (regexp-replace-all re (str string?) (subst (or string?integer?symbol?)) (start integer?) (end integer?) ) ⟹ string?
Equivalent to regexp-replace, but replaces all occurrences of re in str.
(scheme regex) procedure (regexp-match? obj ) ⟹ boolean?
Returns true iff obj is a successful match from regexp-matches or regexp-search.
(scheme regex) procedure (regexp-match-count (obj regexp-match?) ) ⟹ integer?
Returns the number of submatches of regexp-match, regardless of whether they matched or not. Does not include the implicit zero full match in the count.
(scheme regex) procedure (regexp-match-submatch (obj regexp-match?) (field (or integer?symbol?)) ) ⟹ string? / #f /
Returns the substring matched in regexp-match corresponding to field, either an integer or a symbol for a named submatch. Index 0 refers to the entire match, index 1 to the first lexicographic submatch, and so on. If there are multiple submatches with the same name, the first which matched is returned. If passed an integer outside the range of matches, or a symbol which does not correspond to a named submatch of the pattern, it is an error. If the corresponding submatch did not match, returns false.
The result of extracting a submatch after the original matched string has been mutated is unspecified.
(scheme regex) procedure (regexp-match-submatch-start (obj regexp-match?) (field (or integer?symbol?)) ) ⟹ integer? / #f /
Returns the start index regexp-match corresponding to field, as in regexp-match-submatch.
(scheme regex) procedure (regexp-match-submatch-end (obj regexp-match?) (field (or integer?symbol?)) ) ⟹ integer? / #f /
Returns the end index in regexp-match corresponding to field, as in regexp-match-submatch.
(scheme regex) procedure (regexp-match->list (obj regexp-match?) ) ⟹ list?
Returns a list of all submatches in regexp-match as string or false, beginning with the entire match 0.
library (scheme show)
(scheme show) procedure (show (port #f) (fmt formatter) ... ) ⟹ string?
(scheme show) procedure (show (port (or output-port?boolean?)) (fmt formatter) ... ) ⟹ undefined
The entry point for all formatting. Applies the fmt formatters in sequence, accumulating the output to output-dest. As with SRFI 28 format, output-dest can be an output port, #t to indicate the current output port, or #f to accumulate the output into a string and return that as the result of show.
(scheme show) procedure (displayed obj ) ⟹ formatter
If obj is a formatter, returns obj as is. Otherwise, outputs obj using display semantics. Specifically, strings are output as if by write-string and characters are written as if by write-char. Other objects are output as with written (including nested strings and chars inside obj). This is the default behavior for top-level formats in show, each and most other high-level formatters.
(scheme show) procedure (written obj ) ⟹ formatter
Outputs obj using write semantics. Uses the current numeric formatting settings to the extent that the written result can still be passed to read, possibly with loss of precision. Specifically, the current radix is used if set to any of 2, 8, 10 or 16, and the fixed point precision is used if specified and the radix is 10.
(scheme show) procedure (written-simply obj ) ⟹ formatter
Same as "written", but doesn't handle shared structures. Infinite loops can still be avoided if used inside a formatter that truncates data (see trimmed and fitted below).
(scheme show) procedure (pretty obj ) ⟹ formatter
Pretty-prints obj. The result should be identical to written except possibly for differences in whitespace to make the output resemble formatted source code. Implementations should print vectors and data lists (lists that don't begin with a (nested) symbol) in a tabular format when possible to reduce vertical space.
(scheme show) procedure (pretty-simply obj ) ⟹ formatter
Same as "pretty", but doesn't handle shared structures. Infinite loops can still be avoided if used inside a formatter that truncates data (see trimmed and fitted below).
(scheme show) procedure (escaped (str string?) ) ⟹ formatter
(scheme show) procedure (escaped (str string?) (quote-ch char?) ) ⟹ formatter
(scheme show) procedure (escaped (str string?) (quote-ch char?) (esc-ch char?) ) ⟹ formatter
(scheme show) procedure (escaped (str string?) (quote-ch char?) (esc-ch char?) (renamer procedure?) ) ⟹ formatter
(renamer (c char?) ) ⟹ char?
Outputs the string str, escaping any quote or escape characters. If esc-ch, which defaults to #\\, is #f, escapes only the quote-ch, which defaults to #\", by doubling it, as in SQL strings and CSV values. If renamer is provided, it should be a procedure of one character which maps that character to its escape value, e.g. #\newline => #\n, or #f if there is no escape value.
(scheme show) procedure (maybe-escaped (str string?) (pred procedure?) ) ⟹ formatter
(scheme show) procedure (maybe-escaped (str string?) (pred procedure?) (quote-ch char?) ) ⟹ formatter
(scheme show) procedure (maybe-escaped (str string?) (pred procedure?) (quote-ch char?) (esc-ch char?) ) ⟹ formatter
(scheme show) procedure (maybe-escaped (str string?) (pred procedure?) (quote-ch char?) (esc-ch char?) (renamer procedure?) ) ⟹ formatter
(pred (c char?) ) ⟹ boolean?
(renamer (c char?) ) ⟹ char?
Like escaped, but first checks if any quoting is required (by the existence of either any quote or escape characters, or any character matching pred), and if so outputs the string in quotes and with escapes. Otherwise outputs the string as is. This is useful for quoting symbols and CSV output, etc.
(scheme show) procedure (numeric (num number?) ) ⟹ formatter
(scheme show) procedure (numeric (num number?) (radix integer?) ) ⟹ formatter
(scheme show) procedure (numeric (num number?) (radix integer?) (precision integer?) ) ⟹ formatter
(scheme show) procedure (numeric (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) ) ⟹ formatter
(scheme show) procedure (numeric (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) ) ⟹ formatter
(scheme show) procedure (numeric (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) (comma-sep char?) ) ⟹ formatter
(scheme show) procedure (numeric (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) (comma-sep char?) (decimal-sep char?) ) ⟹ formatter
Formats a single number num. You can optionally specify any radix from 2 to 36 (even if num isn't an integer). precision forces a fixed-point format.
A sign of #t indicates to output a plus sign (+) for positive integers. However, if sign is a pair of two strings, it means to wrap negative numbers with the two strings. For example, ("(" . ")") prints negative numbers in parentheses, financial style: -1.99 => (1.99).
comma is an integer specifying the number of digits between commas.
comma-sep is the character to use for commas, defaulting to #\,.
decimal-sep is the character to use for decimals, defaulting to #\., or to #\, (European style) if comma-sep is already #\..
These parameters may seem unwieldy, but they can also take their defaults from state variables
(scheme show) procedure (numeric/comma (num number?) ) ⟹ formatter
(scheme show) procedure (numeric/comma (num number?) (radix integer?) ) ⟹ formatter
(scheme show) procedure (numeric/comma (num number?) (radix integer?) (precision integer?) ) ⟹ formatter
(scheme show) procedure (numeric/comma (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) ) ⟹ formatter
Shortcut for numeric to print with commas.
(scheme show) procedure (numeric/si (num number?) ) ⟹ formatter
(scheme show) procedure (numeric/si (num number?) (base integer?) ) ⟹ formatter
(scheme show) procedure (numeric/si (num number?) (base integer?) (separator string?) ) ⟹ formatter
Abbreviates num with an SI suffix as in the -h or --si option to many GNU commands. The base defaults to 1024, using suffix names like Ki, Mi, Gi, etc. Other bases (e.g. the standard 1000) have the suffixes k, M, G, etc. If separator is provided, it is inserted after the number, before any suffix.
(scheme show) procedure (numeric/fitted (num number?) ) ⟹ formatter
(scheme show) procedure (numeric/fitted (num number?) (radix integer?) ) ⟹ formatter
(scheme show) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) ) ⟹ formatter
(scheme show) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) ) ⟹ formatter
(scheme show) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) ) ⟹ formatter
(scheme show) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) (comma-sep char?) ) ⟹ formatter
(scheme show) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) (comma-sep char?) (decimal-sep char?) ) ⟹ formatter
Like numeric, but if the result doesn't fit in width using the current precision, output instead a string of hashes rather than showing an incorrectly truncated number.
nl ⟹ formatter
Outputs a newline.
fl ⟹ formatter
Short for "fresh line," outputs a newline only if we're not already at the start of a line.
(scheme show) procedure (space-to (column integer?) ) ⟹ formatter
Outputs spaces up to the given column. If the current column is already >= column, does nothing. The character used for spacing is the current value of pad-char, described below, which defaults to space. Columns are zero-based.
(scheme show) procedure (tab-to ) ⟹ formatter
(scheme show) procedure (tab-to (tab-width integer?) ) ⟹ formatter
Outputs spaces up to the next tab stop, using tab stops of width tab-width, which defaults to 8. If already on a tab stop, does nothing. If you want to ensure you always tab at least one space, you can use (each " " (tab-to width)). Columns are zero-based.
nothing ⟹ formatter
Outputs nothing (useful in combinators and as a default noop in conditionals).
(scheme show) procedure (each (fmt formatter) ... ) ⟹ formatter
Applies each fmt in sequence, as in the top-level of show.
(scheme show) procedure (each-in-list (list-of-fmts list?) ) ⟹ formatter
Equivalent to (apply each list-of-fmts) but may be more efficient.
(scheme show) procedure (joined (mapper procedure?) (list list?) ) ⟹ formatter
(scheme show) procedure (joined (mapper procedure?) (list list?) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
Formats each element elt of list with (mapper elt), inserting sep in between. sep defaults to the empty string, but can be any format or string.
(scheme show) procedure (joined/prefix (mapper procedure?) (list list?) ) ⟹ formatter
(scheme show) procedure (joined/prefix (mapper procedure?) (list list?) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
As joined, but inserts sep before every element.
(scheme show) procedure (joined/suffix (mapper procedure?) (list list?) ) ⟹ formatter
(scheme show) procedure (joined/suffix (mapper procedure?) (list list?) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
As joined, but inserts sep after every element.
(scheme show) procedure (joined/last (mapper procedure?) (last-mapper procedure?) (list list?) ) ⟹ formatter
(scheme show) procedure (joined/last (mapper procedure?) (last-mapper procedure?) (list list?) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
(last-mapper element ) ⟹ formatter
As joined, but the last element of the list is formatted with last-mapper instead.
(scheme show) procedure (joined/dot (mapper procedure?) (dot-mapper procedure?) (list (or list?dotted-list?)) ) ⟹ formatter
(scheme show) procedure (joined/dot (mapper procedure?) (dot-mapper procedure?) (list (or list?dotted-list?)) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
(dot-mapper tail ) ⟹ formatter
As joined, but if the list is a dotted list, then formats the dotted value with dot-mapper instead.
(scheme show) procedure (joined/range (mapper procedure?) (start integer?) ) ⟹ formatter
(scheme show) procedure (joined/range (mapper procedure?) (start integer?) (end (or integer?#f)) ) ⟹ formatter
(scheme show) procedure (joined/range (mapper procedure?) (start integer?) (end (or integer?#f)) (separator (or string?formatter)) ) ⟹ formatter
(mapper (value integer?) ) ⟹ formatter
As joined, but counts from start (inclusive) to end (exclusive), formatting each integer in the range with mapper. If end is #f or unspecified, produces an infinite stream of output.
(scheme show) procedure (padded (width integer?) (fmt formatter) ... ) ⟹ formatter
Add extra space to the left side of the output generated by the fmts to pad it to width.
(scheme show) procedure (padded/right (width integer?) (fmt formatter) ... ) ⟹ formatter
Add extra space to the right side of the output generated by the fmts to pad it to width.
(scheme show) procedure (padded/both (width integer?) (fmt formatter) ... ) ⟹ formatter
Add extra space to the both sides of the output generated by the fmts to pad it to width.
(scheme show) procedure (trimmed (width integer?) (fmt formatter) ... ) ⟹ formatter
Truncates the output of the fmts to force it in under width columns. As soon as any of the fmts exceeds width, stop formatting and truncate the result, returning control to whoever called trimmed. If a truncation ellipsis is set, then when any truncation occurs trimmed will prepend the ellipsis.
(scheme show) procedure (trimmed/right (width integer?) (fmt formatter) ... ) ⟹ formatter
Truncates the output of the fmts to force it in under width columns. As soon as any of the fmts exceeds width, stop formatting and truncate the result, returning control to whoever called trimmed. If a truncation ellipsis is set, then when any truncation occurs trimmed/right will append the ellipsis.
(scheme show) procedure (trimmed/both (width integer?) (fmt formatter) ... ) ⟹ formatter
Truncates the output of the fmts to force it in under width columns. As soon as any of the fmts exceeds width, stop formatting and truncate the result, returning control to whoever called trimmed. If a truncation ellipsis is set, then when any truncation occurs trimmed/bith will both prepend and append the ellipsis.
(scheme show) procedure (trimmed/lazy (width integer?) (fmt formatter) ... ) ⟹ formatter
A variant of trimmed which generates each fmt in left to right order, and truncates and terminates immediately if more than width characters are generated. Thus this is safe to use with an infinite amount of output, e.g. from written-simply on an infinite list.
(scheme show) procedure (fitted (width integer?) (fmt formatter) ... ) ⟹ formatter
A combination of padded and trimmed that ensures that the output width is exactly width, truncating if it goes over and padding if it goes under.
(scheme show) procedure (fitted/right (width integer?) (fmt formatter) ... ) ⟹ formatter
A combination of padded and trimmed that ensures that the output width is exactly width, truncating if it goes over and padding if it goes under.
(scheme show) procedure (fitted/both (width integer?) (fmt formatter) ... ) ⟹ formatter
A combination of padded and trimmed that ensures that the output width is exactly width, truncating if it goes over and padding if it goes under.
(scheme show) procedure (columnar (column (or formatterstring?symbol?number?)) ... ) ⟹ formatter
Formats each column side-by-side, i.e. as though each were formatted separately and then the individual lines concatenated together. The current line width (from the width state variable) is divided evenly among the columns, and all but the last column are right-padded.
You may also prefix any column with any of the symbols 'left, 'right or 'center to control the justification. The symbol 'infinite can be used to indicate the column generates an infinite stream of output.
You can further prefix any column with a width modifier. Any positive integer is treated as a fixed width, ignoring the available width. Any real number between 0 and 1 indicates a fraction of the available width (after subtracting out any fixed widths). Columns with unspecified width divide up the remaining width evenly. If the extra space does not divide evenly, it is allocated column-wise left to right, e.g. if the width of 78 is divided among 5 columns, the column widths become 16, 16, 16, 15, 15 in order.
Note that columnar builds its output incrementally, interleaving calls to the generators until each has produced a line, then concatenating that line together and outputting it. This is important because as noted above, some columns may produce an infinite stream of output, and in general you may want to format data larger than can fit into memory. Thus columnar would be suitable for line numbering a file of arbitrary size, or implementing the Unix yes(1) command, etc.
(scheme show) procedure (tabular (column (or formatterstring?symbol?number?)) ... ) ⟹ formatter
Equivalent to columnar except that each column is padded at least to the minimum width required on any of its lines.
This makes it easier to generate tables without knowing widths in advance. However, because it requires generating the entire output in advance to determine the correct column widths, tabular cannot format a table larger than would fit in memory.
(scheme show) procedure (wrapped (fmt formatter) ... ) ⟹ formatter
Behaves like each, except text is accumulated and lines are wrapped to fit in the current width as in the Unix fmt(1) command. Specifically, words are tokenized by splitting on all characters which satisfy the predicate in the parameter word-separator?, which defaults to char-whitespace?. Words are grouped into lines separating them by space, and line breaks are introduced to minimize the sum of the cube of trailing whitespace on every line.
(scheme show) procedure (wrapped/list (list-of-strings list?) ... ) ⟹ formatter
Like wrapped, but taking a pre-tokenized list of strings.
(scheme show) procedure (wrapped/char (fmt formatter) ... ) ⟹ formatter
As wrapped, but splits simply on individual characters exactly as the current width is reached on each line. Thus there is nothing to optimize and this formatter doesn't buffer output.
(scheme show) procedure (justified (fmt formatter) ... ) ⟹ formatter
Like wrapped except the lines are full-justified.
(scheme show) procedure (from-file (pathname string?) ) ⟹ formatter
Displays the contents of the file pathname one line at a time, so that in typical formatters such as columnar only constant memory is consumed, making this suitable for formatting files of arbitrary size.
(scheme show) procedure (line-numbers ) ⟹ formatter
(scheme show) procedure (line-numbers (start integer?) ) ⟹ formatter
A convenience utility, just formats an infinite stream of numbers (in the current radix) beginning with start, which defaults to 1.
(scheme show) procedure (as-red (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-blue (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-green (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-cyan (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-yellow (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-magenta (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-white (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-black (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-bold (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-underline (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(scheme show) procedure (as-unicode (fmt formatter) ... ) ⟹ formatter
Padding, trimming and tabbing, etc. will generally not do the right thing in the presence of zero-width and double-width Unicode characters. This formatter overrides the string-width state var used in column tracking to do the right thing in such cases, considering Unicode double or full width characters as 2 characters wide (as they typically are in fixed-width terminals), while treating combining and non-spacing characters as 0 characters wide.
(scheme show) procedure (unicode-terminal-width (str string?) ) ⟹ integer?
A utility function which returns the integer number of columns str would require in a terminal
(scheme show) syntax (fn () ((_ (binding ...) expr ... fmt) formatter ) )
(id state-var) id
state-var ⟹ formatter-variable
Short for "function," this is the analog to lambda. Returns a formatter which on application evaluates each expr and fmt in left-to-right order, in a lexical environment extended with each identifier id bound to the current value of the state variable named by the symbol state-var. The result of the fmt is then applied as a formatter.
(scheme show) syntax (with () ((_ ((state-var value) ...) fmt ...)) )
state-var ⟹ formatter-variable
Conceptually the formatting equivalent of parameterize, temporarily altering state variables. Applies each of the formatters fmt with each state-var bound to the corresponding value. The resulting state is then updated to restore each state-var to its original value.
(scheme show) syntax (with! () ((_ (state-var value) ...)) )
state-var ⟹ formatter-variable
Similar to with but does not restore the original values, changing the value of each state-var for any remaining formatters in a sequence.
(scheme show) procedure (forked (fmt1 formatter) (fmt2 formatter) ) ⟹ formatter
Calls fmt1 on (a conceptual copy of) the current state, then fmt2 on the same original state as though fmt1 had not been called.
(scheme show) procedure (call-with-output (fmt formatter) (mapper procedure?) ) ⟹ formatter
(mapper (result-string string?) ) ⟹ formatter
A utility, calls formatter on a copy of the current state (as with forked), accumulating the results into a string. Then calls the formatter resulting from (mapper result-string) on the original state.
port ⟹ formatter-variable
The textual port output is written to, this can be overridden to capture intermediate output.
row ⟹ formatter-variable
The current row of output.
col ⟹ formatter-variable
The current column of output, used for padding and spacing, etc.
width ⟹ formatter-variable
The current line width, used for wrapping, pretty-printing, and columnar formatting. The default is implementation-defined.
output ⟹ formatter-variable
The underlying standard formatter for writing a single string. The default value outputs the string while tracking the current row and col. This can be overridden both to capture intermediate output and perform transformations on strings before outputting, but should generally wrap the existing output to preserve expected behavior.
writer ⟹ formatter-variable
The mapper for automatic formatting of non-string/char values in top-level show, each and other formatters. Default value is implementation-defined.
string-width ⟹ formatter-variable
A function of a single string, it returns the length in columns of that string, used by the default output.
pad-char ⟹ formatter-variable
The character used by space-to, tab-to and other padding formatters.
ellipsis ⟹ formatter-variable
The string used when truncating as described in trimmed.
radix ⟹ formatter-variable
The radix for numeric output, defaulting to 10, as used in numeric and written.
precision ⟹ formatter-variable
The precision for numeric output, as described in numeric and written. The precision specifies the number of digits written after the decimal point. If the numeric value to be written out requires more digits to represent it than precision, the written representation is chosen which is closest to the numeric value and representable with the specified precision. If the numeric value falls on the midpoint of two such representations, it is implementation dependent which representation is chosen.
When the numeric value is an inexact floating-point number, there is more than one interpretation of this "rounding". One is to take the effective value the floating-point number represents (e.g. if we use binary floating-point numbers, we take the value of (* sign mantissa (expt 2 exponent))), and compare it to the two closest numeric representations of the given precision. Another way is to obtain the default notation of the floating-point number and apply rounding to it. The former (we call it effective rounding) is consistent with most floating-point number operations, but may lead to a more non-intuitive result than the latter (we call it notational rounding). For example, 5.015 can't be represented exactly in binary floating-point numbers. With IEEE754 floating-point numbers, the floating point number closest to 5.015 is smaller than exact 5.015, i.e. (< 5.015 5015/1000) => #t. With effective rounding with precision 2, it should result in "5.01". However, users who look at the notation may be confused by "5.015" not being rounded up as they usually expect. With notational rounding the implementation chooses "5.02" (if it also adopts round-half-to-infinity or round-half-up rule). It is up to the implementation to choose which interpretation to adopt.
decimal-sep ⟹ formatter-variable
The decimal separator for floating point output, default ".".
decimal-align ⟹ formatter-variable
Specifies an alignment for the decimal place when formatting numbers, and is useful for outputting tables of numbers.
word-separator? ⟹ formatter-variable
A character predicate used to tokenize words for wrapped and justify. Defaults to char-whitespace?. More flexibility is available with wrapped/list.
library (scheme vector base)
(scheme vector base) procedure (make-u8vector (size integer?) ) ⟹ u8vector?
(scheme vector base) procedure (make-u8vector (size integer?) (fill u8?) ) ⟹ u8vector?
Returns a u8vector whose length is size. If fill is provided, all the elements of the u8vector are initialized to it.
(scheme vector base) procedure (u8vector (value u8?) ... ) ⟹ u8vector?
Returns a u8vector initialized with values.
(scheme vector base) procedure (u8vector? obj ) ⟹ boolean?
Returns #t if obj is a u8vector, and #f otherwise.
(scheme vector base) procedure (u8vector-length (u8vec u8vector?) ) ⟹ integer?
Returns the length of u8vec
(scheme vector base) procedure (u8vector-ref (u8vec u8vector?) (i integer?) ) ⟹ u8?
Returns the ith element of u8vec.
(scheme vector base) procedure (u8vector-set! (u8vec u8vector?) (i integer?) (value u8?) ) ⟹ undefined
Sets the ith element of u8vec to value.
(scheme vector base) procedure (u8vector->list (u8vec u8vector?) ) ⟹ list?
(scheme vector base) procedure (u8vector->list (u8vec u8vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (u8vector->list (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u8vec
(scheme vector base) procedure (list->u8vector (proper-list list?) ) ⟹ u8vector?
proper-list ⟹ (list u8? )
Returns u8vector with same elements as list.
(scheme vector base) procedure (u8? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u8vector (ie., unsigned exact integer in the range 0 to (2^8)-1), and #f otherwise.
(scheme vector base) procedure (make-s8vector (size integer?) ) ⟹ s8vector?
(scheme vector base) procedure (make-s8vector (size integer?) (fill s8?) ) ⟹ s8vector?
Returns a s8vector whose length is size. If fill is provided, all the elements of the s8vector are initialized to it.
(scheme vector base) procedure (s8vector (value s8?) ... ) ⟹ s8vector?
Returns a s8vector initialized with values.
(scheme vector base) procedure (s8vector? obj ) ⟹ boolean?
Returns #t if obj is a s8vector, and #f otherwise.
(scheme vector base) procedure (s8vector-length (s8vec s8vector?) ) ⟹ integer?
Returns the length of s8vec
(scheme vector base) procedure (s8vector-ref (s8vec s8vector?) (i integer?) ) ⟹ s8?
Returns the ith element of s8vec.
(scheme vector base) procedure (s8vector-set! (s8vec s8vector?) (i integer?) (value s8?) ) ⟹ undefined
Sets the ith element of s8vec to value.
(scheme vector base) procedure (s8vector->list (s8vec s8vector?) ) ⟹ list?
(scheme vector base) procedure (s8vector->list (s8vec s8vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (s8vector->list (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s8vec
(scheme vector base) procedure (list->s8vector (proper-list list?) ) ⟹ s8vector?
proper-list ⟹ (list s8? )
Returns s8vector with same elements as list.
(scheme vector base) procedure (s8? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s8vector (ie., signed exact integer in the range -(2^7) to (2^7)-1), and #f otherwise.
(scheme vector base) procedure (make-u16vector (size integer?) ) ⟹ u16vector?
(scheme vector base) procedure (make-u16vector (size integer?) (fill u16?) ) ⟹ u16vector?
Returns a u16vector whose length is size. If fill is provided, all the elements of the u16vector are initialized to it.
(scheme vector base) procedure (u16vector (value u16?) ... ) ⟹ u16vector?
Returns a u16vector initialized with values.
(scheme vector base) procedure (u16vector? obj ) ⟹ boolean?
Returns #t if obj is a u16vector, and #f otherwise.
(scheme vector base) procedure (u16vector-length (u16vec u16vector?) ) ⟹ integer?
Returns the length of u16vec
(scheme vector base) procedure (u16vector-ref (u16vec u16vector?) (i integer?) ) ⟹ u16?
Returns the ith element of u16vec.
(scheme vector base) procedure (u16vector-set! (u16vec u16vector?) (i integer?) (value u16?) ) ⟹ undefined
Sets the ith element of u16vec to value.
(scheme vector base) procedure (u16vector->list (u16vec u16vector?) ) ⟹ list?
(scheme vector base) procedure (u16vector->list (u16vec u16vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (u16vector->list (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u16vec
(scheme vector base) procedure (list->u16vector (proper-list list?) ) ⟹ u16vector?
proper-list ⟹ (list u16? )
Returns u16vector with same elements as list.
(scheme vector base) procedure (u16? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u16vector (ie., unsigned exact integer in the range 0 to (2^16)-1), and #f otherwise.
(scheme vector base) procedure (make-s16vector (size integer?) ) ⟹ s16vector?
(scheme vector base) procedure (make-s16vector (size integer?) (fill s16?) ) ⟹ s16vector?
Returns a s16vector whose length is size. If fill is provided, all the elements of the s16vector are initialized to it.
(scheme vector base) procedure (s16vector (value s16?) ... ) ⟹ s16vector?
Returns a s16vector initialized with values.
(scheme vector base) procedure (s16vector? obj ) ⟹ boolean?
Returns #t if obj is a s16vector, and #f otherwise.
(scheme vector base) procedure (s16vector-length (s16vec s16vector?) ) ⟹ integer?
Returns the length of s16vec
(scheme vector base) procedure (s16vector-ref (s16vec s16vector?) (i integer?) ) ⟹ s16?
Returns the ith element of s16vec.
(scheme vector base) procedure (s16vector-set! (s16vec s16vector?) (i integer?) (value s16?) ) ⟹ undefined
Sets the ith element of s16vec to value.
(scheme vector base) procedure (s16vector->list (s16vec s16vector?) ) ⟹ list?
(scheme vector base) procedure (s16vector->list (s16vec s16vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (s16vector->list (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s16vec
(scheme vector base) procedure (list->s16vector (proper-list list?) ) ⟹ s16vector?
proper-list ⟹ (list s16? )
Returns s16vector with same elements as list.
(scheme vector base) procedure (s16? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s16vector (ie., signed exact integer in the range -(2^15) to (2^15)-1), and #f otherwise.
(scheme vector base) procedure (make-u32vector (size integer?) ) ⟹ u32vector?
(scheme vector base) procedure (make-u32vector (size integer?) (fill u32?) ) ⟹ u32vector?
Returns a u32vector whose length is size. If fill is provided, all the elements of the u32vector are initialized to it.
(scheme vector base) procedure (u32vector (value u32?) ... ) ⟹ u32vector?
Returns a u32vector initialized with values.
(scheme vector base) procedure (u32vector? obj ) ⟹ boolean?
Returns #t if obj is a u32vector, and #f otherwise.
(scheme vector base) procedure (u32vector-length (u32vec u32vector?) ) ⟹ integer?
Returns the length of u32vec
(scheme vector base) procedure (u32vector-ref (u32vec u32vector?) (i integer?) ) ⟹ u32?
Returns the ith element of u32vec.
(scheme vector base) procedure (u32vector-set! (u32vec u32vector?) (i integer?) (value u32?) ) ⟹ undefined
Sets the ith element of u32vec to value.
(scheme vector base) procedure (u32vector->list (u32vec u32vector?) ) ⟹ list?
(scheme vector base) procedure (u32vector->list (u32vec u32vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (u32vector->list (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u32vec
(scheme vector base) procedure (list->u32vector (proper-list list?) ) ⟹ u32vector?
proper-list ⟹ (list u32? )
Returns u32vector with same elements as list.
(scheme vector base) procedure (u32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u32vector (ie., unsigned exact integer in the range 0 to (2^32)-1), and #f otherwise.
(scheme vector base) procedure (make-s32vector (size integer?) ) ⟹ s32vector?
(scheme vector base) procedure (make-s32vector (size integer?) (fill s32?) ) ⟹ s32vector?
Returns a s32vector whose length is size. If fill is provided, all the elements of the s32vector are initialized to it.
(scheme vector base) procedure (s32vector (value s32?) ... ) ⟹ s32vector?
Returns a s32vector initialized with values.
(scheme vector base) procedure (s32vector? obj ) ⟹ boolean?
Returns #t if obj is a s32vector, and #f otherwise.
(scheme vector base) procedure (s32vector-length (s32vec s32vector?) ) ⟹ integer?
Returns the length of s32vec
(scheme vector base) procedure (s32vector-ref (s32vec s32vector?) (i integer?) ) ⟹ s32?
Returns the ith element of s32vec.
(scheme vector base) procedure (s32vector-set! (s32vec s32vector?) (i integer?) (value s32?) ) ⟹ undefined
Sets the ith element of s32vec to value.
(scheme vector base) procedure (s32vector->list (s32vec s32vector?) ) ⟹ list?
(scheme vector base) procedure (s32vector->list (s32vec s32vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (s32vector->list (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s32vec
(scheme vector base) procedure (list->s32vector (proper-list list?) ) ⟹ s32vector?
proper-list ⟹ (list s32? )
Returns s32vector with same elements as list.
(scheme vector base) procedure (s32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s32vector (ie., signed exact integer in the range -(2^31) to (2^31)-1), and #f otherwise.
(scheme vector base) procedure (make-u64vector (size integer?) ) ⟹ u64vector?
(scheme vector base) procedure (make-u64vector (size integer?) (fill u64?) ) ⟹ u64vector?
Returns a u64vector whose length is size. If fill is provided, all the elements of the u64vector are initialized to it.
(scheme vector base) procedure (u64vector (value u64?) ... ) ⟹ u64vector?
Returns a u64vector initialized with values.
(scheme vector base) procedure (u64vector? obj ) ⟹ boolean?
Returns #t if obj is a u64vector, and #f otherwise.
(scheme vector base) procedure (u64vector-length (u64vec u64vector?) ) ⟹ integer?
Returns the length of u64vec
(scheme vector base) procedure (u64vector-ref (u64vec u64vector?) (i integer?) ) ⟹ u64?
Returns the ith element of u64vec.
(scheme vector base) procedure (u64vector-set! (u64vec u64vector?) (i integer?) (value u64?) ) ⟹ undefined
Sets the ith element of u64vec to value.
(scheme vector base) procedure (u64vector->list (u64vec u64vector?) ) ⟹ list?
(scheme vector base) procedure (u64vector->list (u64vec u64vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (u64vector->list (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u64vec
(scheme vector base) procedure (list->u64vector (proper-list list?) ) ⟹ u64vector?
proper-list ⟹ (list u64? )
Returns u64vector with same elements as list.
(scheme vector base) procedure (u64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u64vector (ie., unsigned exact integer in the range 0 to (2^64)-1), and #f otherwise.
(scheme vector base) procedure (make-s64vector (size integer?) ) ⟹ s64vector?
(scheme vector base) procedure (make-s64vector (size integer?) (fill s64?) ) ⟹ s64vector?
Returns a s64vector whose length is size. If fill is provided, all the elements of the s64vector are initialized to it.
(scheme vector base) procedure (s64vector (value s64?) ... ) ⟹ s64vector?
Returns a s64vector initialized with values.
(scheme vector base) procedure (s64vector? obj ) ⟹ boolean?
Returns #t if obj is a s64vector, and #f otherwise.
(scheme vector base) procedure (s64vector-length (s64vec s64vector?) ) ⟹ integer?
Returns the length of s64vec
(scheme vector base) procedure (s64vector-ref (s64vec s64vector?) (i integer?) ) ⟹ s64?
Returns the ith element of s64vec.
(scheme vector base) procedure (s64vector-set! (s64vec s64vector?) (i integer?) (value s64?) ) ⟹ undefined
Sets the ith element of s64vec to value.
(scheme vector base) procedure (s64vector->list (s64vec s64vector?) ) ⟹ list?
(scheme vector base) procedure (s64vector->list (s64vec s64vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (s64vector->list (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s64vec
(scheme vector base) procedure (list->s64vector (proper-list list?) ) ⟹ s64vector?
proper-list ⟹ (list s64? )
Returns s64vector with same elements as list.
(scheme vector base) procedure (s64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s64vector (ie., signed exact integer in the range -(2^63) to (2^63)-1), and #f otherwise.
(scheme vector base) procedure (make-f32vector (size integer?) ) ⟹ f32vector?
(scheme vector base) procedure (make-f32vector (size integer?) (fill f32?) ) ⟹ f32vector?
Returns a f32vector whose length is size. If fill is provided, all the elements of the f32vector are initialized to it.
(scheme vector base) procedure (f32vector (value f32?) ... ) ⟹ f32vector?
Returns a f32vector initialized with values.
(scheme vector base) procedure (f32vector? obj ) ⟹ boolean?
Returns #t if obj is a f32vector, and #f otherwise.
(scheme vector base) procedure (f32vector-length (f32vec f32vector?) ) ⟹ integer?
Returns the length of f32vec
(scheme vector base) procedure (f32vector-ref (f32vec f32vector?) (i integer?) ) ⟹ f32?
Returns the ith element of f32vec.
(scheme vector base) procedure (f32vector-set! (f32vec f32vector?) (i integer?) (value f32?) ) ⟹ undefined
Sets the ith element of f32vec to value.
(scheme vector base) procedure (f32vector->list (f32vec f32vector?) ) ⟹ list?
(scheme vector base) procedure (f32vector->list (f32vec f32vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (f32vector->list (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f32vec
(scheme vector base) procedure (list->f32vector (proper-list list?) ) ⟹ f32vector?
proper-list ⟹ (list f32? )
Returns f32vector with same elements as list.
(scheme vector base) procedure (f32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an f32vector (ie., inexact real), and #f otherwise.
(scheme vector base) procedure (make-f64vector (size integer?) ) ⟹ f64vector?
(scheme vector base) procedure (make-f64vector (size integer?) (fill f64?) ) ⟹ f64vector?
Returns a f64vector whose length is size. If fill is provided, all the elements of the f64vector are initialized to it.
(scheme vector base) procedure (f64vector (value f64?) ... ) ⟹ f64vector?
Returns a f64vector initialized with values.
(scheme vector base) procedure (f64vector? obj ) ⟹ boolean?
Returns #t if obj is a f64vector, and #f otherwise.
(scheme vector base) procedure (f64vector-length (f64vec f64vector?) ) ⟹ integer?
Returns the length of f64vec
(scheme vector base) procedure (f64vector-ref (f64vec f64vector?) (i integer?) ) ⟹ f64?
Returns the ith element of f64vec.
(scheme vector base) procedure (f64vector-set! (f64vec f64vector?) (i integer?) (value f64?) ) ⟹ undefined
Sets the ith element of f64vec to value.
(scheme vector base) procedure (f64vector->list (f64vec f64vector?) ) ⟹ list?
(scheme vector base) procedure (f64vector->list (f64vec f64vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (f64vector->list (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f64vec
(scheme vector base) procedure (list->f64vector (proper-list list?) ) ⟹ f64vector?
proper-list ⟹ (list f64? )
Returns f64vector with same elements as list.
(scheme vector base) procedure (f64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an f64vector (ie., inexact real), and #f otherwise.
(scheme vector base) procedure (make-c64vector (size integer?) ) ⟹ c64vector?
(scheme vector base) procedure (make-c64vector (size integer?) (fill c64?) ) ⟹ c64vector?
Returns a c64vector whose length is size. If fill is provided, all the elements of the c64vector are initialized to it.
(scheme vector base) procedure (c64vector (value c64?) ... ) ⟹ c64vector?
Returns a c64vector initialized with values.
(scheme vector base) procedure (c64vector? obj ) ⟹ boolean?
Returns #t if obj is a c64vector, and #f otherwise.
(scheme vector base) procedure (c64vector-length (c64vec c64vector?) ) ⟹ integer?
Returns the length of c64vec
(scheme vector base) procedure (c64vector-ref (c64vec c64vector?) (i integer?) ) ⟹ c64?
Returns the ith element of c64vec.
(scheme vector base) procedure (c64vector-set! (c64vec c64vector?) (i integer?) (value c64?) ) ⟹ undefined
Sets the ith element of c64vec to value.
(scheme vector base) procedure (c64vector->list (c64vec c64vector?) ) ⟹ list?
(scheme vector base) procedure (c64vector->list (c64vec c64vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (c64vector->list (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c64vec
(scheme vector base) procedure (list->c64vector (proper-list list?) ) ⟹ c64vector?
proper-list ⟹ (list c64? )
Returns c64vector with same elements as list.
(scheme vector base) procedure (c64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an c64vector (ie., inexact complex), and #f otherwise.
(scheme vector base) procedure (make-c128vector (size integer?) ) ⟹ c128vector?
(scheme vector base) procedure (make-c128vector (size integer?) (fill c128?) ) ⟹ c128vector?
Returns a c128vector whose length is size. If fill is provided, all the elements of the c128vector are initialized to it.
(scheme vector base) procedure (c128vector (value c128?) ... ) ⟹ c128vector?
Returns a c128vector initialized with values.
(scheme vector base) procedure (c128vector? obj ) ⟹ boolean?
Returns #t if obj is a c128vector, and #f otherwise.
(scheme vector base) procedure (c128vector-length (c128vec c128vector?) ) ⟹ integer?
Returns the length of c128vec
(scheme vector base) procedure (c128vector-ref (c128vec c128vector?) (i integer?) ) ⟹ c128?
Returns the ith element of c128vec.
(scheme vector base) procedure (c128vector-set! (c128vec c128vector?) (i integer?) (value c128?) ) ⟹ undefined
Sets the ith element of c128vec to value.
(scheme vector base) procedure (c128vector->list (c128vec c128vector?) ) ⟹ list?
(scheme vector base) procedure (c128vector->list (c128vec c128vector?) (start integer?) ) ⟹ list?
(scheme vector base) procedure (c128vector->list (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c128vec
(scheme vector base) procedure (list->c128vector (proper-list list?) ) ⟹ c128vector?
proper-list ⟹ (list c128? )
Returns c128vector with same elements as list.
(scheme vector base) procedure (c128? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an c128vector (ie., inexact complex), and #f otherwise.
library (scheme vector u8)
(scheme vector u8) procedure (make-u8vector (size integer?) ) ⟹ u8vector?
(scheme vector u8) procedure (make-u8vector (size integer?) (fill u8?) ) ⟹ u8vector?
Returns a u8vector whose length is size. If fill is provided, all the elements of the u8vector are initialized to it.
(scheme vector u8) procedure (u8vector (value u8?) ... ) ⟹ u8vector?
Returns a u8vector initialized with values.
(scheme vector u8) procedure (u8vector? obj ) ⟹ boolean?
Returns #t if obj is a u8vector, and #f otherwise.
(scheme vector u8) procedure (u8vector-length (u8vec u8vector?) ) ⟹ integer?
Returns the length of u8vec
(scheme vector u8) procedure (u8vector-ref (u8vec u8vector?) (i integer?) ) ⟹ u8?
Returns the ith element of u8vec.
(scheme vector u8) procedure (u8vector-set! (u8vec u8vector?) (i integer?) (value u8?) ) ⟹ undefined
Sets the ith element of u8vec to value.
(scheme vector u8) procedure (u8vector->list (u8vec u8vector?) ) ⟹ list?
(scheme vector u8) procedure (u8vector->list (u8vec u8vector?) (start integer?) ) ⟹ list?
(scheme vector u8) procedure (u8vector->list (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u8vec
(scheme vector u8) procedure (list->u8vector (proper-list list?) ) ⟹ u8vector?
proper-list ⟹ (list u8? )
Returns u8vector with same elements as list.
(scheme vector u8) procedure (u8? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u8vector (ie., unsigned exact integer in the range 0 to (2^8)-1), and #f otherwise.
(scheme vector u8) procedure (u8vector-unfold (f procedure?) (length integer?) seed ) ⟹ u8vector?
(scheme vector u8) procedure (u8vector-unfold (f procedure?) (length integer?) seed ) ⟹ u8vector?
(f (index integer?) state ) ⟹ (values u8?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector u8) procedure (u8vector-copy (u8vec u8vector?) ) ⟹ u8vector?
(scheme vector u8) procedure (u8vector-copy (u8vec u8vector?) (start integer?) ) ⟹ u8vector?
(scheme vector u8) procedure (u8vector-copy (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ u8vector?
Makes a copy of the portion of u8vec from start to end and returns it.
(scheme vector u8) procedure (u8vector-reverse-copy (u8vec u8vector?) ) ⟹ u8vector?
(scheme vector u8) procedure (u8vector-reverse-copy (u8vec u8vector?) (start integer?) ) ⟹ u8vector?
(scheme vector u8) procedure (u8vector-reverse-copy (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ u8vector?
The same as u8vector-copy, but in reverse order.
(scheme vector u8) procedure (u8vector-append (u8vec u8vector?) ... ) ⟹ u8vector?
Returns a u8vector containing all the elements of the u8vecs in order.
(scheme vector u8) procedure (u8vector-concatenate (list-of-u8vectors list?) ) ⟹ u8vector?
list-of-u8vectors ⟹ (list u8vector? )
The same as u8vector-append, but takes a list of u8vectors rather than multiple arguments.
(scheme vector u8) procedure (u8vector-append-subvectors (u8vec1 u8vector?) (start1 integer?) (end1 integer?) ... ) ⟹ u8vector?
Concatenates the result of applying u8vector-copy to each triplet of u8vec, start, end arguments, but may be implemented more efficiently.
(scheme vector u8) procedure (u8vector-empty? (u8vec u8vector?) ) ⟹ boolean?
Returns #t if u8vec has a length of zero, and #f otherwise.
(scheme vector u8) procedure (u8vector= (u8vec u8vector?) ... ) ⟹ boolean?
Compares the u8vecs for elementwise equality, using = to do the comparisons. Returns #f unless all u8vectors are the same length.
(scheme vector u8) procedure (u8vector-take (u8vec u8vector?) (n integer?) ) ⟹ u8vector?
(scheme vector u8) procedure (u8vector-take-right (u8vec u8vector?) (n integer?) ) ⟹ u8vector?
Returns a u8vector containing the first/last n elements of u8vec.
(scheme vector u8) procedure (u8vector-drop (u8vec u8vector?) (n integer?) ) ⟹ u8vector?
(scheme vector u8) procedure (u8vector-drop-right (u8vec u8vector?) (n integer?) ) ⟹ u8vector?
Returns a u8vector containing all except the first/last n elements of u8vec.
(scheme vector u8) procedure (u8vector-segment (u8vec u8vector?) (n integer?) ) ⟹ list?
Returns a list of u8vectors, each of which contains n consecutive elements of u8vec. The last u8vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector u8) procedure (u8vector-fold (kons procedure?) knil (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ *
(kons state (obj1 u8?) (obj2 u8?) ... ) ⟹ *
(scheme vector u8) procedure (u8vector-fold-right (kons procedure?) knil (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ *
(kons state (obj1 u8?) (obj2 u8?) ... ) ⟹ *
When one u8vector argument u8vec is given, folds kons over the elements of u8vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple u8vector arguments are given, kons is called with the current state value and each value from all the vectors; u8vector-fold scans elements from left to right, while u8vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector u8) procedure (u8vector-map (proc procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ vector?
(proc (val1 u8?) ... ) ⟹ *
(scheme vector u8) procedure (u8vector-map! (proc procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ undefined
(proc (val1 u8?) ... ) ⟹ *
(scheme vector u8) procedure (u8vector-for-each (proc procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ undefined
(proc (val1 u8?) ... ) ⟹ undefined
Iterate over the elements of u8vec and apply f to each, returning respectively a u8vector of the results, an undefined value with the results placed back in u8vec, and an undefined value with no change to u8vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For u8vector-map!, only u8vec is modified even when multiple vectors are passed.
If u8vector-map or u8vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector u8) procedure (u8vector-count (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer?
(pred? (val1 u8?) (val2 u8?) ... ) ⟹ *
Call pred? on each element of u8vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector u8) procedure (u8vector-cumulate (f procedure?) knil (u8vec u8vector?) ) ⟹ u8vector?
(f state (value u8?) ) ⟹ *
Like u8vector-fold, but returns an u8vector of partial results rather than just the final result.
(scheme vector u8) procedure (u8vector-take-while (pred? procedure?) (u8vec u8vector?) ) ⟹ u8vector?
(pred? (value u8?) ) ⟹ boolean?
(scheme vector u8) procedure (u8vector-take-while-right (pred? procedure?) (u8vec u8vector?) ) ⟹ u8vector?
(pred? (value u8?) ) ⟹ boolean?
Return the shortest prefix/suffix of u8vec all of whose elements satisfy pred?.
(scheme vector u8) procedure (u8vector-drop-while (pred? procedure?) (u8vec u8vector?) ) ⟹ u8vector?
(pred? (value u8?) ) ⟹ boolean?
(scheme vector u8) procedure (u8vector-drop-while-right (pred? procedure?) (u8vec u8vector?) ) ⟹ u8vector?
(pred? (value u8?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of u8vec such that all its elements satisfy pred.
(scheme vector u8) procedure (u8vector-index (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u8?) (value2 u8?) ... ) ⟹ *
(scheme vector u8) procedure (u8vector-index-right (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u8?) (value2 u8?) ... ) ⟹ *
Return the index of the first/last element of u8vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u8vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for u8vector-index-right.
(scheme vector u8) procedure (u8vector-skip (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u8?) (value2 u8?) ... ) ⟹ *
(scheme vector u8) procedure (u8vector-skip-right (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u8?) (value2 u8?) ... ) ⟹ *
Returns the index of the first/last element of u8vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u8vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for u8vector-skip-right.
(scheme vector u8) procedure (u8vector-any (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ *
(pred? (val1 u8?) (val2 u8?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the u8vec, or #f if there is no such element. If u8vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector u8) procedure (u8vector-every (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ *
(pred? (val1 u8?) (val2 u8?) ... ) ⟹ *
If all elements from u8vec satisfy pred?, return the last result of pred?. If not all do, return #f. If u8vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector u8) procedure (u8vector-partition (pred? procedure?) (u8vec u8vector?) ) ⟹ (values u8vector?integer?)
(pred? (value u8?) ) ⟹ boolean?
Returns an u8vector of the same type as u8vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new u8vector and the number of elements satisfying pred?.
(scheme vector u8) procedure (u8vector-filter (pred? procedure?) (u8vec1 u8vector?) ) ⟹ u8vector?
(pred? (val u8?) ) ⟹ boolean?
(scheme vector u8) procedure (u8vector-remove (pred? procedure?) (u8vec1 u8vector?) ) ⟹ u8vector?
(pred? (val u8?) ) ⟹ boolean?
Return an u8vector containing the elements of u8vec that satisfy / do not satisfy pred?.
(scheme vector u8) procedure (u8vector-swap! (u8vec u8vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of u8vec.
(scheme vector u8) procedure (u8vector-fill! (u8vec u8vector?) (fill u8?) ) ⟹ undefined
(scheme vector u8) procedure (u8vector-fill! (u8vec u8vector?) (fill u8?) (start integer?) ) ⟹ undefined
(scheme vector u8) procedure (u8vector-fill! (u8vec u8vector?) (fill u8?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of u8vec from start to end with the value fill.
(scheme vector u8) procedure (u8vector-reverse! (u8vec u8vector?) ) ⟹ undefined
(scheme vector u8) procedure (u8vector-reverse! (u8vec u8vector?) (start integer?) ) ⟹ undefined
(scheme vector u8) procedure (u8vector-reverse! (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of u8vec from start to end.
(scheme vector u8) procedure (u8vector-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) ) ⟹ undefined
(scheme vector u8) procedure (u8vector-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) (start integer?) ) ⟹ undefined
(scheme vector u8) procedure (u8vector-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of u8from from start to end onto u8to, starting at index at.
(scheme vector u8) procedure (u8vector-reverse-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) ) ⟹ undefined
(scheme vector u8) procedure (u8vector-reverse-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) (start integer?) ) ⟹ undefined
(scheme vector u8) procedure (u8vector-reverse-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as u8vector-copy!, but copies in reverse
(scheme vector u8) procedure (u8vector-unfold! (f procedure?) (u8vec u8vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like u8vector-unfold, but the elements are copied into the vector u8vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector u8) procedure (u8vector-unfold-right! (f procedure?) (u8vec u8vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as u8vector-unfold!, but initializes the u8vector from right to left.
(scheme vector u8) procedure (reverse-u8vector->list (u8vec u8vector?) ) ⟹ list?
(scheme vector u8) procedure (reverse-u8vector->list (u8vec u8vector?) (start integer?) ) ⟹ list?
(scheme vector u8) procedure (reverse-u8vector->list (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u8vec in reverse order.
(scheme vector u8) procedure (reverse-list->u8vector (proper-list list?) ) ⟹ u8vector?
Returns u8vector with same elements as list in reverse order.
(scheme vector u8) procedure (u8vector->vector (u8vec u8vector?) ) ⟹ vector?
(scheme vector u8) procedure (u8vector->vector (u8vec u8vector?) (start integer?) ) ⟹ vector?
(scheme vector u8) procedure (u8vector->vector (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as u8vec.
(scheme vector u8) procedure (vector->u8vector (vec vector?) ) ⟹ u8vector?
(scheme vector u8) procedure (vector->u8vector (vec vector?) (start integer?) ) ⟹ u8vector?
(scheme vector u8) procedure (vector->u8vector (vec vector?) (start integer?) (end integer?) ) ⟹ u8vector?
Returns u8vector with same elements as vec.
(scheme vector u8) procedure (make-u8vector-generator (u8vector u8vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / u8? /
Returns a SRFI 121 generator that generates all the values of u8vector in order. Note that the generator is finite.
u8vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of u8vector.
(scheme vector u8) procedure (write-u8vector (u8vec u8vector) ) ⟹ undefined
(scheme vector u8) procedure (write-u8vector (u8vec u8vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of u8vec in the lexical syntax explained below.
library (scheme vector s8)
(scheme vector s8) procedure (make-s8vector (size integer?) ) ⟹ s8vector?
(scheme vector s8) procedure (make-s8vector (size integer?) (fill s8?) ) ⟹ s8vector?
Returns a s8vector whose length is size. If fill is provided, all the elements of the s8vector are initialized to it.
(scheme vector s8) procedure (s8vector (value s8?) ... ) ⟹ s8vector?
Returns a s8vector initialized with values.
(scheme vector s8) procedure (s8vector? obj ) ⟹ boolean?
Returns #t if obj is a s8vector, and #f otherwise.
(scheme vector s8) procedure (s8vector-length (s8vec s8vector?) ) ⟹ integer?
Returns the length of s8vec
(scheme vector s8) procedure (s8vector-ref (s8vec s8vector?) (i integer?) ) ⟹ s8?
Returns the ith element of s8vec.
(scheme vector s8) procedure (s8vector-set! (s8vec s8vector?) (i integer?) (value s8?) ) ⟹ undefined
Sets the ith element of s8vec to value.
(scheme vector s8) procedure (s8vector->list (s8vec s8vector?) ) ⟹ list?
(scheme vector s8) procedure (s8vector->list (s8vec s8vector?) (start integer?) ) ⟹ list?
(scheme vector s8) procedure (s8vector->list (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s8vec
(scheme vector s8) procedure (list->s8vector (proper-list list?) ) ⟹ s8vector?
proper-list ⟹ (list s8? )
Returns s8vector with same elements as list.
(scheme vector s8) procedure (s8? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s8vector (ie., signed exact integer in the range -(2^7) to (2^7)-1), and #f otherwise.
(scheme vector s8) procedure (s8vector-unfold (f procedure?) (length integer?) seed ) ⟹ s8vector?
(scheme vector s8) procedure (s8vector-unfold (f procedure?) (length integer?) seed ) ⟹ s8vector?
(f (index integer?) state ) ⟹ (values s8?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector s8) procedure (s8vector-copy (s8vec s8vector?) ) ⟹ s8vector?
(scheme vector s8) procedure (s8vector-copy (s8vec s8vector?) (start integer?) ) ⟹ s8vector?
(scheme vector s8) procedure (s8vector-copy (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ s8vector?
Makes a copy of the portion of s8vec from start to end and returns it.
(scheme vector s8) procedure (s8vector-reverse-copy (s8vec s8vector?) ) ⟹ s8vector?
(scheme vector s8) procedure (s8vector-reverse-copy (s8vec s8vector?) (start integer?) ) ⟹ s8vector?
(scheme vector s8) procedure (s8vector-reverse-copy (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ s8vector?
The same as s8vector-copy, but in reverse order.
(scheme vector s8) procedure (s8vector-append (s8vec s8vector?) ... ) ⟹ s8vector?
Returns a s8vector containing all the elements of the s8vecs in order.
(scheme vector s8) procedure (s8vector-concatenate (list-of-s8vectors list?) ) ⟹ s8vector?
list-of-s8vectors ⟹ (list s8vector? )
The same as s8vector-append, but takes a list of s8vectors rather than multiple arguments.
(scheme vector s8) procedure (s8vector-append-subvectors (s8vec1 s8vector?) (start1 integer?) (end1 integer?) ... ) ⟹ s8vector?
Concatenates the result of applying s8vector-copy to each triplet of s8vec, start, end arguments, but may be implemented more efficiently.
(scheme vector s8) procedure (s8vector-empty? (s8vec s8vector?) ) ⟹ boolean?
Returns #t if s8vec has a length of zero, and #f otherwise.
(scheme vector s8) procedure (s8vector= (s8vec s8vector?) ... ) ⟹ boolean?
Compares the s8vecs for elementwise equality, using = to do the comparisons. Returns #f unless all s8vectors are the same length.
(scheme vector s8) procedure (s8vector-take (s8vec s8vector?) (n integer?) ) ⟹ s8vector?
(scheme vector s8) procedure (s8vector-take-right (s8vec s8vector?) (n integer?) ) ⟹ s8vector?
Returns a s8vector containing the first/last n elements of s8vec.
(scheme vector s8) procedure (s8vector-drop (s8vec s8vector?) (n integer?) ) ⟹ s8vector?
(scheme vector s8) procedure (s8vector-drop-right (s8vec s8vector?) (n integer?) ) ⟹ s8vector?
Returns a s8vector containing all except the first/last n elements of s8vec.
(scheme vector s8) procedure (s8vector-segment (s8vec s8vector?) (n integer?) ) ⟹ list?
Returns a list of s8vectors, each of which contains n consecutive elements of s8vec. The last s8vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector s8) procedure (s8vector-fold (kons procedure?) knil (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ *
(kons state (obj1 s8?) (obj2 s8?) ... ) ⟹ *
(scheme vector s8) procedure (s8vector-fold-right (kons procedure?) knil (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ *
(kons state (obj1 s8?) (obj2 s8?) ... ) ⟹ *
When one s8vector argument s8vec is given, folds kons over the elements of s8vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple s8vector arguments are given, kons is called with the current state value and each value from all the vectors; s8vector-fold scans elements from left to right, while s8vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector s8) procedure (s8vector-map (proc procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ vector?
(proc (val1 s8?) ... ) ⟹ *
(scheme vector s8) procedure (s8vector-map! (proc procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ undefined
(proc (val1 s8?) ... ) ⟹ *
(scheme vector s8) procedure (s8vector-for-each (proc procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ undefined
(proc (val1 s8?) ... ) ⟹ undefined
Iterate over the elements of s8vec and apply f to each, returning respectively a s8vector of the results, an undefined value with the results placed back in s8vec, and an undefined value with no change to s8vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For s8vector-map!, only s8vec is modified even when multiple vectors are passed.
If s8vector-map or s8vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector s8) procedure (s8vector-count (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer?
(pred? (val1 s8?) (val2 s8?) ... ) ⟹ *
Call pred? on each element of s8vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector s8) procedure (s8vector-cumulate (f procedure?) knil (s8vec s8vector?) ) ⟹ s8vector?
(f state (value s8?) ) ⟹ *
Like s8vector-fold, but returns an s8vector of partial results rather than just the final result.
(scheme vector s8) procedure (s8vector-take-while (pred? procedure?) (s8vec s8vector?) ) ⟹ s8vector?
(pred? (value s8?) ) ⟹ boolean?
(scheme vector s8) procedure (s8vector-take-while-right (pred? procedure?) (s8vec s8vector?) ) ⟹ s8vector?
(pred? (value s8?) ) ⟹ boolean?
Return the shortest prefix/suffix of s8vec all of whose elements satisfy pred?.
(scheme vector s8) procedure (s8vector-drop-while (pred? procedure?) (s8vec s8vector?) ) ⟹ s8vector?
(pred? (value s8?) ) ⟹ boolean?
(scheme vector s8) procedure (s8vector-drop-while-right (pred? procedure?) (s8vec s8vector?) ) ⟹ s8vector?
(pred? (value s8?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of s8vec such that all its elements satisfy pred.
(scheme vector s8) procedure (s8vector-index (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s8?) (value2 s8?) ... ) ⟹ *
(scheme vector s8) procedure (s8vector-index-right (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s8?) (value2 s8?) ... ) ⟹ *
Return the index of the first/last element of s8vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s8vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for s8vector-index-right.
(scheme vector s8) procedure (s8vector-skip (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s8?) (value2 s8?) ... ) ⟹ *
(scheme vector s8) procedure (s8vector-skip-right (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s8?) (value2 s8?) ... ) ⟹ *
Returns the index of the first/last element of s8vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s8vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for s8vector-skip-right.
(scheme vector s8) procedure (s8vector-any (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ *
(pred? (val1 s8?) (val2 s8?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the s8vec, or #f if there is no such element. If s8vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector s8) procedure (s8vector-every (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ *
(pred? (val1 s8?) (val2 s8?) ... ) ⟹ *
If all elements from s8vec satisfy pred?, return the last result of pred?. If not all do, return #f. If s8vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector s8) procedure (s8vector-partition (pred? procedure?) (s8vec s8vector?) ) ⟹ (values s8vector?integer?)
(pred? (value s8?) ) ⟹ boolean?
Returns an s8vector of the same type as s8vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new s8vector and the number of elements satisfying pred?.
(scheme vector s8) procedure (s8vector-filter (pred? procedure?) (s8vec1 s8vector?) ) ⟹ s8vector?
(pred? (val s8?) ) ⟹ boolean?
(scheme vector s8) procedure (s8vector-remove (pred? procedure?) (s8vec1 s8vector?) ) ⟹ s8vector?
(pred? (val s8?) ) ⟹ boolean?
Return an s8vector containing the elements of s8vec that satisfy / do not satisfy pred?.
(scheme vector s8) procedure (s8vector-swap! (s8vec s8vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of s8vec.
(scheme vector s8) procedure (s8vector-fill! (s8vec s8vector?) (fill s8?) ) ⟹ undefined
(scheme vector s8) procedure (s8vector-fill! (s8vec s8vector?) (fill s8?) (start integer?) ) ⟹ undefined
(scheme vector s8) procedure (s8vector-fill! (s8vec s8vector?) (fill s8?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of s8vec from start to end with the value fill.
(scheme vector s8) procedure (s8vector-reverse! (s8vec s8vector?) ) ⟹ undefined
(scheme vector s8) procedure (s8vector-reverse! (s8vec s8vector?) (start integer?) ) ⟹ undefined
(scheme vector s8) procedure (s8vector-reverse! (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of s8vec from start to end.
(scheme vector s8) procedure (s8vector-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) ) ⟹ undefined
(scheme vector s8) procedure (s8vector-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) (start integer?) ) ⟹ undefined
(scheme vector s8) procedure (s8vector-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of s8from from start to end onto s8to, starting at index at.
(scheme vector s8) procedure (s8vector-reverse-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) ) ⟹ undefined
(scheme vector s8) procedure (s8vector-reverse-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) (start integer?) ) ⟹ undefined
(scheme vector s8) procedure (s8vector-reverse-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as s8vector-copy!, but copies in reverse
(scheme vector s8) procedure (s8vector-unfold! (f procedure?) (s8vec s8vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like s8vector-unfold, but the elements are copied into the vector s8vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector s8) procedure (s8vector-unfold-right! (f procedure?) (s8vec s8vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as s8vector-unfold!, but initializes the s8vector from right to left.
(scheme vector s8) procedure (reverse-s8vector->list (s8vec s8vector?) ) ⟹ list?
(scheme vector s8) procedure (reverse-s8vector->list (s8vec s8vector?) (start integer?) ) ⟹ list?
(scheme vector s8) procedure (reverse-s8vector->list (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s8vec in reverse order.
(scheme vector s8) procedure (reverse-list->s8vector (proper-list list?) ) ⟹ s8vector?
Returns s8vector with same elements as list in reverse order.
(scheme vector s8) procedure (s8vector->vector (s8vec s8vector?) ) ⟹ vector?
(scheme vector s8) procedure (s8vector->vector (s8vec s8vector?) (start integer?) ) ⟹ vector?
(scheme vector s8) procedure (s8vector->vector (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as s8vec.
(scheme vector s8) procedure (vector->s8vector (vec vector?) ) ⟹ s8vector?
(scheme vector s8) procedure (vector->s8vector (vec vector?) (start integer?) ) ⟹ s8vector?
(scheme vector s8) procedure (vector->s8vector (vec vector?) (start integer?) (end integer?) ) ⟹ s8vector?
Returns s8vector with same elements as vec.
(scheme vector s8) procedure (make-s8vector-generator (s8vector s8vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / s8? /
Returns a SRFI 121 generator that generates all the values of s8vector in order. Note that the generator is finite.
s8vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of s8vector.
(scheme vector s8) procedure (write-s8vector (s8vec s8vector) ) ⟹ undefined
(scheme vector s8) procedure (write-s8vector (s8vec s8vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of s8vec in the lexical syntax explained below.
library (scheme vector u16)
(scheme vector u16) procedure (make-u16vector (size integer?) ) ⟹ u16vector?
(scheme vector u16) procedure (make-u16vector (size integer?) (fill u16?) ) ⟹ u16vector?
Returns a u16vector whose length is size. If fill is provided, all the elements of the u16vector are initialized to it.
(scheme vector u16) procedure (u16vector (value u16?) ... ) ⟹ u16vector?
Returns a u16vector initialized with values.
(scheme vector u16) procedure (u16vector? obj ) ⟹ boolean?
Returns #t if obj is a u16vector, and #f otherwise.
(scheme vector u16) procedure (u16vector-length (u16vec u16vector?) ) ⟹ integer?
Returns the length of u16vec
(scheme vector u16) procedure (u16vector-ref (u16vec u16vector?) (i integer?) ) ⟹ u16?
Returns the ith element of u16vec.
(scheme vector u16) procedure (u16vector-set! (u16vec u16vector?) (i integer?) (value u16?) ) ⟹ undefined
Sets the ith element of u16vec to value.
(scheme vector u16) procedure (u16vector->list (u16vec u16vector?) ) ⟹ list?
(scheme vector u16) procedure (u16vector->list (u16vec u16vector?) (start integer?) ) ⟹ list?
(scheme vector u16) procedure (u16vector->list (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u16vec
(scheme vector u16) procedure (list->u16vector (proper-list list?) ) ⟹ u16vector?
proper-list ⟹ (list u16? )
Returns u16vector with same elements as list.
(scheme vector u16) procedure (u16? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u16vector (ie., unsigned exact integer in the range 0 to (2^16)-1), and #f otherwise.
(scheme vector u16) procedure (u16vector-unfold (f procedure?) (length integer?) seed ) ⟹ u16vector?
(scheme vector u16) procedure (u16vector-unfold (f procedure?) (length integer?) seed ) ⟹ u16vector?
(f (index integer?) state ) ⟹ (values u16?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector u16) procedure (u16vector-copy (u16vec u16vector?) ) ⟹ u16vector?
(scheme vector u16) procedure (u16vector-copy (u16vec u16vector?) (start integer?) ) ⟹ u16vector?
(scheme vector u16) procedure (u16vector-copy (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ u16vector?
Makes a copy of the portion of u16vec from start to end and returns it.
(scheme vector u16) procedure (u16vector-reverse-copy (u16vec u16vector?) ) ⟹ u16vector?
(scheme vector u16) procedure (u16vector-reverse-copy (u16vec u16vector?) (start integer?) ) ⟹ u16vector?
(scheme vector u16) procedure (u16vector-reverse-copy (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ u16vector?
The same as u16vector-copy, but in reverse order.
(scheme vector u16) procedure (u16vector-append (u16vec u16vector?) ... ) ⟹ u16vector?
Returns a u16vector containing all the elements of the u16vecs in order.
(scheme vector u16) procedure (u16vector-concatenate (list-of-u16vectors list?) ) ⟹ u16vector?
list-of-u16vectors ⟹ (list u16vector? )
The same as u16vector-append, but takes a list of u16vectors rather than multiple arguments.
(scheme vector u16) procedure (u16vector-append-subvectors (u16vec1 u16vector?) (start1 integer?) (end1 integer?) ... ) ⟹ u16vector?
Concatenates the result of applying u16vector-copy to each triplet of u16vec, start, end arguments, but may be implemented more efficiently.
(scheme vector u16) procedure (u16vector-empty? (u16vec u16vector?) ) ⟹ boolean?
Returns #t if u16vec has a length of zero, and #f otherwise.
(scheme vector u16) procedure (u16vector= (u16vec u16vector?) ... ) ⟹ boolean?
Compares the u16vecs for elementwise equality, using = to do the comparisons. Returns #f unless all u16vectors are the same length.
(scheme vector u16) procedure (u16vector-take (u16vec u16vector?) (n integer?) ) ⟹ u16vector?
(scheme vector u16) procedure (u16vector-take-right (u16vec u16vector?) (n integer?) ) ⟹ u16vector?
Returns a u16vector containing the first/last n elements of u16vec.
(scheme vector u16) procedure (u16vector-drop (u16vec u16vector?) (n integer?) ) ⟹ u16vector?
(scheme vector u16) procedure (u16vector-drop-right (u16vec u16vector?) (n integer?) ) ⟹ u16vector?
Returns a u16vector containing all except the first/last n elements of u16vec.
(scheme vector u16) procedure (u16vector-segment (u16vec u16vector?) (n integer?) ) ⟹ list?
Returns a list of u16vectors, each of which contains n consecutive elements of u16vec. The last u16vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector u16) procedure (u16vector-fold (kons procedure?) knil (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ *
(kons state (obj1 u16?) (obj2 u16?) ... ) ⟹ *
(scheme vector u16) procedure (u16vector-fold-right (kons procedure?) knil (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ *
(kons state (obj1 u16?) (obj2 u16?) ... ) ⟹ *
When one u16vector argument u16vec is given, folds kons over the elements of u16vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple u16vector arguments are given, kons is called with the current state value and each value from all the vectors; u16vector-fold scans elements from left to right, while u16vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector u16) procedure (u16vector-map (proc procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ vector?
(proc (val1 u16?) ... ) ⟹ *
(scheme vector u16) procedure (u16vector-map! (proc procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ undefined
(proc (val1 u16?) ... ) ⟹ *
(scheme vector u16) procedure (u16vector-for-each (proc procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ undefined
(proc (val1 u16?) ... ) ⟹ undefined
Iterate over the elements of u16vec and apply f to each, returning respectively a u16vector of the results, an undefined value with the results placed back in u16vec, and an undefined value with no change to u16vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For u16vector-map!, only u16vec is modified even when multiple vectors are passed.
If u16vector-map or u16vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector u16) procedure (u16vector-count (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer?
(pred? (val1 u16?) (val2 u16?) ... ) ⟹ *
Call pred? on each element of u16vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector u16) procedure (u16vector-cumulate (f procedure?) knil (u16vec u16vector?) ) ⟹ u16vector?
(f state (value u16?) ) ⟹ *
Like u16vector-fold, but returns an u16vector of partial results rather than just the final result.
(scheme vector u16) procedure (u16vector-take-while (pred? procedure?) (u16vec u16vector?) ) ⟹ u16vector?
(pred? (value u16?) ) ⟹ boolean?
(scheme vector u16) procedure (u16vector-take-while-right (pred? procedure?) (u16vec u16vector?) ) ⟹ u16vector?
(pred? (value u16?) ) ⟹ boolean?
Return the shortest prefix/suffix of u16vec all of whose elements satisfy pred?.
(scheme vector u16) procedure (u16vector-drop-while (pred? procedure?) (u16vec u16vector?) ) ⟹ u16vector?
(pred? (value u16?) ) ⟹ boolean?
(scheme vector u16) procedure (u16vector-drop-while-right (pred? procedure?) (u16vec u16vector?) ) ⟹ u16vector?
(pred? (value u16?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of u16vec such that all its elements satisfy pred.
(scheme vector u16) procedure (u16vector-index (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u16?) (value2 u16?) ... ) ⟹ *
(scheme vector u16) procedure (u16vector-index-right (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u16?) (value2 u16?) ... ) ⟹ *
Return the index of the first/last element of u16vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u16vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for u16vector-index-right.
(scheme vector u16) procedure (u16vector-skip (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u16?) (value2 u16?) ... ) ⟹ *
(scheme vector u16) procedure (u16vector-skip-right (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u16?) (value2 u16?) ... ) ⟹ *
Returns the index of the first/last element of u16vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u16vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for u16vector-skip-right.
(scheme vector u16) procedure (u16vector-any (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ *
(pred? (val1 u16?) (val2 u16?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the u16vec, or #f if there is no such element. If u16vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector u16) procedure (u16vector-every (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ *
(pred? (val1 u16?) (val2 u16?) ... ) ⟹ *
If all elements from u16vec satisfy pred?, return the last result of pred?. If not all do, return #f. If u16vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector u16) procedure (u16vector-partition (pred? procedure?) (u16vec u16vector?) ) ⟹ (values u16vector?integer?)
(pred? (value u16?) ) ⟹ boolean?
Returns an u16vector of the same type as u16vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new u16vector and the number of elements satisfying pred?.
(scheme vector u16) procedure (u16vector-filter (pred? procedure?) (u16vec1 u16vector?) ) ⟹ u16vector?
(pred? (val u16?) ) ⟹ boolean?
(scheme vector u16) procedure (u16vector-remove (pred? procedure?) (u16vec1 u16vector?) ) ⟹ u16vector?
(pred? (val u16?) ) ⟹ boolean?
Return an u16vector containing the elements of u16vec that satisfy / do not satisfy pred?.
(scheme vector u16) procedure (u16vector-swap! (u16vec u16vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of u16vec.
(scheme vector u16) procedure (u16vector-fill! (u16vec u16vector?) (fill u16?) ) ⟹ undefined
(scheme vector u16) procedure (u16vector-fill! (u16vec u16vector?) (fill u16?) (start integer?) ) ⟹ undefined
(scheme vector u16) procedure (u16vector-fill! (u16vec u16vector?) (fill u16?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of u16vec from start to end with the value fill.
(scheme vector u16) procedure (u16vector-reverse! (u16vec u16vector?) ) ⟹ undefined
(scheme vector u16) procedure (u16vector-reverse! (u16vec u16vector?) (start integer?) ) ⟹ undefined
(scheme vector u16) procedure (u16vector-reverse! (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of u16vec from start to end.
(scheme vector u16) procedure (u16vector-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) ) ⟹ undefined
(scheme vector u16) procedure (u16vector-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) (start integer?) ) ⟹ undefined
(scheme vector u16) procedure (u16vector-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of u16from from start to end onto u16to, starting at index at.
(scheme vector u16) procedure (u16vector-reverse-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) ) ⟹ undefined
(scheme vector u16) procedure (u16vector-reverse-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) (start integer?) ) ⟹ undefined
(scheme vector u16) procedure (u16vector-reverse-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as u16vector-copy!, but copies in reverse
(scheme vector u16) procedure (u16vector-unfold! (f procedure?) (u16vec u16vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like u16vector-unfold, but the elements are copied into the vector u16vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector u16) procedure (u16vector-unfold-right! (f procedure?) (u16vec u16vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as u16vector-unfold!, but initializes the u16vector from right to left.
(scheme vector u16) procedure (reverse-u16vector->list (u16vec u16vector?) ) ⟹ list?
(scheme vector u16) procedure (reverse-u16vector->list (u16vec u16vector?) (start integer?) ) ⟹ list?
(scheme vector u16) procedure (reverse-u16vector->list (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u16vec in reverse order.
(scheme vector u16) procedure (reverse-list->u16vector (proper-list list?) ) ⟹ u16vector?
Returns u16vector with same elements as list in reverse order.
(scheme vector u16) procedure (u16vector->vector (u16vec u16vector?) ) ⟹ vector?
(scheme vector u16) procedure (u16vector->vector (u16vec u16vector?) (start integer?) ) ⟹ vector?
(scheme vector u16) procedure (u16vector->vector (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as u16vec.
(scheme vector u16) procedure (vector->u16vector (vec vector?) ) ⟹ u16vector?
(scheme vector u16) procedure (vector->u16vector (vec vector?) (start integer?) ) ⟹ u16vector?
(scheme vector u16) procedure (vector->u16vector (vec vector?) (start integer?) (end integer?) ) ⟹ u16vector?
Returns u16vector with same elements as vec.
(scheme vector u16) procedure (make-u16vector-generator (u16vector u16vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / u16? /
Returns a SRFI 121 generator that generates all the values of u16vector in order. Note that the generator is finite.
u16vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of u16vector.
(scheme vector u16) procedure (write-u16vector (u16vec u16vector) ) ⟹ undefined
(scheme vector u16) procedure (write-u16vector (u16vec u16vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of u16vec in the lexical syntax explained below.
library (scheme vector s16)
(scheme vector s16) procedure (make-s16vector (size integer?) ) ⟹ s16vector?
(scheme vector s16) procedure (make-s16vector (size integer?) (fill s16?) ) ⟹ s16vector?
Returns a s16vector whose length is size. If fill is provided, all the elements of the s16vector are initialized to it.
(scheme vector s16) procedure (s16vector (value s16?) ... ) ⟹ s16vector?
Returns a s16vector initialized with values.
(scheme vector s16) procedure (s16vector? obj ) ⟹ boolean?
Returns #t if obj is a s16vector, and #f otherwise.
(scheme vector s16) procedure (s16vector-length (s16vec s16vector?) ) ⟹ integer?
Returns the length of s16vec
(scheme vector s16) procedure (s16vector-ref (s16vec s16vector?) (i integer?) ) ⟹ s16?
Returns the ith element of s16vec.
(scheme vector s16) procedure (s16vector-set! (s16vec s16vector?) (i integer?) (value s16?) ) ⟹ undefined
Sets the ith element of s16vec to value.
(scheme vector s16) procedure (s16vector->list (s16vec s16vector?) ) ⟹ list?
(scheme vector s16) procedure (s16vector->list (s16vec s16vector?) (start integer?) ) ⟹ list?
(scheme vector s16) procedure (s16vector->list (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s16vec
(scheme vector s16) procedure (list->s16vector (proper-list list?) ) ⟹ s16vector?
proper-list ⟹ (list s16? )
Returns s16vector with same elements as list.
(scheme vector s16) procedure (s16? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s16vector (ie., signed exact integer in the range -(2^15) to (2^15)-1), and #f otherwise.
(scheme vector s16) procedure (s16vector-unfold (f procedure?) (length integer?) seed ) ⟹ s16vector?
(scheme vector s16) procedure (s16vector-unfold (f procedure?) (length integer?) seed ) ⟹ s16vector?
(f (index integer?) state ) ⟹ (values s16?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector s16) procedure (s16vector-copy (s16vec s16vector?) ) ⟹ s16vector?
(scheme vector s16) procedure (s16vector-copy (s16vec s16vector?) (start integer?) ) ⟹ s16vector?
(scheme vector s16) procedure (s16vector-copy (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ s16vector?
Makes a copy of the portion of s16vec from start to end and returns it.
(scheme vector s16) procedure (s16vector-reverse-copy (s16vec s16vector?) ) ⟹ s16vector?
(scheme vector s16) procedure (s16vector-reverse-copy (s16vec s16vector?) (start integer?) ) ⟹ s16vector?
(scheme vector s16) procedure (s16vector-reverse-copy (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ s16vector?
The same as s16vector-copy, but in reverse order.
(scheme vector s16) procedure (s16vector-append (s16vec s16vector?) ... ) ⟹ s16vector?
Returns a s16vector containing all the elements of the s16vecs in order.
(scheme vector s16) procedure (s16vector-concatenate (list-of-s16vectors list?) ) ⟹ s16vector?
list-of-s16vectors ⟹ (list s16vector? )
The same as s16vector-append, but takes a list of s16vectors rather than multiple arguments.
(scheme vector s16) procedure (s16vector-append-subvectors (s16vec1 s16vector?) (start1 integer?) (end1 integer?) ... ) ⟹ s16vector?
Concatenates the result of applying s16vector-copy to each triplet of s16vec, start, end arguments, but may be implemented more efficiently.
(scheme vector s16) procedure (s16vector-empty? (s16vec s16vector?) ) ⟹ boolean?
Returns #t if s16vec has a length of zero, and #f otherwise.
(scheme vector s16) procedure (s16vector= (s16vec s16vector?) ... ) ⟹ boolean?
Compares the s16vecs for elementwise equality, using = to do the comparisons. Returns #f unless all s16vectors are the same length.
(scheme vector s16) procedure (s16vector-take (s16vec s16vector?) (n integer?) ) ⟹ s16vector?
(scheme vector s16) procedure (s16vector-take-right (s16vec s16vector?) (n integer?) ) ⟹ s16vector?
Returns a s16vector containing the first/last n elements of s16vec.
(scheme vector s16) procedure (s16vector-drop (s16vec s16vector?) (n integer?) ) ⟹ s16vector?
(scheme vector s16) procedure (s16vector-drop-right (s16vec s16vector?) (n integer?) ) ⟹ s16vector?
Returns a s16vector containing all except the first/last n elements of s16vec.
(scheme vector s16) procedure (s16vector-segment (s16vec s16vector?) (n integer?) ) ⟹ list?
Returns a list of s16vectors, each of which contains n consecutive elements of s16vec. The last s16vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector s16) procedure (s16vector-fold (kons procedure?) knil (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ *
(kons state (obj1 s16?) (obj2 s16?) ... ) ⟹ *
(scheme vector s16) procedure (s16vector-fold-right (kons procedure?) knil (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ *
(kons state (obj1 s16?) (obj2 s16?) ... ) ⟹ *
When one s16vector argument s16vec is given, folds kons over the elements of s16vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple s16vector arguments are given, kons is called with the current state value and each value from all the vectors; s16vector-fold scans elements from left to right, while s16vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector s16) procedure (s16vector-map (proc procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ vector?
(proc (val1 s16?) ... ) ⟹ *
(scheme vector s16) procedure (s16vector-map! (proc procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ undefined
(proc (val1 s16?) ... ) ⟹ *
(scheme vector s16) procedure (s16vector-for-each (proc procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ undefined
(proc (val1 s16?) ... ) ⟹ undefined
Iterate over the elements of s16vec and apply f to each, returning respectively a s16vector of the results, an undefined value with the results placed back in s16vec, and an undefined value with no change to s16vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For s16vector-map!, only s16vec is modified even when multiple vectors are passed.
If s16vector-map or s16vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector s16) procedure (s16vector-count (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer?
(pred? (val1 s16?) (val2 s16?) ... ) ⟹ *
Call pred? on each element of s16vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector s16) procedure (s16vector-cumulate (f procedure?) knil (s16vec s16vector?) ) ⟹ s16vector?
(f state (value s16?) ) ⟹ *
Like s16vector-fold, but returns an s16vector of partial results rather than just the final result.
(scheme vector s16) procedure (s16vector-take-while (pred? procedure?) (s16vec s16vector?) ) ⟹ s16vector?
(pred? (value s16?) ) ⟹ boolean?
(scheme vector s16) procedure (s16vector-take-while-right (pred? procedure?) (s16vec s16vector?) ) ⟹ s16vector?
(pred? (value s16?) ) ⟹ boolean?
Return the shortest prefix/suffix of s16vec all of whose elements satisfy pred?.
(scheme vector s16) procedure (s16vector-drop-while (pred? procedure?) (s16vec s16vector?) ) ⟹ s16vector?
(pred? (value s16?) ) ⟹ boolean?
(scheme vector s16) procedure (s16vector-drop-while-right (pred? procedure?) (s16vec s16vector?) ) ⟹ s16vector?
(pred? (value s16?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of s16vec such that all its elements satisfy pred.
(scheme vector s16) procedure (s16vector-index (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s16?) (value2 s16?) ... ) ⟹ *
(scheme vector s16) procedure (s16vector-index-right (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s16?) (value2 s16?) ... ) ⟹ *
Return the index of the first/last element of s16vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s16vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for s16vector-index-right.
(scheme vector s16) procedure (s16vector-skip (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s16?) (value2 s16?) ... ) ⟹ *
(scheme vector s16) procedure (s16vector-skip-right (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s16?) (value2 s16?) ... ) ⟹ *
Returns the index of the first/last element of s16vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s16vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for s16vector-skip-right.
(scheme vector s16) procedure (s16vector-any (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ *
(pred? (val1 s16?) (val2 s16?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the s16vec, or #f if there is no such element. If s16vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector s16) procedure (s16vector-every (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ *
(pred? (val1 s16?) (val2 s16?) ... ) ⟹ *
If all elements from s16vec satisfy pred?, return the last result of pred?. If not all do, return #f. If s16vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector s16) procedure (s16vector-partition (pred? procedure?) (s16vec s16vector?) ) ⟹ (values s16vector?integer?)
(pred? (value s16?) ) ⟹ boolean?
Returns an s16vector of the same type as s16vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new s16vector and the number of elements satisfying pred?.
(scheme vector s16) procedure (s16vector-filter (pred? procedure?) (s16vec1 s16vector?) ) ⟹ s16vector?
(pred? (val s16?) ) ⟹ boolean?
(scheme vector s16) procedure (s16vector-remove (pred? procedure?) (s16vec1 s16vector?) ) ⟹ s16vector?
(pred? (val s16?) ) ⟹ boolean?
Return an s16vector containing the elements of s16vec that satisfy / do not satisfy pred?.
(scheme vector s16) procedure (s16vector-swap! (s16vec s16vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of s16vec.
(scheme vector s16) procedure (s16vector-fill! (s16vec s16vector?) (fill s16?) ) ⟹ undefined
(scheme vector s16) procedure (s16vector-fill! (s16vec s16vector?) (fill s16?) (start integer?) ) ⟹ undefined
(scheme vector s16) procedure (s16vector-fill! (s16vec s16vector?) (fill s16?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of s16vec from start to end with the value fill.
(scheme vector s16) procedure (s16vector-reverse! (s16vec s16vector?) ) ⟹ undefined
(scheme vector s16) procedure (s16vector-reverse! (s16vec s16vector?) (start integer?) ) ⟹ undefined
(scheme vector s16) procedure (s16vector-reverse! (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of s16vec from start to end.
(scheme vector s16) procedure (s16vector-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) ) ⟹ undefined
(scheme vector s16) procedure (s16vector-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) (start integer?) ) ⟹ undefined
(scheme vector s16) procedure (s16vector-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of s16from from start to end onto s16to, starting at index at.
(scheme vector s16) procedure (s16vector-reverse-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) ) ⟹ undefined
(scheme vector s16) procedure (s16vector-reverse-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) (start integer?) ) ⟹ undefined
(scheme vector s16) procedure (s16vector-reverse-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as s16vector-copy!, but copies in reverse
(scheme vector s16) procedure (s16vector-unfold! (f procedure?) (s16vec s16vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like s16vector-unfold, but the elements are copied into the vector s16vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector s16) procedure (s16vector-unfold-right! (f procedure?) (s16vec s16vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as s16vector-unfold!, but initializes the s16vector from right to left.
(scheme vector s16) procedure (reverse-s16vector->list (s16vec s16vector?) ) ⟹ list?
(scheme vector s16) procedure (reverse-s16vector->list (s16vec s16vector?) (start integer?) ) ⟹ list?
(scheme vector s16) procedure (reverse-s16vector->list (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s16vec in reverse order.
(scheme vector s16) procedure (reverse-list->s16vector (proper-list list?) ) ⟹ s16vector?
Returns s16vector with same elements as list in reverse order.
(scheme vector s16) procedure (s16vector->vector (s16vec s16vector?) ) ⟹ vector?
(scheme vector s16) procedure (s16vector->vector (s16vec s16vector?) (start integer?) ) ⟹ vector?
(scheme vector s16) procedure (s16vector->vector (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as s16vec.
(scheme vector s16) procedure (vector->s16vector (vec vector?) ) ⟹ s16vector?
(scheme vector s16) procedure (vector->s16vector (vec vector?) (start integer?) ) ⟹ s16vector?
(scheme vector s16) procedure (vector->s16vector (vec vector?) (start integer?) (end integer?) ) ⟹ s16vector?
Returns s16vector with same elements as vec.
(scheme vector s16) procedure (make-s16vector-generator (s16vector s16vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / s16? /
Returns a SRFI 121 generator that generates all the values of s16vector in order. Note that the generator is finite.
s16vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of s16vector.
(scheme vector s16) procedure (write-s16vector (s16vec s16vector) ) ⟹ undefined
(scheme vector s16) procedure (write-s16vector (s16vec s16vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of s16vec in the lexical syntax explained below.
library (scheme vector u32)
(scheme vector u32) procedure (make-u32vector (size integer?) ) ⟹ u32vector?
(scheme vector u32) procedure (make-u32vector (size integer?) (fill u32?) ) ⟹ u32vector?
Returns a u32vector whose length is size. If fill is provided, all the elements of the u32vector are initialized to it.
(scheme vector u32) procedure (u32vector (value u32?) ... ) ⟹ u32vector?
Returns a u32vector initialized with values.
(scheme vector u32) procedure (u32vector? obj ) ⟹ boolean?
Returns #t if obj is a u32vector, and #f otherwise.
(scheme vector u32) procedure (u32vector-length (u32vec u32vector?) ) ⟹ integer?
Returns the length of u32vec
(scheme vector u32) procedure (u32vector-ref (u32vec u32vector?) (i integer?) ) ⟹ u32?
Returns the ith element of u32vec.
(scheme vector u32) procedure (u32vector-set! (u32vec u32vector?) (i integer?) (value u32?) ) ⟹ undefined
Sets the ith element of u32vec to value.
(scheme vector u32) procedure (u32vector->list (u32vec u32vector?) ) ⟹ list?
(scheme vector u32) procedure (u32vector->list (u32vec u32vector?) (start integer?) ) ⟹ list?
(scheme vector u32) procedure (u32vector->list (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u32vec
(scheme vector u32) procedure (list->u32vector (proper-list list?) ) ⟹ u32vector?
proper-list ⟹ (list u32? )
Returns u32vector with same elements as list.
(scheme vector u32) procedure (u32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u32vector (ie., unsigned exact integer in the range 0 to (2^32)-1), and #f otherwise.
(scheme vector u32) procedure (u32vector-unfold (f procedure?) (length integer?) seed ) ⟹ u32vector?
(scheme vector u32) procedure (u32vector-unfold (f procedure?) (length integer?) seed ) ⟹ u32vector?
(f (index integer?) state ) ⟹ (values u32?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector u32) procedure (u32vector-copy (u32vec u32vector?) ) ⟹ u32vector?
(scheme vector u32) procedure (u32vector-copy (u32vec u32vector?) (start integer?) ) ⟹ u32vector?
(scheme vector u32) procedure (u32vector-copy (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ u32vector?
Makes a copy of the portion of u32vec from start to end and returns it.
(scheme vector u32) procedure (u32vector-reverse-copy (u32vec u32vector?) ) ⟹ u32vector?
(scheme vector u32) procedure (u32vector-reverse-copy (u32vec u32vector?) (start integer?) ) ⟹ u32vector?
(scheme vector u32) procedure (u32vector-reverse-copy (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ u32vector?
The same as u32vector-copy, but in reverse order.
(scheme vector u32) procedure (u32vector-append (u32vec u32vector?) ... ) ⟹ u32vector?
Returns a u32vector containing all the elements of the u32vecs in order.
(scheme vector u32) procedure (u32vector-concatenate (list-of-u32vectors list?) ) ⟹ u32vector?
list-of-u32vectors ⟹ (list u32vector? )
The same as u32vector-append, but takes a list of u32vectors rather than multiple arguments.
(scheme vector u32) procedure (u32vector-append-subvectors (u32vec1 u32vector?) (start1 integer?) (end1 integer?) ... ) ⟹ u32vector?
Concatenates the result of applying u32vector-copy to each triplet of u32vec, start, end arguments, but may be implemented more efficiently.
(scheme vector u32) procedure (u32vector-empty? (u32vec u32vector?) ) ⟹ boolean?
Returns #t if u32vec has a length of zero, and #f otherwise.
(scheme vector u32) procedure (u32vector= (u32vec u32vector?) ... ) ⟹ boolean?
Compares the u32vecs for elementwise equality, using = to do the comparisons. Returns #f unless all u32vectors are the same length.
(scheme vector u32) procedure (u32vector-take (u32vec u32vector?) (n integer?) ) ⟹ u32vector?
(scheme vector u32) procedure (u32vector-take-right (u32vec u32vector?) (n integer?) ) ⟹ u32vector?
Returns a u32vector containing the first/last n elements of u32vec.
(scheme vector u32) procedure (u32vector-drop (u32vec u32vector?) (n integer?) ) ⟹ u32vector?
(scheme vector u32) procedure (u32vector-drop-right (u32vec u32vector?) (n integer?) ) ⟹ u32vector?
Returns a u32vector containing all except the first/last n elements of u32vec.
(scheme vector u32) procedure (u32vector-segment (u32vec u32vector?) (n integer?) ) ⟹ list?
Returns a list of u32vectors, each of which contains n consecutive elements of u32vec. The last u32vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector u32) procedure (u32vector-fold (kons procedure?) knil (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ *
(kons state (obj1 u32?) (obj2 u32?) ... ) ⟹ *
(scheme vector u32) procedure (u32vector-fold-right (kons procedure?) knil (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ *
(kons state (obj1 u32?) (obj2 u32?) ... ) ⟹ *
When one u32vector argument u32vec is given, folds kons over the elements of u32vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple u32vector arguments are given, kons is called with the current state value and each value from all the vectors; u32vector-fold scans elements from left to right, while u32vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector u32) procedure (u32vector-map (proc procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ vector?
(proc (val1 u32?) ... ) ⟹ *
(scheme vector u32) procedure (u32vector-map! (proc procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ undefined
(proc (val1 u32?) ... ) ⟹ *
(scheme vector u32) procedure (u32vector-for-each (proc procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ undefined
(proc (val1 u32?) ... ) ⟹ undefined
Iterate over the elements of u32vec and apply f to each, returning respectively a u32vector of the results, an undefined value with the results placed back in u32vec, and an undefined value with no change to u32vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For u32vector-map!, only u32vec is modified even when multiple vectors are passed.
If u32vector-map or u32vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector u32) procedure (u32vector-count (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer?
(pred? (val1 u32?) (val2 u32?) ... ) ⟹ *
Call pred? on each element of u32vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector u32) procedure (u32vector-cumulate (f procedure?) knil (u32vec u32vector?) ) ⟹ u32vector?
(f state (value u32?) ) ⟹ *
Like u32vector-fold, but returns an u32vector of partial results rather than just the final result.
(scheme vector u32) procedure (u32vector-take-while (pred? procedure?) (u32vec u32vector?) ) ⟹ u32vector?
(pred? (value u32?) ) ⟹ boolean?
(scheme vector u32) procedure (u32vector-take-while-right (pred? procedure?) (u32vec u32vector?) ) ⟹ u32vector?
(pred? (value u32?) ) ⟹ boolean?
Return the shortest prefix/suffix of u32vec all of whose elements satisfy pred?.
(scheme vector u32) procedure (u32vector-drop-while (pred? procedure?) (u32vec u32vector?) ) ⟹ u32vector?
(pred? (value u32?) ) ⟹ boolean?
(scheme vector u32) procedure (u32vector-drop-while-right (pred? procedure?) (u32vec u32vector?) ) ⟹ u32vector?
(pred? (value u32?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of u32vec such that all its elements satisfy pred.
(scheme vector u32) procedure (u32vector-index (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u32?) (value2 u32?) ... ) ⟹ *
(scheme vector u32) procedure (u32vector-index-right (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u32?) (value2 u32?) ... ) ⟹ *
Return the index of the first/last element of u32vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u32vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for u32vector-index-right.
(scheme vector u32) procedure (u32vector-skip (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u32?) (value2 u32?) ... ) ⟹ *
(scheme vector u32) procedure (u32vector-skip-right (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u32?) (value2 u32?) ... ) ⟹ *
Returns the index of the first/last element of u32vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u32vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for u32vector-skip-right.
(scheme vector u32) procedure (u32vector-any (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ *
(pred? (val1 u32?) (val2 u32?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the u32vec, or #f if there is no such element. If u32vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector u32) procedure (u32vector-every (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ *
(pred? (val1 u32?) (val2 u32?) ... ) ⟹ *
If all elements from u32vec satisfy pred?, return the last result of pred?. If not all do, return #f. If u32vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector u32) procedure (u32vector-partition (pred? procedure?) (u32vec u32vector?) ) ⟹ (values u32vector?integer?)
(pred? (value u32?) ) ⟹ boolean?
Returns an u32vector of the same type as u32vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new u32vector and the number of elements satisfying pred?.
(scheme vector u32) procedure (u32vector-filter (pred? procedure?) (u32vec1 u32vector?) ) ⟹ u32vector?
(pred? (val u32?) ) ⟹ boolean?
(scheme vector u32) procedure (u32vector-remove (pred? procedure?) (u32vec1 u32vector?) ) ⟹ u32vector?
(pred? (val u32?) ) ⟹ boolean?
Return an u32vector containing the elements of u32vec that satisfy / do not satisfy pred?.
(scheme vector u32) procedure (u32vector-swap! (u32vec u32vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of u32vec.
(scheme vector u32) procedure (u32vector-fill! (u32vec u32vector?) (fill u32?) ) ⟹ undefined
(scheme vector u32) procedure (u32vector-fill! (u32vec u32vector?) (fill u32?) (start integer?) ) ⟹ undefined
(scheme vector u32) procedure (u32vector-fill! (u32vec u32vector?) (fill u32?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of u32vec from start to end with the value fill.
(scheme vector u32) procedure (u32vector-reverse! (u32vec u32vector?) ) ⟹ undefined
(scheme vector u32) procedure (u32vector-reverse! (u32vec u32vector?) (start integer?) ) ⟹ undefined
(scheme vector u32) procedure (u32vector-reverse! (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of u32vec from start to end.
(scheme vector u32) procedure (u32vector-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) ) ⟹ undefined
(scheme vector u32) procedure (u32vector-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) (start integer?) ) ⟹ undefined
(scheme vector u32) procedure (u32vector-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of u32from from start to end onto u32to, starting at index at.
(scheme vector u32) procedure (u32vector-reverse-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) ) ⟹ undefined
(scheme vector u32) procedure (u32vector-reverse-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) (start integer?) ) ⟹ undefined
(scheme vector u32) procedure (u32vector-reverse-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as u32vector-copy!, but copies in reverse
(scheme vector u32) procedure (u32vector-unfold! (f procedure?) (u32vec u32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like u32vector-unfold, but the elements are copied into the vector u32vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector u32) procedure (u32vector-unfold-right! (f procedure?) (u32vec u32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as u32vector-unfold!, but initializes the u32vector from right to left.
(scheme vector u32) procedure (reverse-u32vector->list (u32vec u32vector?) ) ⟹ list?
(scheme vector u32) procedure (reverse-u32vector->list (u32vec u32vector?) (start integer?) ) ⟹ list?
(scheme vector u32) procedure (reverse-u32vector->list (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u32vec in reverse order.
(scheme vector u32) procedure (reverse-list->u32vector (proper-list list?) ) ⟹ u32vector?
Returns u32vector with same elements as list in reverse order.
(scheme vector u32) procedure (u32vector->vector (u32vec u32vector?) ) ⟹ vector?
(scheme vector u32) procedure (u32vector->vector (u32vec u32vector?) (start integer?) ) ⟹ vector?
(scheme vector u32) procedure (u32vector->vector (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as u32vec.
(scheme vector u32) procedure (vector->u32vector (vec vector?) ) ⟹ u32vector?
(scheme vector u32) procedure (vector->u32vector (vec vector?) (start integer?) ) ⟹ u32vector?
(scheme vector u32) procedure (vector->u32vector (vec vector?) (start integer?) (end integer?) ) ⟹ u32vector?
Returns u32vector with same elements as vec.
(scheme vector u32) procedure (make-u32vector-generator (u32vector u32vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / u32? /
Returns a SRFI 121 generator that generates all the values of u32vector in order. Note that the generator is finite.
u32vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of u32vector.
(scheme vector u32) procedure (write-u32vector (u32vec u32vector) ) ⟹ undefined
(scheme vector u32) procedure (write-u32vector (u32vec u32vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of u32vec in the lexical syntax explained below.
library (scheme vector s32)
(scheme vector s32) procedure (make-s32vector (size integer?) ) ⟹ s32vector?
(scheme vector s32) procedure (make-s32vector (size integer?) (fill s32?) ) ⟹ s32vector?
Returns a s32vector whose length is size. If fill is provided, all the elements of the s32vector are initialized to it.
(scheme vector s32) procedure (s32vector (value s32?) ... ) ⟹ s32vector?
Returns a s32vector initialized with values.
(scheme vector s32) procedure (s32vector? obj ) ⟹ boolean?
Returns #t if obj is a s32vector, and #f otherwise.
(scheme vector s32) procedure (s32vector-length (s32vec s32vector?) ) ⟹ integer?
Returns the length of s32vec
(scheme vector s32) procedure (s32vector-ref (s32vec s32vector?) (i integer?) ) ⟹ s32?
Returns the ith element of s32vec.
(scheme vector s32) procedure (s32vector-set! (s32vec s32vector?) (i integer?) (value s32?) ) ⟹ undefined
Sets the ith element of s32vec to value.
(scheme vector s32) procedure (s32vector->list (s32vec s32vector?) ) ⟹ list?
(scheme vector s32) procedure (s32vector->list (s32vec s32vector?) (start integer?) ) ⟹ list?
(scheme vector s32) procedure (s32vector->list (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s32vec
(scheme vector s32) procedure (list->s32vector (proper-list list?) ) ⟹ s32vector?
proper-list ⟹ (list s32? )
Returns s32vector with same elements as list.
(scheme vector s32) procedure (s32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s32vector (ie., signed exact integer in the range -(2^31) to (2^31)-1), and #f otherwise.
(scheme vector s32) procedure (s32vector-unfold (f procedure?) (length integer?) seed ) ⟹ s32vector?
(scheme vector s32) procedure (s32vector-unfold (f procedure?) (length integer?) seed ) ⟹ s32vector?
(f (index integer?) state ) ⟹ (values s32?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector s32) procedure (s32vector-copy (s32vec s32vector?) ) ⟹ s32vector?
(scheme vector s32) procedure (s32vector-copy (s32vec s32vector?) (start integer?) ) ⟹ s32vector?
(scheme vector s32) procedure (s32vector-copy (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ s32vector?
Makes a copy of the portion of s32vec from start to end and returns it.
(scheme vector s32) procedure (s32vector-reverse-copy (s32vec s32vector?) ) ⟹ s32vector?
(scheme vector s32) procedure (s32vector-reverse-copy (s32vec s32vector?) (start integer?) ) ⟹ s32vector?
(scheme vector s32) procedure (s32vector-reverse-copy (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ s32vector?
The same as s32vector-copy, but in reverse order.
(scheme vector s32) procedure (s32vector-append (s32vec s32vector?) ... ) ⟹ s32vector?
Returns a s32vector containing all the elements of the s32vecs in order.
(scheme vector s32) procedure (s32vector-concatenate (list-of-s32vectors list?) ) ⟹ s32vector?
list-of-s32vectors ⟹ (list s32vector? )
The same as s32vector-append, but takes a list of s32vectors rather than multiple arguments.
(scheme vector s32) procedure (s32vector-append-subvectors (s32vec1 s32vector?) (start1 integer?) (end1 integer?) ... ) ⟹ s32vector?
Concatenates the result of applying s32vector-copy to each triplet of s32vec, start, end arguments, but may be implemented more efficiently.
(scheme vector s32) procedure (s32vector-empty? (s32vec s32vector?) ) ⟹ boolean?
Returns #t if s32vec has a length of zero, and #f otherwise.
(scheme vector s32) procedure (s32vector= (s32vec s32vector?) ... ) ⟹ boolean?
Compares the s32vecs for elementwise equality, using = to do the comparisons. Returns #f unless all s32vectors are the same length.
(scheme vector s32) procedure (s32vector-take (s32vec s32vector?) (n integer?) ) ⟹ s32vector?
(scheme vector s32) procedure (s32vector-take-right (s32vec s32vector?) (n integer?) ) ⟹ s32vector?
Returns a s32vector containing the first/last n elements of s32vec.
(scheme vector s32) procedure (s32vector-drop (s32vec s32vector?) (n integer?) ) ⟹ s32vector?
(scheme vector s32) procedure (s32vector-drop-right (s32vec s32vector?) (n integer?) ) ⟹ s32vector?
Returns a s32vector containing all except the first/last n elements of s32vec.
(scheme vector s32) procedure (s32vector-segment (s32vec s32vector?) (n integer?) ) ⟹ list?
Returns a list of s32vectors, each of which contains n consecutive elements of s32vec. The last s32vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector s32) procedure (s32vector-fold (kons procedure?) knil (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ *
(kons state (obj1 s32?) (obj2 s32?) ... ) ⟹ *
(scheme vector s32) procedure (s32vector-fold-right (kons procedure?) knil (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ *
(kons state (obj1 s32?) (obj2 s32?) ... ) ⟹ *
When one s32vector argument s32vec is given, folds kons over the elements of s32vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple s32vector arguments are given, kons is called with the current state value and each value from all the vectors; s32vector-fold scans elements from left to right, while s32vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector s32) procedure (s32vector-map (proc procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ vector?
(proc (val1 s32?) ... ) ⟹ *
(scheme vector s32) procedure (s32vector-map! (proc procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ undefined
(proc (val1 s32?) ... ) ⟹ *
(scheme vector s32) procedure (s32vector-for-each (proc procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ undefined
(proc (val1 s32?) ... ) ⟹ undefined
Iterate over the elements of s32vec and apply f to each, returning respectively a s32vector of the results, an undefined value with the results placed back in s32vec, and an undefined value with no change to s32vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For s32vector-map!, only s32vec is modified even when multiple vectors are passed.
If s32vector-map or s32vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector s32) procedure (s32vector-count (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer?
(pred? (val1 s32?) (val2 s32?) ... ) ⟹ *
Call pred? on each element of s32vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector s32) procedure (s32vector-cumulate (f procedure?) knil (s32vec s32vector?) ) ⟹ s32vector?
(f state (value s32?) ) ⟹ *
Like s32vector-fold, but returns an s32vector of partial results rather than just the final result.
(scheme vector s32) procedure (s32vector-take-while (pred? procedure?) (s32vec s32vector?) ) ⟹ s32vector?
(pred? (value s32?) ) ⟹ boolean?
(scheme vector s32) procedure (s32vector-take-while-right (pred? procedure?) (s32vec s32vector?) ) ⟹ s32vector?
(pred? (value s32?) ) ⟹ boolean?
Return the shortest prefix/suffix of s32vec all of whose elements satisfy pred?.
(scheme vector s32) procedure (s32vector-drop-while (pred? procedure?) (s32vec s32vector?) ) ⟹ s32vector?
(pred? (value s32?) ) ⟹ boolean?
(scheme vector s32) procedure (s32vector-drop-while-right (pred? procedure?) (s32vec s32vector?) ) ⟹ s32vector?
(pred? (value s32?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of s32vec such that all its elements satisfy pred.
(scheme vector s32) procedure (s32vector-index (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s32?) (value2 s32?) ... ) ⟹ *
(scheme vector s32) procedure (s32vector-index-right (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s32?) (value2 s32?) ... ) ⟹ *
Return the index of the first/last element of s32vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s32vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for s32vector-index-right.
(scheme vector s32) procedure (s32vector-skip (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s32?) (value2 s32?) ... ) ⟹ *
(scheme vector s32) procedure (s32vector-skip-right (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s32?) (value2 s32?) ... ) ⟹ *
Returns the index of the first/last element of s32vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s32vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for s32vector-skip-right.
(scheme vector s32) procedure (s32vector-any (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ *
(pred? (val1 s32?) (val2 s32?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the s32vec, or #f if there is no such element. If s32vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector s32) procedure (s32vector-every (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ *
(pred? (val1 s32?) (val2 s32?) ... ) ⟹ *
If all elements from s32vec satisfy pred?, return the last result of pred?. If not all do, return #f. If s32vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector s32) procedure (s32vector-partition (pred? procedure?) (s32vec s32vector?) ) ⟹ (values s32vector?integer?)
(pred? (value s32?) ) ⟹ boolean?
Returns an s32vector of the same type as s32vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new s32vector and the number of elements satisfying pred?.
(scheme vector s32) procedure (s32vector-filter (pred? procedure?) (s32vec1 s32vector?) ) ⟹ s32vector?
(pred? (val s32?) ) ⟹ boolean?
(scheme vector s32) procedure (s32vector-remove (pred? procedure?) (s32vec1 s32vector?) ) ⟹ s32vector?
(pred? (val s32?) ) ⟹ boolean?
Return an s32vector containing the elements of s32vec that satisfy / do not satisfy pred?.
(scheme vector s32) procedure (s32vector-swap! (s32vec s32vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of s32vec.
(scheme vector s32) procedure (s32vector-fill! (s32vec s32vector?) (fill s32?) ) ⟹ undefined
(scheme vector s32) procedure (s32vector-fill! (s32vec s32vector?) (fill s32?) (start integer?) ) ⟹ undefined
(scheme vector s32) procedure (s32vector-fill! (s32vec s32vector?) (fill s32?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of s32vec from start to end with the value fill.
(scheme vector s32) procedure (s32vector-reverse! (s32vec s32vector?) ) ⟹ undefined
(scheme vector s32) procedure (s32vector-reverse! (s32vec s32vector?) (start integer?) ) ⟹ undefined
(scheme vector s32) procedure (s32vector-reverse! (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of s32vec from start to end.
(scheme vector s32) procedure (s32vector-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) ) ⟹ undefined
(scheme vector s32) procedure (s32vector-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) (start integer?) ) ⟹ undefined
(scheme vector s32) procedure (s32vector-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of s32from from start to end onto s32to, starting at index at.
(scheme vector s32) procedure (s32vector-reverse-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) ) ⟹ undefined
(scheme vector s32) procedure (s32vector-reverse-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) (start integer?) ) ⟹ undefined
(scheme vector s32) procedure (s32vector-reverse-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as s32vector-copy!, but copies in reverse
(scheme vector s32) procedure (s32vector-unfold! (f procedure?) (s32vec s32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like s32vector-unfold, but the elements are copied into the vector s32vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector s32) procedure (s32vector-unfold-right! (f procedure?) (s32vec s32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as s32vector-unfold!, but initializes the s32vector from right to left.
(scheme vector s32) procedure (reverse-s32vector->list (s32vec s32vector?) ) ⟹ list?
(scheme vector s32) procedure (reverse-s32vector->list (s32vec s32vector?) (start integer?) ) ⟹ list?
(scheme vector s32) procedure (reverse-s32vector->list (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s32vec in reverse order.
(scheme vector s32) procedure (reverse-list->s32vector (proper-list list?) ) ⟹ s32vector?
Returns s32vector with same elements as list in reverse order.
(scheme vector s32) procedure (s32vector->vector (s32vec s32vector?) ) ⟹ vector?
(scheme vector s32) procedure (s32vector->vector (s32vec s32vector?) (start integer?) ) ⟹ vector?
(scheme vector s32) procedure (s32vector->vector (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as s32vec.
(scheme vector s32) procedure (vector->s32vector (vec vector?) ) ⟹ s32vector?
(scheme vector s32) procedure (vector->s32vector (vec vector?) (start integer?) ) ⟹ s32vector?
(scheme vector s32) procedure (vector->s32vector (vec vector?) (start integer?) (end integer?) ) ⟹ s32vector?
Returns s32vector with same elements as vec.
(scheme vector s32) procedure (make-s32vector-generator (s32vector s32vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / s32? /
Returns a SRFI 121 generator that generates all the values of s32vector in order. Note that the generator is finite.
s32vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of s32vector.
(scheme vector s32) procedure (write-s32vector (s32vec s32vector) ) ⟹ undefined
(scheme vector s32) procedure (write-s32vector (s32vec s32vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of s32vec in the lexical syntax explained below.
library (scheme vector u64)
(scheme vector u64) procedure (make-u64vector (size integer?) ) ⟹ u64vector?
(scheme vector u64) procedure (make-u64vector (size integer?) (fill u64?) ) ⟹ u64vector?
Returns a u64vector whose length is size. If fill is provided, all the elements of the u64vector are initialized to it.
(scheme vector u64) procedure (u64vector (value u64?) ... ) ⟹ u64vector?
Returns a u64vector initialized with values.
(scheme vector u64) procedure (u64vector? obj ) ⟹ boolean?
Returns #t if obj is a u64vector, and #f otherwise.
(scheme vector u64) procedure (u64vector-length (u64vec u64vector?) ) ⟹ integer?
Returns the length of u64vec
(scheme vector u64) procedure (u64vector-ref (u64vec u64vector?) (i integer?) ) ⟹ u64?
Returns the ith element of u64vec.
(scheme vector u64) procedure (u64vector-set! (u64vec u64vector?) (i integer?) (value u64?) ) ⟹ undefined
Sets the ith element of u64vec to value.
(scheme vector u64) procedure (u64vector->list (u64vec u64vector?) ) ⟹ list?
(scheme vector u64) procedure (u64vector->list (u64vec u64vector?) (start integer?) ) ⟹ list?
(scheme vector u64) procedure (u64vector->list (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u64vec
(scheme vector u64) procedure (list->u64vector (proper-list list?) ) ⟹ u64vector?
proper-list ⟹ (list u64? )
Returns u64vector with same elements as list.
(scheme vector u64) procedure (u64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u64vector (ie., unsigned exact integer in the range 0 to (2^64)-1), and #f otherwise.
(scheme vector u64) procedure (u64vector-unfold (f procedure?) (length integer?) seed ) ⟹ u64vector?
(scheme vector u64) procedure (u64vector-unfold (f procedure?) (length integer?) seed ) ⟹ u64vector?
(f (index integer?) state ) ⟹ (values u64?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector u64) procedure (u64vector-copy (u64vec u64vector?) ) ⟹ u64vector?
(scheme vector u64) procedure (u64vector-copy (u64vec u64vector?) (start integer?) ) ⟹ u64vector?
(scheme vector u64) procedure (u64vector-copy (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ u64vector?
Makes a copy of the portion of u64vec from start to end and returns it.
(scheme vector u64) procedure (u64vector-reverse-copy (u64vec u64vector?) ) ⟹ u64vector?
(scheme vector u64) procedure (u64vector-reverse-copy (u64vec u64vector?) (start integer?) ) ⟹ u64vector?
(scheme vector u64) procedure (u64vector-reverse-copy (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ u64vector?
The same as u64vector-copy, but in reverse order.
(scheme vector u64) procedure (u64vector-append (u64vec u64vector?) ... ) ⟹ u64vector?
Returns a u64vector containing all the elements of the u64vecs in order.
(scheme vector u64) procedure (u64vector-concatenate (list-of-u64vectors list?) ) ⟹ u64vector?
list-of-u64vectors ⟹ (list u64vector? )
The same as u64vector-append, but takes a list of u64vectors rather than multiple arguments.
(scheme vector u64) procedure (u64vector-append-subvectors (u64vec1 u64vector?) (start1 integer?) (end1 integer?) ... ) ⟹ u64vector?
Concatenates the result of applying u64vector-copy to each triplet of u64vec, start, end arguments, but may be implemented more efficiently.
(scheme vector u64) procedure (u64vector-empty? (u64vec u64vector?) ) ⟹ boolean?
Returns #t if u64vec has a length of zero, and #f otherwise.
(scheme vector u64) procedure (u64vector= (u64vec u64vector?) ... ) ⟹ boolean?
Compares the u64vecs for elementwise equality, using = to do the comparisons. Returns #f unless all u64vectors are the same length.
(scheme vector u64) procedure (u64vector-take (u64vec u64vector?) (n integer?) ) ⟹ u64vector?
(scheme vector u64) procedure (u64vector-take-right (u64vec u64vector?) (n integer?) ) ⟹ u64vector?
Returns a u64vector containing the first/last n elements of u64vec.
(scheme vector u64) procedure (u64vector-drop (u64vec u64vector?) (n integer?) ) ⟹ u64vector?
(scheme vector u64) procedure (u64vector-drop-right (u64vec u64vector?) (n integer?) ) ⟹ u64vector?
Returns a u64vector containing all except the first/last n elements of u64vec.
(scheme vector u64) procedure (u64vector-segment (u64vec u64vector?) (n integer?) ) ⟹ list?
Returns a list of u64vectors, each of which contains n consecutive elements of u64vec. The last u64vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector u64) procedure (u64vector-fold (kons procedure?) knil (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ *
(kons state (obj1 u64?) (obj2 u64?) ... ) ⟹ *
(scheme vector u64) procedure (u64vector-fold-right (kons procedure?) knil (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ *
(kons state (obj1 u64?) (obj2 u64?) ... ) ⟹ *
When one u64vector argument u64vec is given, folds kons over the elements of u64vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple u64vector arguments are given, kons is called with the current state value and each value from all the vectors; u64vector-fold scans elements from left to right, while u64vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector u64) procedure (u64vector-map (proc procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ vector?
(proc (val1 u64?) ... ) ⟹ *
(scheme vector u64) procedure (u64vector-map! (proc procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ undefined
(proc (val1 u64?) ... ) ⟹ *
(scheme vector u64) procedure (u64vector-for-each (proc procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ undefined
(proc (val1 u64?) ... ) ⟹ undefined
Iterate over the elements of u64vec and apply f to each, returning respectively a u64vector of the results, an undefined value with the results placed back in u64vec, and an undefined value with no change to u64vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For u64vector-map!, only u64vec is modified even when multiple vectors are passed.
If u64vector-map or u64vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector u64) procedure (u64vector-count (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer?
(pred? (val1 u64?) (val2 u64?) ... ) ⟹ *
Call pred? on each element of u64vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector u64) procedure (u64vector-cumulate (f procedure?) knil (u64vec u64vector?) ) ⟹ u64vector?
(f state (value u64?) ) ⟹ *
Like u64vector-fold, but returns an u64vector of partial results rather than just the final result.
(scheme vector u64) procedure (u64vector-take-while (pred? procedure?) (u64vec u64vector?) ) ⟹ u64vector?
(pred? (value u64?) ) ⟹ boolean?
(scheme vector u64) procedure (u64vector-take-while-right (pred? procedure?) (u64vec u64vector?) ) ⟹ u64vector?
(pred? (value u64?) ) ⟹ boolean?
Return the shortest prefix/suffix of u64vec all of whose elements satisfy pred?.
(scheme vector u64) procedure (u64vector-drop-while (pred? procedure?) (u64vec u64vector?) ) ⟹ u64vector?
(pred? (value u64?) ) ⟹ boolean?
(scheme vector u64) procedure (u64vector-drop-while-right (pred? procedure?) (u64vec u64vector?) ) ⟹ u64vector?
(pred? (value u64?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of u64vec such that all its elements satisfy pred.
(scheme vector u64) procedure (u64vector-index (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u64?) (value2 u64?) ... ) ⟹ *
(scheme vector u64) procedure (u64vector-index-right (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u64?) (value2 u64?) ... ) ⟹ *
Return the index of the first/last element of u64vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u64vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for u64vector-index-right.
(scheme vector u64) procedure (u64vector-skip (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u64?) (value2 u64?) ... ) ⟹ *
(scheme vector u64) procedure (u64vector-skip-right (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u64?) (value2 u64?) ... ) ⟹ *
Returns the index of the first/last element of u64vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u64vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for u64vector-skip-right.
(scheme vector u64) procedure (u64vector-any (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ *
(pred? (val1 u64?) (val2 u64?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the u64vec, or #f if there is no such element. If u64vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector u64) procedure (u64vector-every (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ *
(pred? (val1 u64?) (val2 u64?) ... ) ⟹ *
If all elements from u64vec satisfy pred?, return the last result of pred?. If not all do, return #f. If u64vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector u64) procedure (u64vector-partition (pred? procedure?) (u64vec u64vector?) ) ⟹ (values u64vector?integer?)
(pred? (value u64?) ) ⟹ boolean?
Returns an u64vector of the same type as u64vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new u64vector and the number of elements satisfying pred?.
(scheme vector u64) procedure (u64vector-filter (pred? procedure?) (u64vec1 u64vector?) ) ⟹ u64vector?
(pred? (val u64?) ) ⟹ boolean?
(scheme vector u64) procedure (u64vector-remove (pred? procedure?) (u64vec1 u64vector?) ) ⟹ u64vector?
(pred? (val u64?) ) ⟹ boolean?
Return an u64vector containing the elements of u64vec that satisfy / do not satisfy pred?.
(scheme vector u64) procedure (u64vector-swap! (u64vec u64vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of u64vec.
(scheme vector u64) procedure (u64vector-fill! (u64vec u64vector?) (fill u64?) ) ⟹ undefined
(scheme vector u64) procedure (u64vector-fill! (u64vec u64vector?) (fill u64?) (start integer?) ) ⟹ undefined
(scheme vector u64) procedure (u64vector-fill! (u64vec u64vector?) (fill u64?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of u64vec from start to end with the value fill.
(scheme vector u64) procedure (u64vector-reverse! (u64vec u64vector?) ) ⟹ undefined
(scheme vector u64) procedure (u64vector-reverse! (u64vec u64vector?) (start integer?) ) ⟹ undefined
(scheme vector u64) procedure (u64vector-reverse! (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of u64vec from start to end.
(scheme vector u64) procedure (u64vector-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) ) ⟹ undefined
(scheme vector u64) procedure (u64vector-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) (start integer?) ) ⟹ undefined
(scheme vector u64) procedure (u64vector-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of u64from from start to end onto u64to, starting at index at.
(scheme vector u64) procedure (u64vector-reverse-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) ) ⟹ undefined
(scheme vector u64) procedure (u64vector-reverse-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) (start integer?) ) ⟹ undefined
(scheme vector u64) procedure (u64vector-reverse-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as u64vector-copy!, but copies in reverse
(scheme vector u64) procedure (u64vector-unfold! (f procedure?) (u64vec u64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like u64vector-unfold, but the elements are copied into the vector u64vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector u64) procedure (u64vector-unfold-right! (f procedure?) (u64vec u64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as u64vector-unfold!, but initializes the u64vector from right to left.
(scheme vector u64) procedure (reverse-u64vector->list (u64vec u64vector?) ) ⟹ list?
(scheme vector u64) procedure (reverse-u64vector->list (u64vec u64vector?) (start integer?) ) ⟹ list?
(scheme vector u64) procedure (reverse-u64vector->list (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u64vec in reverse order.
(scheme vector u64) procedure (reverse-list->u64vector (proper-list list?) ) ⟹ u64vector?
Returns u64vector with same elements as list in reverse order.
(scheme vector u64) procedure (u64vector->vector (u64vec u64vector?) ) ⟹ vector?
(scheme vector u64) procedure (u64vector->vector (u64vec u64vector?) (start integer?) ) ⟹ vector?
(scheme vector u64) procedure (u64vector->vector (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as u64vec.
(scheme vector u64) procedure (vector->u64vector (vec vector?) ) ⟹ u64vector?
(scheme vector u64) procedure (vector->u64vector (vec vector?) (start integer?) ) ⟹ u64vector?
(scheme vector u64) procedure (vector->u64vector (vec vector?) (start integer?) (end integer?) ) ⟹ u64vector?
Returns u64vector with same elements as vec.
(scheme vector u64) procedure (make-u64vector-generator (u64vector u64vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / u64? /
Returns a SRFI 121 generator that generates all the values of u64vector in order. Note that the generator is finite.
u64vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of u64vector.
(scheme vector u64) procedure (write-u64vector (u64vec u64vector) ) ⟹ undefined
(scheme vector u64) procedure (write-u64vector (u64vec u64vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of u64vec in the lexical syntax explained below.
library (scheme vector s64)
(scheme vector s64) procedure (make-s64vector (size integer?) ) ⟹ s64vector?
(scheme vector s64) procedure (make-s64vector (size integer?) (fill s64?) ) ⟹ s64vector?
Returns a s64vector whose length is size. If fill is provided, all the elements of the s64vector are initialized to it.
(scheme vector s64) procedure (s64vector (value s64?) ... ) ⟹ s64vector?
Returns a s64vector initialized with values.
(scheme vector s64) procedure (s64vector? obj ) ⟹ boolean?
Returns #t if obj is a s64vector, and #f otherwise.
(scheme vector s64) procedure (s64vector-length (s64vec s64vector?) ) ⟹ integer?
Returns the length of s64vec
(scheme vector s64) procedure (s64vector-ref (s64vec s64vector?) (i integer?) ) ⟹ s64?
Returns the ith element of s64vec.
(scheme vector s64) procedure (s64vector-set! (s64vec s64vector?) (i integer?) (value s64?) ) ⟹ undefined
Sets the ith element of s64vec to value.
(scheme vector s64) procedure (s64vector->list (s64vec s64vector?) ) ⟹ list?
(scheme vector s64) procedure (s64vector->list (s64vec s64vector?) (start integer?) ) ⟹ list?
(scheme vector s64) procedure (s64vector->list (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s64vec
(scheme vector s64) procedure (list->s64vector (proper-list list?) ) ⟹ s64vector?
proper-list ⟹ (list s64? )
Returns s64vector with same elements as list.
(scheme vector s64) procedure (s64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s64vector (ie., signed exact integer in the range -(2^63) to (2^63)-1), and #f otherwise.
(scheme vector s64) procedure (s64vector-unfold (f procedure?) (length integer?) seed ) ⟹ s64vector?
(scheme vector s64) procedure (s64vector-unfold (f procedure?) (length integer?) seed ) ⟹ s64vector?
(f (index integer?) state ) ⟹ (values s64?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector s64) procedure (s64vector-copy (s64vec s64vector?) ) ⟹ s64vector?
(scheme vector s64) procedure (s64vector-copy (s64vec s64vector?) (start integer?) ) ⟹ s64vector?
(scheme vector s64) procedure (s64vector-copy (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ s64vector?
Makes a copy of the portion of s64vec from start to end and returns it.
(scheme vector s64) procedure (s64vector-reverse-copy (s64vec s64vector?) ) ⟹ s64vector?
(scheme vector s64) procedure (s64vector-reverse-copy (s64vec s64vector?) (start integer?) ) ⟹ s64vector?
(scheme vector s64) procedure (s64vector-reverse-copy (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ s64vector?
The same as s64vector-copy, but in reverse order.
(scheme vector s64) procedure (s64vector-append (s64vec s64vector?) ... ) ⟹ s64vector?
Returns a s64vector containing all the elements of the s64vecs in order.
(scheme vector s64) procedure (s64vector-concatenate (list-of-s64vectors list?) ) ⟹ s64vector?
list-of-s64vectors ⟹ (list s64vector? )
The same as s64vector-append, but takes a list of s64vectors rather than multiple arguments.
(scheme vector s64) procedure (s64vector-append-subvectors (s64vec1 s64vector?) (start1 integer?) (end1 integer?) ... ) ⟹ s64vector?
Concatenates the result of applying s64vector-copy to each triplet of s64vec, start, end arguments, but may be implemented more efficiently.
(scheme vector s64) procedure (s64vector-empty? (s64vec s64vector?) ) ⟹ boolean?
Returns #t if s64vec has a length of zero, and #f otherwise.
(scheme vector s64) procedure (s64vector= (s64vec s64vector?) ... ) ⟹ boolean?
Compares the s64vecs for elementwise equality, using = to do the comparisons. Returns #f unless all s64vectors are the same length.
(scheme vector s64) procedure (s64vector-take (s64vec s64vector?) (n integer?) ) ⟹ s64vector?
(scheme vector s64) procedure (s64vector-take-right (s64vec s64vector?) (n integer?) ) ⟹ s64vector?
Returns a s64vector containing the first/last n elements of s64vec.
(scheme vector s64) procedure (s64vector-drop (s64vec s64vector?) (n integer?) ) ⟹ s64vector?
(scheme vector s64) procedure (s64vector-drop-right (s64vec s64vector?) (n integer?) ) ⟹ s64vector?
Returns a s64vector containing all except the first/last n elements of s64vec.
(scheme vector s64) procedure (s64vector-segment (s64vec s64vector?) (n integer?) ) ⟹ list?
Returns a list of s64vectors, each of which contains n consecutive elements of s64vec. The last s64vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector s64) procedure (s64vector-fold (kons procedure?) knil (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ *
(kons state (obj1 s64?) (obj2 s64?) ... ) ⟹ *
(scheme vector s64) procedure (s64vector-fold-right (kons procedure?) knil (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ *
(kons state (obj1 s64?) (obj2 s64?) ... ) ⟹ *
When one s64vector argument s64vec is given, folds kons over the elements of s64vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple s64vector arguments are given, kons is called with the current state value and each value from all the vectors; s64vector-fold scans elements from left to right, while s64vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector s64) procedure (s64vector-map (proc procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ vector?
(proc (val1 s64?) ... ) ⟹ *
(scheme vector s64) procedure (s64vector-map! (proc procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ undefined
(proc (val1 s64?) ... ) ⟹ *
(scheme vector s64) procedure (s64vector-for-each (proc procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ undefined
(proc (val1 s64?) ... ) ⟹ undefined
Iterate over the elements of s64vec and apply f to each, returning respectively a s64vector of the results, an undefined value with the results placed back in s64vec, and an undefined value with no change to s64vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For s64vector-map!, only s64vec is modified even when multiple vectors are passed.
If s64vector-map or s64vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector s64) procedure (s64vector-count (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer?
(pred? (val1 s64?) (val2 s64?) ... ) ⟹ *
Call pred? on each element of s64vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector s64) procedure (s64vector-cumulate (f procedure?) knil (s64vec s64vector?) ) ⟹ s64vector?
(f state (value s64?) ) ⟹ *
Like s64vector-fold, but returns an s64vector of partial results rather than just the final result.
(scheme vector s64) procedure (s64vector-take-while (pred? procedure?) (s64vec s64vector?) ) ⟹ s64vector?
(pred? (value s64?) ) ⟹ boolean?
(scheme vector s64) procedure (s64vector-take-while-right (pred? procedure?) (s64vec s64vector?) ) ⟹ s64vector?
(pred? (value s64?) ) ⟹ boolean?
Return the shortest prefix/suffix of s64vec all of whose elements satisfy pred?.
(scheme vector s64) procedure (s64vector-drop-while (pred? procedure?) (s64vec s64vector?) ) ⟹ s64vector?
(pred? (value s64?) ) ⟹ boolean?
(scheme vector s64) procedure (s64vector-drop-while-right (pred? procedure?) (s64vec s64vector?) ) ⟹ s64vector?
(pred? (value s64?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of s64vec such that all its elements satisfy pred.
(scheme vector s64) procedure (s64vector-index (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s64?) (value2 s64?) ... ) ⟹ *
(scheme vector s64) procedure (s64vector-index-right (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s64?) (value2 s64?) ... ) ⟹ *
Return the index of the first/last element of s64vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s64vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for s64vector-index-right.
(scheme vector s64) procedure (s64vector-skip (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s64?) (value2 s64?) ... ) ⟹ *
(scheme vector s64) procedure (s64vector-skip-right (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s64?) (value2 s64?) ... ) ⟹ *
Returns the index of the first/last element of s64vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s64vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for s64vector-skip-right.
(scheme vector s64) procedure (s64vector-any (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ *
(pred? (val1 s64?) (val2 s64?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the s64vec, or #f if there is no such element. If s64vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector s64) procedure (s64vector-every (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ *
(pred? (val1 s64?) (val2 s64?) ... ) ⟹ *
If all elements from s64vec satisfy pred?, return the last result of pred?. If not all do, return #f. If s64vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector s64) procedure (s64vector-partition (pred? procedure?) (s64vec s64vector?) ) ⟹ (values s64vector?integer?)
(pred? (value s64?) ) ⟹ boolean?
Returns an s64vector of the same type as s64vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new s64vector and the number of elements satisfying pred?.
(scheme vector s64) procedure (s64vector-filter (pred? procedure?) (s64vec1 s64vector?) ) ⟹ s64vector?
(pred? (val s64?) ) ⟹ boolean?
(scheme vector s64) procedure (s64vector-remove (pred? procedure?) (s64vec1 s64vector?) ) ⟹ s64vector?
(pred? (val s64?) ) ⟹ boolean?
Return an s64vector containing the elements of s64vec that satisfy / do not satisfy pred?.
(scheme vector s64) procedure (s64vector-swap! (s64vec s64vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of s64vec.
(scheme vector s64) procedure (s64vector-fill! (s64vec s64vector?) (fill s64?) ) ⟹ undefined
(scheme vector s64) procedure (s64vector-fill! (s64vec s64vector?) (fill s64?) (start integer?) ) ⟹ undefined
(scheme vector s64) procedure (s64vector-fill! (s64vec s64vector?) (fill s64?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of s64vec from start to end with the value fill.
(scheme vector s64) procedure (s64vector-reverse! (s64vec s64vector?) ) ⟹ undefined
(scheme vector s64) procedure (s64vector-reverse! (s64vec s64vector?) (start integer?) ) ⟹ undefined
(scheme vector s64) procedure (s64vector-reverse! (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of s64vec from start to end.
(scheme vector s64) procedure (s64vector-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) ) ⟹ undefined
(scheme vector s64) procedure (s64vector-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) (start integer?) ) ⟹ undefined
(scheme vector s64) procedure (s64vector-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of s64from from start to end onto s64to, starting at index at.
(scheme vector s64) procedure (s64vector-reverse-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) ) ⟹ undefined
(scheme vector s64) procedure (s64vector-reverse-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) (start integer?) ) ⟹ undefined
(scheme vector s64) procedure (s64vector-reverse-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as s64vector-copy!, but copies in reverse
(scheme vector s64) procedure (s64vector-unfold! (f procedure?) (s64vec s64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like s64vector-unfold, but the elements are copied into the vector s64vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector s64) procedure (s64vector-unfold-right! (f procedure?) (s64vec s64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as s64vector-unfold!, but initializes the s64vector from right to left.
(scheme vector s64) procedure (reverse-s64vector->list (s64vec s64vector?) ) ⟹ list?
(scheme vector s64) procedure (reverse-s64vector->list (s64vec s64vector?) (start integer?) ) ⟹ list?
(scheme vector s64) procedure (reverse-s64vector->list (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s64vec in reverse order.
(scheme vector s64) procedure (reverse-list->s64vector (proper-list list?) ) ⟹ s64vector?
Returns s64vector with same elements as list in reverse order.
(scheme vector s64) procedure (s64vector->vector (s64vec s64vector?) ) ⟹ vector?
(scheme vector s64) procedure (s64vector->vector (s64vec s64vector?) (start integer?) ) ⟹ vector?
(scheme vector s64) procedure (s64vector->vector (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as s64vec.
(scheme vector s64) procedure (vector->s64vector (vec vector?) ) ⟹ s64vector?
(scheme vector s64) procedure (vector->s64vector (vec vector?) (start integer?) ) ⟹ s64vector?
(scheme vector s64) procedure (vector->s64vector (vec vector?) (start integer?) (end integer?) ) ⟹ s64vector?
Returns s64vector with same elements as vec.
(scheme vector s64) procedure (make-s64vector-generator (s64vector s64vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / s64? /
Returns a SRFI 121 generator that generates all the values of s64vector in order. Note that the generator is finite.
s64vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of s64vector.
(scheme vector s64) procedure (write-s64vector (s64vec s64vector) ) ⟹ undefined
(scheme vector s64) procedure (write-s64vector (s64vec s64vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of s64vec in the lexical syntax explained below.
library (scheme vector f32)
(scheme vector f32) procedure (make-f32vector (size integer?) ) ⟹ f32vector?
(scheme vector f32) procedure (make-f32vector (size integer?) (fill f32?) ) ⟹ f32vector?
Returns a f32vector whose length is size. If fill is provided, all the elements of the f32vector are initialized to it.
(scheme vector f32) procedure (f32vector (value f32?) ... ) ⟹ f32vector?
Returns a f32vector initialized with values.
(scheme vector f32) procedure (f32vector? obj ) ⟹ boolean?
Returns #t if obj is a f32vector, and #f otherwise.
(scheme vector f32) procedure (f32vector-length (f32vec f32vector?) ) ⟹ integer?
Returns the length of f32vec
(scheme vector f32) procedure (f32vector-ref (f32vec f32vector?) (i integer?) ) ⟹ f32?
Returns the ith element of f32vec.
(scheme vector f32) procedure (f32vector-set! (f32vec f32vector?) (i integer?) (value f32?) ) ⟹ undefined
Sets the ith element of f32vec to value.
(scheme vector f32) procedure (f32vector->list (f32vec f32vector?) ) ⟹ list?
(scheme vector f32) procedure (f32vector->list (f32vec f32vector?) (start integer?) ) ⟹ list?
(scheme vector f32) procedure (f32vector->list (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f32vec
(scheme vector f32) procedure (list->f32vector (proper-list list?) ) ⟹ f32vector?
proper-list ⟹ (list f32? )
Returns f32vector with same elements as list.
(scheme vector f32) procedure (f32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an f32vector (ie., inexact real), and #f otherwise.
(scheme vector f32) procedure (f32vector-unfold (f procedure?) (length integer?) seed ) ⟹ f32vector?
(scheme vector f32) procedure (f32vector-unfold (f procedure?) (length integer?) seed ) ⟹ f32vector?
(f (index integer?) state ) ⟹ (values f32?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector f32) procedure (f32vector-copy (f32vec f32vector?) ) ⟹ f32vector?
(scheme vector f32) procedure (f32vector-copy (f32vec f32vector?) (start integer?) ) ⟹ f32vector?
(scheme vector f32) procedure (f32vector-copy (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ f32vector?
Makes a copy of the portion of f32vec from start to end and returns it.
(scheme vector f32) procedure (f32vector-reverse-copy (f32vec f32vector?) ) ⟹ f32vector?
(scheme vector f32) procedure (f32vector-reverse-copy (f32vec f32vector?) (start integer?) ) ⟹ f32vector?
(scheme vector f32) procedure (f32vector-reverse-copy (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ f32vector?
The same as f32vector-copy, but in reverse order.
(scheme vector f32) procedure (f32vector-append (f32vec f32vector?) ... ) ⟹ f32vector?
Returns a f32vector containing all the elements of the f32vecs in order.
(scheme vector f32) procedure (f32vector-concatenate (list-of-f32vectors list?) ) ⟹ f32vector?
list-of-f32vectors ⟹ (list f32vector? )
The same as f32vector-append, but takes a list of f32vectors rather than multiple arguments.
(scheme vector f32) procedure (f32vector-append-subvectors (f32vec1 f32vector?) (start1 integer?) (end1 integer?) ... ) ⟹ f32vector?
Concatenates the result of applying f32vector-copy to each triplet of f32vec, start, end arguments, but may be implemented more efficiently.
(scheme vector f32) procedure (f32vector-empty? (f32vec f32vector?) ) ⟹ boolean?
Returns #t if f32vec has a length of zero, and #f otherwise.
(scheme vector f32) procedure (f32vector= (f32vec f32vector?) ... ) ⟹ boolean?
Compares the f32vecs for elementwise equality, using = to do the comparisons. Returns #f unless all f32vectors are the same length.
(scheme vector f32) procedure (f32vector-take (f32vec f32vector?) (n integer?) ) ⟹ f32vector?
(scheme vector f32) procedure (f32vector-take-right (f32vec f32vector?) (n integer?) ) ⟹ f32vector?
Returns a f32vector containing the first/last n elements of f32vec.
(scheme vector f32) procedure (f32vector-drop (f32vec f32vector?) (n integer?) ) ⟹ f32vector?
(scheme vector f32) procedure (f32vector-drop-right (f32vec f32vector?) (n integer?) ) ⟹ f32vector?
Returns a f32vector containing all except the first/last n elements of f32vec.
(scheme vector f32) procedure (f32vector-segment (f32vec f32vector?) (n integer?) ) ⟹ list?
Returns a list of f32vectors, each of which contains n consecutive elements of f32vec. The last f32vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector f32) procedure (f32vector-fold (kons procedure?) knil (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ *
(kons state (obj1 f32?) (obj2 f32?) ... ) ⟹ *
(scheme vector f32) procedure (f32vector-fold-right (kons procedure?) knil (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ *
(kons state (obj1 f32?) (obj2 f32?) ... ) ⟹ *
When one f32vector argument f32vec is given, folds kons over the elements of f32vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple f32vector arguments are given, kons is called with the current state value and each value from all the vectors; f32vector-fold scans elements from left to right, while f32vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector f32) procedure (f32vector-map (proc procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ vector?
(proc (val1 f32?) ... ) ⟹ *
(scheme vector f32) procedure (f32vector-map! (proc procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ undefined
(proc (val1 f32?) ... ) ⟹ *
(scheme vector f32) procedure (f32vector-for-each (proc procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ undefined
(proc (val1 f32?) ... ) ⟹ undefined
Iterate over the elements of f32vec and apply f to each, returning respectively a f32vector of the results, an undefined value with the results placed back in f32vec, and an undefined value with no change to f32vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For f32vector-map!, only f32vec is modified even when multiple vectors are passed.
If f32vector-map or f32vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector f32) procedure (f32vector-count (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer?
(pred? (val1 f32?) (val2 f32?) ... ) ⟹ *
Call pred? on each element of f32vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector f32) procedure (f32vector-cumulate (f procedure?) knil (f32vec f32vector?) ) ⟹ f32vector?
(f state (value f32?) ) ⟹ *
Like f32vector-fold, but returns an f32vector of partial results rather than just the final result.
(scheme vector f32) procedure (f32vector-take-while (pred? procedure?) (f32vec f32vector?) ) ⟹ f32vector?
(pred? (value f32?) ) ⟹ boolean?
(scheme vector f32) procedure (f32vector-take-while-right (pred? procedure?) (f32vec f32vector?) ) ⟹ f32vector?
(pred? (value f32?) ) ⟹ boolean?
Return the shortest prefix/suffix of f32vec all of whose elements satisfy pred?.
(scheme vector f32) procedure (f32vector-drop-while (pred? procedure?) (f32vec f32vector?) ) ⟹ f32vector?
(pred? (value f32?) ) ⟹ boolean?
(scheme vector f32) procedure (f32vector-drop-while-right (pred? procedure?) (f32vec f32vector?) ) ⟹ f32vector?
(pred? (value f32?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of f32vec such that all its elements satisfy pred.
(scheme vector f32) procedure (f32vector-index (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f32?) (value2 f32?) ... ) ⟹ *
(scheme vector f32) procedure (f32vector-index-right (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f32?) (value2 f32?) ... ) ⟹ *
Return the index of the first/last element of f32vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, f32vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for f32vector-index-right.
(scheme vector f32) procedure (f32vector-skip (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f32?) (value2 f32?) ... ) ⟹ *
(scheme vector f32) procedure (f32vector-skip-right (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f32?) (value2 f32?) ... ) ⟹ *
Returns the index of the first/last element of f32vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, f32vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for f32vector-skip-right.
(scheme vector f32) procedure (f32vector-any (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ *
(pred? (val1 f32?) (val2 f32?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the f32vec, or #f if there is no such element. If f32vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector f32) procedure (f32vector-every (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ *
(pred? (val1 f32?) (val2 f32?) ... ) ⟹ *
If all elements from f32vec satisfy pred?, return the last result of pred?. If not all do, return #f. If f32vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector f32) procedure (f32vector-partition (pred? procedure?) (f32vec f32vector?) ) ⟹ (values f32vector?integer?)
(pred? (value f32?) ) ⟹ boolean?
Returns an f32vector of the same type as f32vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new f32vector and the number of elements satisfying pred?.
(scheme vector f32) procedure (f32vector-filter (pred? procedure?) (f32vec1 f32vector?) ) ⟹ f32vector?
(pred? (val f32?) ) ⟹ boolean?
(scheme vector f32) procedure (f32vector-remove (pred? procedure?) (f32vec1 f32vector?) ) ⟹ f32vector?
(pred? (val f32?) ) ⟹ boolean?
Return an f32vector containing the elements of f32vec that satisfy / do not satisfy pred?.
(scheme vector f32) procedure (f32vector-swap! (f32vec f32vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of f32vec.
(scheme vector f32) procedure (f32vector-fill! (f32vec f32vector?) (fill f32?) ) ⟹ undefined
(scheme vector f32) procedure (f32vector-fill! (f32vec f32vector?) (fill f32?) (start integer?) ) ⟹ undefined
(scheme vector f32) procedure (f32vector-fill! (f32vec f32vector?) (fill f32?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of f32vec from start to end with the value fill.
(scheme vector f32) procedure (f32vector-reverse! (f32vec f32vector?) ) ⟹ undefined
(scheme vector f32) procedure (f32vector-reverse! (f32vec f32vector?) (start integer?) ) ⟹ undefined
(scheme vector f32) procedure (f32vector-reverse! (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of f32vec from start to end.
(scheme vector f32) procedure (f32vector-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) ) ⟹ undefined
(scheme vector f32) procedure (f32vector-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) (start integer?) ) ⟹ undefined
(scheme vector f32) procedure (f32vector-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of f32from from start to end onto f32to, starting at index at.
(scheme vector f32) procedure (f32vector-reverse-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) ) ⟹ undefined
(scheme vector f32) procedure (f32vector-reverse-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) (start integer?) ) ⟹ undefined
(scheme vector f32) procedure (f32vector-reverse-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as f32vector-copy!, but copies in reverse
(scheme vector f32) procedure (f32vector-unfold! (f procedure?) (f32vec f32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like f32vector-unfold, but the elements are copied into the vector f32vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector f32) procedure (f32vector-unfold-right! (f procedure?) (f32vec f32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as f32vector-unfold!, but initializes the f32vector from right to left.
(scheme vector f32) procedure (reverse-f32vector->list (f32vec f32vector?) ) ⟹ list?
(scheme vector f32) procedure (reverse-f32vector->list (f32vec f32vector?) (start integer?) ) ⟹ list?
(scheme vector f32) procedure (reverse-f32vector->list (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f32vec in reverse order.
(scheme vector f32) procedure (reverse-list->f32vector (proper-list list?) ) ⟹ f32vector?
Returns f32vector with same elements as list in reverse order.
(scheme vector f32) procedure (f32vector->vector (f32vec f32vector?) ) ⟹ vector?
(scheme vector f32) procedure (f32vector->vector (f32vec f32vector?) (start integer?) ) ⟹ vector?
(scheme vector f32) procedure (f32vector->vector (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as f32vec.
(scheme vector f32) procedure (vector->f32vector (vec vector?) ) ⟹ f32vector?
(scheme vector f32) procedure (vector->f32vector (vec vector?) (start integer?) ) ⟹ f32vector?
(scheme vector f32) procedure (vector->f32vector (vec vector?) (start integer?) (end integer?) ) ⟹ f32vector?
Returns f32vector with same elements as vec.
(scheme vector f32) procedure (make-f32vector-generator (f32vector f32vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / f32? /
Returns a SRFI 121 generator that generates all the values of f32vector in order. Note that the generator is finite.
f32vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of f32vector.
(scheme vector f32) procedure (write-f32vector (f32vec f32vector) ) ⟹ undefined
(scheme vector f32) procedure (write-f32vector (f32vec f32vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of f32vec in the lexical syntax explained below.
library (scheme vector f64)
(scheme vector f64) procedure (make-f64vector (size integer?) ) ⟹ f64vector?
(scheme vector f64) procedure (make-f64vector (size integer?) (fill f64?) ) ⟹ f64vector?
Returns a f64vector whose length is size. If fill is provided, all the elements of the f64vector are initialized to it.
(scheme vector f64) procedure (f64vector (value f64?) ... ) ⟹ f64vector?
Returns a f64vector initialized with values.
(scheme vector f64) procedure (f64vector? obj ) ⟹ boolean?
Returns #t if obj is a f64vector, and #f otherwise.
(scheme vector f64) procedure (f64vector-length (f64vec f64vector?) ) ⟹ integer?
Returns the length of f64vec
(scheme vector f64) procedure (f64vector-ref (f64vec f64vector?) (i integer?) ) ⟹ f64?
Returns the ith element of f64vec.
(scheme vector f64) procedure (f64vector-set! (f64vec f64vector?) (i integer?) (value f64?) ) ⟹ undefined
Sets the ith element of f64vec to value.
(scheme vector f64) procedure (f64vector->list (f64vec f64vector?) ) ⟹ list?
(scheme vector f64) procedure (f64vector->list (f64vec f64vector?) (start integer?) ) ⟹ list?
(scheme vector f64) procedure (f64vector->list (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f64vec
(scheme vector f64) procedure (list->f64vector (proper-list list?) ) ⟹ f64vector?
proper-list ⟹ (list f64? )
Returns f64vector with same elements as list.
(scheme vector f64) procedure (f64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an f64vector (ie., inexact real), and #f otherwise.
(scheme vector f64) procedure (f64vector-unfold (f procedure?) (length integer?) seed ) ⟹ f64vector?
(scheme vector f64) procedure (f64vector-unfold (f procedure?) (length integer?) seed ) ⟹ f64vector?
(f (index integer?) state ) ⟹ (values f64?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector f64) procedure (f64vector-copy (f64vec f64vector?) ) ⟹ f64vector?
(scheme vector f64) procedure (f64vector-copy (f64vec f64vector?) (start integer?) ) ⟹ f64vector?
(scheme vector f64) procedure (f64vector-copy (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ f64vector?
Makes a copy of the portion of f64vec from start to end and returns it.
(scheme vector f64) procedure (f64vector-reverse-copy (f64vec f64vector?) ) ⟹ f64vector?
(scheme vector f64) procedure (f64vector-reverse-copy (f64vec f64vector?) (start integer?) ) ⟹ f64vector?
(scheme vector f64) procedure (f64vector-reverse-copy (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ f64vector?
The same as f64vector-copy, but in reverse order.
(scheme vector f64) procedure (f64vector-append (f64vec f64vector?) ... ) ⟹ f64vector?
Returns a f64vector containing all the elements of the f64vecs in order.
(scheme vector f64) procedure (f64vector-concatenate (list-of-f64vectors list?) ) ⟹ f64vector?
list-of-f64vectors ⟹ (list f64vector? )
The same as f64vector-append, but takes a list of f64vectors rather than multiple arguments.
(scheme vector f64) procedure (f64vector-append-subvectors (f64vec1 f64vector?) (start1 integer?) (end1 integer?) ... ) ⟹ f64vector?
Concatenates the result of applying f64vector-copy to each triplet of f64vec, start, end arguments, but may be implemented more efficiently.
(scheme vector f64) procedure (f64vector-empty? (f64vec f64vector?) ) ⟹ boolean?
Returns #t if f64vec has a length of zero, and #f otherwise.
(scheme vector f64) procedure (f64vector= (f64vec f64vector?) ... ) ⟹ boolean?
Compares the f64vecs for elementwise equality, using = to do the comparisons. Returns #f unless all f64vectors are the same length.
(scheme vector f64) procedure (f64vector-take (f64vec f64vector?) (n integer?) ) ⟹ f64vector?
(scheme vector f64) procedure (f64vector-take-right (f64vec f64vector?) (n integer?) ) ⟹ f64vector?
Returns a f64vector containing the first/last n elements of f64vec.
(scheme vector f64) procedure (f64vector-drop (f64vec f64vector?) (n integer?) ) ⟹ f64vector?
(scheme vector f64) procedure (f64vector-drop-right (f64vec f64vector?) (n integer?) ) ⟹ f64vector?
Returns a f64vector containing all except the first/last n elements of f64vec.
(scheme vector f64) procedure (f64vector-segment (f64vec f64vector?) (n integer?) ) ⟹ list?
Returns a list of f64vectors, each of which contains n consecutive elements of f64vec. The last f64vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector f64) procedure (f64vector-fold (kons procedure?) knil (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ *
(kons state (obj1 f64?) (obj2 f64?) ... ) ⟹ *
(scheme vector f64) procedure (f64vector-fold-right (kons procedure?) knil (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ *
(kons state (obj1 f64?) (obj2 f64?) ... ) ⟹ *
When one f64vector argument f64vec is given, folds kons over the elements of f64vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple f64vector arguments are given, kons is called with the current state value and each value from all the vectors; f64vector-fold scans elements from left to right, while f64vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector f64) procedure (f64vector-map (proc procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ vector?
(proc (val1 f64?) ... ) ⟹ *
(scheme vector f64) procedure (f64vector-map! (proc procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ undefined
(proc (val1 f64?) ... ) ⟹ *
(scheme vector f64) procedure (f64vector-for-each (proc procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ undefined
(proc (val1 f64?) ... ) ⟹ undefined
Iterate over the elements of f64vec and apply f to each, returning respectively a f64vector of the results, an undefined value with the results placed back in f64vec, and an undefined value with no change to f64vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For f64vector-map!, only f64vec is modified even when multiple vectors are passed.
If f64vector-map or f64vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector f64) procedure (f64vector-count (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer?
(pred? (val1 f64?) (val2 f64?) ... ) ⟹ *
Call pred? on each element of f64vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector f64) procedure (f64vector-cumulate (f procedure?) knil (f64vec f64vector?) ) ⟹ f64vector?
(f state (value f64?) ) ⟹ *
Like f64vector-fold, but returns an f64vector of partial results rather than just the final result.
(scheme vector f64) procedure (f64vector-take-while (pred? procedure?) (f64vec f64vector?) ) ⟹ f64vector?
(pred? (value f64?) ) ⟹ boolean?
(scheme vector f64) procedure (f64vector-take-while-right (pred? procedure?) (f64vec f64vector?) ) ⟹ f64vector?
(pred? (value f64?) ) ⟹ boolean?
Return the shortest prefix/suffix of f64vec all of whose elements satisfy pred?.
(scheme vector f64) procedure (f64vector-drop-while (pred? procedure?) (f64vec f64vector?) ) ⟹ f64vector?
(pred? (value f64?) ) ⟹ boolean?
(scheme vector f64) procedure (f64vector-drop-while-right (pred? procedure?) (f64vec f64vector?) ) ⟹ f64vector?
(pred? (value f64?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of f64vec such that all its elements satisfy pred.
(scheme vector f64) procedure (f64vector-index (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f64?) (value2 f64?) ... ) ⟹ *
(scheme vector f64) procedure (f64vector-index-right (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f64?) (value2 f64?) ... ) ⟹ *
Return the index of the first/last element of f64vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, f64vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for f64vector-index-right.
(scheme vector f64) procedure (f64vector-skip (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f64?) (value2 f64?) ... ) ⟹ *
(scheme vector f64) procedure (f64vector-skip-right (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f64?) (value2 f64?) ... ) ⟹ *
Returns the index of the first/last element of f64vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, f64vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for f64vector-skip-right.
(scheme vector f64) procedure (f64vector-any (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ *
(pred? (val1 f64?) (val2 f64?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the f64vec, or #f if there is no such element. If f64vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector f64) procedure (f64vector-every (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ *
(pred? (val1 f64?) (val2 f64?) ... ) ⟹ *
If all elements from f64vec satisfy pred?, return the last result of pred?. If not all do, return #f. If f64vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector f64) procedure (f64vector-partition (pred? procedure?) (f64vec f64vector?) ) ⟹ (values f64vector?integer?)
(pred? (value f64?) ) ⟹ boolean?
Returns an f64vector of the same type as f64vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new f64vector and the number of elements satisfying pred?.
(scheme vector f64) procedure (f64vector-filter (pred? procedure?) (f64vec1 f64vector?) ) ⟹ f64vector?
(pred? (val f64?) ) ⟹ boolean?
(scheme vector f64) procedure (f64vector-remove (pred? procedure?) (f64vec1 f64vector?) ) ⟹ f64vector?
(pred? (val f64?) ) ⟹ boolean?
Return an f64vector containing the elements of f64vec that satisfy / do not satisfy pred?.
(scheme vector f64) procedure (f64vector-swap! (f64vec f64vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of f64vec.
(scheme vector f64) procedure (f64vector-fill! (f64vec f64vector?) (fill f64?) ) ⟹ undefined
(scheme vector f64) procedure (f64vector-fill! (f64vec f64vector?) (fill f64?) (start integer?) ) ⟹ undefined
(scheme vector f64) procedure (f64vector-fill! (f64vec f64vector?) (fill f64?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of f64vec from start to end with the value fill.
(scheme vector f64) procedure (f64vector-reverse! (f64vec f64vector?) ) ⟹ undefined
(scheme vector f64) procedure (f64vector-reverse! (f64vec f64vector?) (start integer?) ) ⟹ undefined
(scheme vector f64) procedure (f64vector-reverse! (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of f64vec from start to end.
(scheme vector f64) procedure (f64vector-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) ) ⟹ undefined
(scheme vector f64) procedure (f64vector-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) (start integer?) ) ⟹ undefined
(scheme vector f64) procedure (f64vector-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of f64from from start to end onto f64to, starting at index at.
(scheme vector f64) procedure (f64vector-reverse-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) ) ⟹ undefined
(scheme vector f64) procedure (f64vector-reverse-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) (start integer?) ) ⟹ undefined
(scheme vector f64) procedure (f64vector-reverse-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as f64vector-copy!, but copies in reverse
(scheme vector f64) procedure (f64vector-unfold! (f procedure?) (f64vec f64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like f64vector-unfold, but the elements are copied into the vector f64vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector f64) procedure (f64vector-unfold-right! (f procedure?) (f64vec f64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as f64vector-unfold!, but initializes the f64vector from right to left.
(scheme vector f64) procedure (reverse-f64vector->list (f64vec f64vector?) ) ⟹ list?
(scheme vector f64) procedure (reverse-f64vector->list (f64vec f64vector?) (start integer?) ) ⟹ list?
(scheme vector f64) procedure (reverse-f64vector->list (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f64vec in reverse order.
(scheme vector f64) procedure (reverse-list->f64vector (proper-list list?) ) ⟹ f64vector?
Returns f64vector with same elements as list in reverse order.
(scheme vector f64) procedure (f64vector->vector (f64vec f64vector?) ) ⟹ vector?
(scheme vector f64) procedure (f64vector->vector (f64vec f64vector?) (start integer?) ) ⟹ vector?
(scheme vector f64) procedure (f64vector->vector (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as f64vec.
(scheme vector f64) procedure (vector->f64vector (vec vector?) ) ⟹ f64vector?
(scheme vector f64) procedure (vector->f64vector (vec vector?) (start integer?) ) ⟹ f64vector?
(scheme vector f64) procedure (vector->f64vector (vec vector?) (start integer?) (end integer?) ) ⟹ f64vector?
Returns f64vector with same elements as vec.
(scheme vector f64) procedure (make-f64vector-generator (f64vector f64vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / f64? /
Returns a SRFI 121 generator that generates all the values of f64vector in order. Note that the generator is finite.
f64vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of f64vector.
(scheme vector f64) procedure (write-f64vector (f64vec f64vector) ) ⟹ undefined
(scheme vector f64) procedure (write-f64vector (f64vec f64vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of f64vec in the lexical syntax explained below.
library (scheme vector c64)
(scheme vector c64) procedure (make-c64vector (size integer?) ) ⟹ c64vector?
(scheme vector c64) procedure (make-c64vector (size integer?) (fill c64?) ) ⟹ c64vector?
Returns a c64vector whose length is size. If fill is provided, all the elements of the c64vector are initialized to it.
(scheme vector c64) procedure (c64vector (value c64?) ... ) ⟹ c64vector?
Returns a c64vector initialized with values.
(scheme vector c64) procedure (c64vector? obj ) ⟹ boolean?
Returns #t if obj is a c64vector, and #f otherwise.
(scheme vector c64) procedure (c64vector-length (c64vec c64vector?) ) ⟹ integer?
Returns the length of c64vec
(scheme vector c64) procedure (c64vector-ref (c64vec c64vector?) (i integer?) ) ⟹ c64?
Returns the ith element of c64vec.
(scheme vector c64) procedure (c64vector-set! (c64vec c64vector?) (i integer?) (value c64?) ) ⟹ undefined
Sets the ith element of c64vec to value.
(scheme vector c64) procedure (c64vector->list (c64vec c64vector?) ) ⟹ list?
(scheme vector c64) procedure (c64vector->list (c64vec c64vector?) (start integer?) ) ⟹ list?
(scheme vector c64) procedure (c64vector->list (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c64vec
(scheme vector c64) procedure (list->c64vector (proper-list list?) ) ⟹ c64vector?
proper-list ⟹ (list c64? )
Returns c64vector with same elements as list.
(scheme vector c64) procedure (c64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an c64vector (ie., inexact complex), and #f otherwise.
(scheme vector c64) procedure (c64vector-unfold (f procedure?) (length integer?) seed ) ⟹ c64vector?
(scheme vector c64) procedure (c64vector-unfold (f procedure?) (length integer?) seed ) ⟹ c64vector?
(f (index integer?) state ) ⟹ (values c64?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector c64) procedure (c64vector-copy (c64vec c64vector?) ) ⟹ c64vector?
(scheme vector c64) procedure (c64vector-copy (c64vec c64vector?) (start integer?) ) ⟹ c64vector?
(scheme vector c64) procedure (c64vector-copy (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ c64vector?
Makes a copy of the portion of c64vec from start to end and returns it.
(scheme vector c64) procedure (c64vector-reverse-copy (c64vec c64vector?) ) ⟹ c64vector?
(scheme vector c64) procedure (c64vector-reverse-copy (c64vec c64vector?) (start integer?) ) ⟹ c64vector?
(scheme vector c64) procedure (c64vector-reverse-copy (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ c64vector?
The same as c64vector-copy, but in reverse order.
(scheme vector c64) procedure (c64vector-append (c64vec c64vector?) ... ) ⟹ c64vector?
Returns a c64vector containing all the elements of the c64vecs in order.
(scheme vector c64) procedure (c64vector-concatenate (list-of-c64vectors list?) ) ⟹ c64vector?
list-of-c64vectors ⟹ (list c64vector? )
The same as c64vector-append, but takes a list of c64vectors rather than multiple arguments.
(scheme vector c64) procedure (c64vector-append-subvectors (c64vec1 c64vector?) (start1 integer?) (end1 integer?) ... ) ⟹ c64vector?
Concatenates the result of applying c64vector-copy to each triplet of c64vec, start, end arguments, but may be implemented more efficiently.
(scheme vector c64) procedure (c64vector-empty? (c64vec c64vector?) ) ⟹ boolean?
Returns #t if c64vec has a length of zero, and #f otherwise.
(scheme vector c64) procedure (c64vector= (c64vec c64vector?) ... ) ⟹ boolean?
Compares the c64vecs for elementwise equality, using = to do the comparisons. Returns #f unless all c64vectors are the same length.
(scheme vector c64) procedure (c64vector-take (c64vec c64vector?) (n integer?) ) ⟹ c64vector?
(scheme vector c64) procedure (c64vector-take-right (c64vec c64vector?) (n integer?) ) ⟹ c64vector?
Returns a c64vector containing the first/last n elements of c64vec.
(scheme vector c64) procedure (c64vector-drop (c64vec c64vector?) (n integer?) ) ⟹ c64vector?
(scheme vector c64) procedure (c64vector-drop-right (c64vec c64vector?) (n integer?) ) ⟹ c64vector?
Returns a c64vector containing all except the first/last n elements of c64vec.
(scheme vector c64) procedure (c64vector-segment (c64vec c64vector?) (n integer?) ) ⟹ list?
Returns a list of c64vectors, each of which contains n consecutive elements of c64vec. The last c64vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector c64) procedure (c64vector-fold (kons procedure?) knil (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ *
(kons state (obj1 c64?) (obj2 c64?) ... ) ⟹ *
(scheme vector c64) procedure (c64vector-fold-right (kons procedure?) knil (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ *
(kons state (obj1 c64?) (obj2 c64?) ... ) ⟹ *
When one c64vector argument c64vec is given, folds kons over the elements of c64vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple c64vector arguments are given, kons is called with the current state value and each value from all the vectors; c64vector-fold scans elements from left to right, while c64vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector c64) procedure (c64vector-map (proc procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ vector?
(proc (val1 c64?) ... ) ⟹ *
(scheme vector c64) procedure (c64vector-map! (proc procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ undefined
(proc (val1 c64?) ... ) ⟹ *
(scheme vector c64) procedure (c64vector-for-each (proc procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ undefined
(proc (val1 c64?) ... ) ⟹ undefined
Iterate over the elements of c64vec and apply f to each, returning respectively a c64vector of the results, an undefined value with the results placed back in c64vec, and an undefined value with no change to c64vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For c64vector-map!, only c64vec is modified even when multiple vectors are passed.
If c64vector-map or c64vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector c64) procedure (c64vector-count (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer?
(pred? (val1 c64?) (val2 c64?) ... ) ⟹ *
Call pred? on each element of c64vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector c64) procedure (c64vector-cumulate (f procedure?) knil (c64vec c64vector?) ) ⟹ c64vector?
(f state (value c64?) ) ⟹ *
Like c64vector-fold, but returns an c64vector of partial results rather than just the final result.
(scheme vector c64) procedure (c64vector-take-while (pred? procedure?) (c64vec c64vector?) ) ⟹ c64vector?
(pred? (value c64?) ) ⟹ boolean?
(scheme vector c64) procedure (c64vector-take-while-right (pred? procedure?) (c64vec c64vector?) ) ⟹ c64vector?
(pred? (value c64?) ) ⟹ boolean?
Return the shortest prefix/suffix of c64vec all of whose elements satisfy pred?.
(scheme vector c64) procedure (c64vector-drop-while (pred? procedure?) (c64vec c64vector?) ) ⟹ c64vector?
(pred? (value c64?) ) ⟹ boolean?
(scheme vector c64) procedure (c64vector-drop-while-right (pred? procedure?) (c64vec c64vector?) ) ⟹ c64vector?
(pred? (value c64?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of c64vec such that all its elements satisfy pred.
(scheme vector c64) procedure (c64vector-index (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c64?) (value2 c64?) ... ) ⟹ *
(scheme vector c64) procedure (c64vector-index-right (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c64?) (value2 c64?) ... ) ⟹ *
Return the index of the first/last element of c64vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, c64vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for c64vector-index-right.
(scheme vector c64) procedure (c64vector-skip (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c64?) (value2 c64?) ... ) ⟹ *
(scheme vector c64) procedure (c64vector-skip-right (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c64?) (value2 c64?) ... ) ⟹ *
Returns the index of the first/last element of c64vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, c64vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for c64vector-skip-right.
(scheme vector c64) procedure (c64vector-any (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ *
(pred? (val1 c64?) (val2 c64?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the c64vec, or #f if there is no such element. If c64vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector c64) procedure (c64vector-every (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ *
(pred? (val1 c64?) (val2 c64?) ... ) ⟹ *
If all elements from c64vec satisfy pred?, return the last result of pred?. If not all do, return #f. If c64vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector c64) procedure (c64vector-partition (pred? procedure?) (c64vec c64vector?) ) ⟹ (values c64vector?integer?)
(pred? (value c64?) ) ⟹ boolean?
Returns an c64vector of the same type as c64vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new c64vector and the number of elements satisfying pred?.
(scheme vector c64) procedure (c64vector-filter (pred? procedure?) (c64vec1 c64vector?) ) ⟹ c64vector?
(pred? (val c64?) ) ⟹ boolean?
(scheme vector c64) procedure (c64vector-remove (pred? procedure?) (c64vec1 c64vector?) ) ⟹ c64vector?
(pred? (val c64?) ) ⟹ boolean?
Return an c64vector containing the elements of c64vec that satisfy / do not satisfy pred?.
(scheme vector c64) procedure (c64vector-swap! (c64vec c64vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of c64vec.
(scheme vector c64) procedure (c64vector-fill! (c64vec c64vector?) (fill c64?) ) ⟹ undefined
(scheme vector c64) procedure (c64vector-fill! (c64vec c64vector?) (fill c64?) (start integer?) ) ⟹ undefined
(scheme vector c64) procedure (c64vector-fill! (c64vec c64vector?) (fill c64?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of c64vec from start to end with the value fill.
(scheme vector c64) procedure (c64vector-reverse! (c64vec c64vector?) ) ⟹ undefined
(scheme vector c64) procedure (c64vector-reverse! (c64vec c64vector?) (start integer?) ) ⟹ undefined
(scheme vector c64) procedure (c64vector-reverse! (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of c64vec from start to end.
(scheme vector c64) procedure (c64vector-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) ) ⟹ undefined
(scheme vector c64) procedure (c64vector-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) (start integer?) ) ⟹ undefined
(scheme vector c64) procedure (c64vector-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of c64from from start to end onto c64to, starting at index at.
(scheme vector c64) procedure (c64vector-reverse-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) ) ⟹ undefined
(scheme vector c64) procedure (c64vector-reverse-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) (start integer?) ) ⟹ undefined
(scheme vector c64) procedure (c64vector-reverse-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as c64vector-copy!, but copies in reverse
(scheme vector c64) procedure (c64vector-unfold! (f procedure?) (c64vec c64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like c64vector-unfold, but the elements are copied into the vector c64vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector c64) procedure (c64vector-unfold-right! (f procedure?) (c64vec c64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as c64vector-unfold!, but initializes the c64vector from right to left.
(scheme vector c64) procedure (reverse-c64vector->list (c64vec c64vector?) ) ⟹ list?
(scheme vector c64) procedure (reverse-c64vector->list (c64vec c64vector?) (start integer?) ) ⟹ list?
(scheme vector c64) procedure (reverse-c64vector->list (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c64vec in reverse order.
(scheme vector c64) procedure (reverse-list->c64vector (proper-list list?) ) ⟹ c64vector?
Returns c64vector with same elements as list in reverse order.
(scheme vector c64) procedure (c64vector->vector (c64vec c64vector?) ) ⟹ vector?
(scheme vector c64) procedure (c64vector->vector (c64vec c64vector?) (start integer?) ) ⟹ vector?
(scheme vector c64) procedure (c64vector->vector (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as c64vec.
(scheme vector c64) procedure (vector->c64vector (vec vector?) ) ⟹ c64vector?
(scheme vector c64) procedure (vector->c64vector (vec vector?) (start integer?) ) ⟹ c64vector?
(scheme vector c64) procedure (vector->c64vector (vec vector?) (start integer?) (end integer?) ) ⟹ c64vector?
Returns c64vector with same elements as vec.
(scheme vector c64) procedure (make-c64vector-generator (c64vector c64vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / c64? /
Returns a SRFI 121 generator that generates all the values of c64vector in order. Note that the generator is finite.
c64vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of c64vector.
(scheme vector c64) procedure (write-c64vector (c64vec c64vector) ) ⟹ undefined
(scheme vector c64) procedure (write-c64vector (c64vec c64vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of c64vec in the lexical syntax explained below.
library (scheme vector c128)
(scheme vector c128) procedure (make-c128vector (size integer?) ) ⟹ c128vector?
(scheme vector c128) procedure (make-c128vector (size integer?) (fill c128?) ) ⟹ c128vector?
Returns a c128vector whose length is size. If fill is provided, all the elements of the c128vector are initialized to it.
(scheme vector c128) procedure (c128vector (value c128?) ... ) ⟹ c128vector?
Returns a c128vector initialized with values.
(scheme vector c128) procedure (c128vector? obj ) ⟹ boolean?
Returns #t if obj is a c128vector, and #f otherwise.
(scheme vector c128) procedure (c128vector-length (c128vec c128vector?) ) ⟹ integer?
Returns the length of c128vec
(scheme vector c128) procedure (c128vector-ref (c128vec c128vector?) (i integer?) ) ⟹ c128?
Returns the ith element of c128vec.
(scheme vector c128) procedure (c128vector-set! (c128vec c128vector?) (i integer?) (value c128?) ) ⟹ undefined
Sets the ith element of c128vec to value.
(scheme vector c128) procedure (c128vector->list (c128vec c128vector?) ) ⟹ list?
(scheme vector c128) procedure (c128vector->list (c128vec c128vector?) (start integer?) ) ⟹ list?
(scheme vector c128) procedure (c128vector->list (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c128vec
(scheme vector c128) procedure (list->c128vector (proper-list list?) ) ⟹ c128vector?
proper-list ⟹ (list c128? )
Returns c128vector with same elements as list.
(scheme vector c128) procedure (c128? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an c128vector (ie., inexact complex), and #f otherwise.
(scheme vector c128) procedure (c128vector-unfold (f procedure?) (length integer?) seed ) ⟹ c128vector?
(scheme vector c128) procedure (c128vector-unfold (f procedure?) (length integer?) seed ) ⟹ c128vector?
(f (index integer?) state ) ⟹ (values c128?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(scheme vector c128) procedure (c128vector-copy (c128vec c128vector?) ) ⟹ c128vector?
(scheme vector c128) procedure (c128vector-copy (c128vec c128vector?) (start integer?) ) ⟹ c128vector?
(scheme vector c128) procedure (c128vector-copy (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ c128vector?
Makes a copy of the portion of c128vec from start to end and returns it.
(scheme vector c128) procedure (c128vector-reverse-copy (c128vec c128vector?) ) ⟹ c128vector?
(scheme vector c128) procedure (c128vector-reverse-copy (c128vec c128vector?) (start integer?) ) ⟹ c128vector?
(scheme vector c128) procedure (c128vector-reverse-copy (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ c128vector?
The same as c128vector-copy, but in reverse order.
(scheme vector c128) procedure (c128vector-append (c128vec c128vector?) ... ) ⟹ c128vector?
Returns a c128vector containing all the elements of the c128vecs in order.
(scheme vector c128) procedure (c128vector-concatenate (list-of-c128vectors list?) ) ⟹ c128vector?
list-of-c128vectors ⟹ (list c128vector? )
The same as c128vector-append, but takes a list of c128vectors rather than multiple arguments.
(scheme vector c128) procedure (c128vector-append-subvectors (c128vec1 c128vector?) (start1 integer?) (end1 integer?) ... ) ⟹ c128vector?
Concatenates the result of applying c128vector-copy to each triplet of c128vec, start, end arguments, but may be implemented more efficiently.
(scheme vector c128) procedure (c128vector-empty? (c128vec c128vector?) ) ⟹ boolean?
Returns #t if c128vec has a length of zero, and #f otherwise.
(scheme vector c128) procedure (c128vector= (c128vec c128vector?) ... ) ⟹ boolean?
Compares the c128vecs for elementwise equality, using = to do the comparisons. Returns #f unless all c128vectors are the same length.
(scheme vector c128) procedure (c128vector-take (c128vec c128vector?) (n integer?) ) ⟹ c128vector?
(scheme vector c128) procedure (c128vector-take-right (c128vec c128vector?) (n integer?) ) ⟹ c128vector?
Returns a c128vector containing the first/last n elements of c128vec.
(scheme vector c128) procedure (c128vector-drop (c128vec c128vector?) (n integer?) ) ⟹ c128vector?
(scheme vector c128) procedure (c128vector-drop-right (c128vec c128vector?) (n integer?) ) ⟹ c128vector?
Returns a c128vector containing all except the first/last n elements of c128vec.
(scheme vector c128) procedure (c128vector-segment (c128vec c128vector?) (n integer?) ) ⟹ list?
Returns a list of c128vectors, each of which contains n consecutive elements of c128vec. The last c128vector may be shorter than n. It is an error if n is not an exact positive integer.
(scheme vector c128) procedure (c128vector-fold (kons procedure?) knil (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ *
(kons state (obj1 c128?) (obj2 c128?) ... ) ⟹ *
(scheme vector c128) procedure (c128vector-fold-right (kons procedure?) knil (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ *
(kons state (obj1 c128?) (obj2 c128?) ... ) ⟹ *
When one c128vector argument c128vec is given, folds kons over the elements of c128vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple c128vector arguments are given, kons is called with the current state value and each value from all the vectors; c128vector-fold scans elements from left to right, while c128vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(scheme vector c128) procedure (c128vector-map (proc procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ vector?
(proc (val1 c128?) ... ) ⟹ *
(scheme vector c128) procedure (c128vector-map! (proc procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ undefined
(proc (val1 c128?) ... ) ⟹ *
(scheme vector c128) procedure (c128vector-for-each (proc procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ undefined
(proc (val1 c128?) ... ) ⟹ undefined
Iterate over the elements of c128vec and apply f to each, returning respectively a c128vector of the results, an undefined value with the results placed back in c128vec, and an undefined value with no change to c128vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For c128vector-map!, only c128vec is modified even when multiple vectors are passed.
If c128vector-map or c128vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(scheme vector c128) procedure (c128vector-count (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer?
(pred? (val1 c128?) (val2 c128?) ... ) ⟹ *
Call pred? on each element of c128vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(scheme vector c128) procedure (c128vector-cumulate (f procedure?) knil (c128vec c128vector?) ) ⟹ c128vector?
(f state (value c128?) ) ⟹ *
Like c128vector-fold, but returns an c128vector of partial results rather than just the final result.
(scheme vector c128) procedure (c128vector-take-while (pred? procedure?) (c128vec c128vector?) ) ⟹ c128vector?
(pred? (value c128?) ) ⟹ boolean?
(scheme vector c128) procedure (c128vector-take-while-right (pred? procedure?) (c128vec c128vector?) ) ⟹ c128vector?
(pred? (value c128?) ) ⟹ boolean?
Return the shortest prefix/suffix of c128vec all of whose elements satisfy pred?.
(scheme vector c128) procedure (c128vector-drop-while (pred? procedure?) (c128vec c128vector?) ) ⟹ c128vector?
(pred? (value c128?) ) ⟹ boolean?
(scheme vector c128) procedure (c128vector-drop-while-right (pred? procedure?) (c128vec c128vector?) ) ⟹ c128vector?
(pred? (value c128?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of c128vec such that all its elements satisfy pred.
(scheme vector c128) procedure (c128vector-index (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c128?) (value2 c128?) ... ) ⟹ *
(scheme vector c128) procedure (c128vector-index-right (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c128?) (value2 c128?) ... ) ⟹ *
Return the index of the first/last element of c128vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, c128vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for c128vector-index-right.
(scheme vector c128) procedure (c128vector-skip (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c128?) (value2 c128?) ... ) ⟹ *
(scheme vector c128) procedure (c128vector-skip-right (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c128?) (value2 c128?) ... ) ⟹ *
Returns the index of the first/last element of c128vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, c128vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for c128vector-skip-right.
(scheme vector c128) procedure (c128vector-any (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ *
(pred? (val1 c128?) (val2 c128?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the c128vec, or #f if there is no such element. If c128vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector c128) procedure (c128vector-every (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ *
(pred? (val1 c128?) (val2 c128?) ... ) ⟹ *
If all elements from c128vec satisfy pred?, return the last result of pred?. If not all do, return #f. If c128vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(scheme vector c128) procedure (c128vector-partition (pred? procedure?) (c128vec c128vector?) ) ⟹ (values c128vector?integer?)
(pred? (value c128?) ) ⟹ boolean?
Returns an c128vector of the same type as c128vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new c128vector and the number of elements satisfying pred?.
(scheme vector c128) procedure (c128vector-filter (pred? procedure?) (c128vec1 c128vector?) ) ⟹ c128vector?
(pred? (val c128?) ) ⟹ boolean?
(scheme vector c128) procedure (c128vector-remove (pred? procedure?) (c128vec1 c128vector?) ) ⟹ c128vector?
(pred? (val c128?) ) ⟹ boolean?
Return an c128vector containing the elements of c128vec that satisfy / do not satisfy pred?.
(scheme vector c128) procedure (c128vector-swap! (c128vec c128vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of c128vec.
(scheme vector c128) procedure (c128vector-fill! (c128vec c128vector?) (fill c128?) ) ⟹ undefined
(scheme vector c128) procedure (c128vector-fill! (c128vec c128vector?) (fill c128?) (start integer?) ) ⟹ undefined
(scheme vector c128) procedure (c128vector-fill! (c128vec c128vector?) (fill c128?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of c128vec from start to end with the value fill.
(scheme vector c128) procedure (c128vector-reverse! (c128vec c128vector?) ) ⟹ undefined
(scheme vector c128) procedure (c128vector-reverse! (c128vec c128vector?) (start integer?) ) ⟹ undefined
(scheme vector c128) procedure (c128vector-reverse! (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of c128vec from start to end.
(scheme vector c128) procedure (c128vector-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) ) ⟹ undefined
(scheme vector c128) procedure (c128vector-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) (start integer?) ) ⟹ undefined
(scheme vector c128) procedure (c128vector-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of c128from from start to end onto c128to, starting at index at.
(scheme vector c128) procedure (c128vector-reverse-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) ) ⟹ undefined
(scheme vector c128) procedure (c128vector-reverse-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) (start integer?) ) ⟹ undefined
(scheme vector c128) procedure (c128vector-reverse-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as c128vector-copy!, but copies in reverse
(scheme vector c128) procedure (c128vector-unfold! (f procedure?) (c128vec c128vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like c128vector-unfold, but the elements are copied into the vector c128vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(scheme vector c128) procedure (c128vector-unfold-right! (f procedure?) (c128vec c128vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as c128vector-unfold!, but initializes the c128vector from right to left.
(scheme vector c128) procedure (reverse-c128vector->list (c128vec c128vector?) ) ⟹ list?
(scheme vector c128) procedure (reverse-c128vector->list (c128vec c128vector?) (start integer?) ) ⟹ list?
(scheme vector c128) procedure (reverse-c128vector->list (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c128vec in reverse order.
(scheme vector c128) procedure (reverse-list->c128vector (proper-list list?) ) ⟹ c128vector?
Returns c128vector with same elements as list in reverse order.
(scheme vector c128) procedure (c128vector->vector (c128vec c128vector?) ) ⟹ vector?
(scheme vector c128) procedure (c128vector->vector (c128vec c128vector?) (start integer?) ) ⟹ vector?
(scheme vector c128) procedure (c128vector->vector (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as c128vec.
(scheme vector c128) procedure (vector->c128vector (vec vector?) ) ⟹ c128vector?
(scheme vector c128) procedure (vector->c128vector (vec vector?) (start integer?) ) ⟹ c128vector?
(scheme vector c128) procedure (vector->c128vector (vec vector?) (start integer?) (end integer?) ) ⟹ c128vector?
Returns c128vector with same elements as vec.
(scheme vector c128) procedure (make-c128vector-generator (c128vector c128vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / c128? /
Returns a SRFI 121 generator that generates all the values of c128vector in order. Note that the generator is finite.
c128vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of c128vector.
(scheme vector c128) procedure (write-c128vector (c128vec c128vector) ) ⟹ undefined
(scheme vector c128) procedure (write-c128vector (c128vec c128vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of c128vec in the lexical syntax explained below.
library (srfi 0)
(srfi 0) 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 (srfi 1)
(srfi 1) procedure (cons a d ) ⟹ pair?
The primitive constructor. Returns a newly allocated pair whose car is a and whose cdr is d. The pair is guaranteed to be different (in the sense of eqv?) from every existing object.
(srfi 1) procedure (list object ... ) ⟹ list?
Returns a newly allocated list of its arguments.
(srfi 1) procedure (xcons d a ) ⟹ pair?
(lambda (d a) (cons a d)) Of utility only as a value to be conveniently passed to higher-order procedures.
(srfi 1) procedure (cons* elt1 elt2 ... ) ⟹ *
Like list, but the last argument provides the tail of the constructed list, returning (cons elt1 (cons elt2 (cons ... eltn))). This function is called list* in Common Lisp and about half of the Schemes that provide it, and cons* in the other half.
(srfi 1) procedure (make-list (n integer?) ) ⟹ list?
(srfi 1) procedure (make-list (n integer?) fill ) ⟹ list?
Returns an n-element list, whose elements are all the value fill. If the fill argument is not given, the elements of the list may be arbitrary values.
(srfi 1) procedure (list-tabulate (n integer?) (init-proc procedure?) ) ⟹ list?
(init-proc (i integer?) ) ⟹ *
Returns an n-element list. Element i of the list, where 0 <= i < n, is produced by (init-proc i). No guarantee is made about the dynamic order in which init-proc is applied to these indices.
(srfi 1) procedure (list-copy (flist list?) ) ⟹ list?
(srfi 1) procedure (list-copy (flist dotted-list?) ) ⟹ dotted-list?
Copies the spine of the argument.
(srfi 1) procedure (circular-list elt1 elt2 ... ) ⟹ circular-list?
Constructs a circular list of the elements.
(srfi 1) procedure (iota (count integer?) ) ⟹ list?
(srfi 1) procedure (iota (count integer?) (start number?) ) ⟹ list?
(srfi 1) procedure (iota (count integer?) (start number?) (step number?) ) ⟹ list?
Returns a list containing the elements (start start+step ... start+(count-1)*step). The start and step parameters default to 0 and 1, respectively. This procedure takes its name from the APL primitive.
(srfi 1) procedure (proper-list? obj ) ⟹ boolean?
Returns true iff x is a proper list -- a finite, nil-terminated list. More carefully: The empty list is a proper list. A pair whose cdr is a proper list is also a proper list: <proper-list> ::= () | (cons <x> <proper-list>). Note that this definition rules out circular lists. This function is required to detect this case and return false. Nil-terminated lists are called "proper" lists by R5RS and Common Lisp. The opposite of proper is improper.
(srfi 1) procedure (circular-list? obj ) ⟹ boolean?
True if x is a circular list. A circular list is a value such that for every n >= 0, cdrn(x) is a pair. Terminology: The opposite of circular is finite.
(srfi 1) procedure (dotted-list? obj ) ⟹ boolean?
True if x is a finite, non-nil-terminated list. That is, there exists an n >= 0 such that cdrn(x) is neither a pair nor (). This includes non-pair, non-() values (e.g. symbols, numbers), which are considered to be dotted lists of length 0.
(srfi 1) procedure (pair? obj ) ⟹ boolean?
Returns #t if object is a pair; otherwise, #f.
(srfi 1) procedure (null? obj ) ⟹ boolean?
Returns #t if object is the empty list; otherwise, #f.
(srfi 1) procedure (null-list? (lst list?) ) ⟹ boolean?
(srfi 1) procedure (null-list? (lst circular-list?) ) ⟹ boolean?
List is a proper or circular list. This procedure returns true if the argument is the empty list (), and false otherwise. It is an error to pass this procedure a value which is not a proper or circular list. This procedure is recommended as the termination condition for list-processing procedures that are not defined on dotted lists.
(srfi 1) procedure (not-pair? obj ) ⟹ boolean?
(lambda (x) (not (pair? x))). Provided as a procedure as it can be useful as the termination condition for list-processing procedures that wish to handle all finite lists, both proper and dotted.
(srfi 1) procedure (list= (elt= procedure?) (list1 list?) ... ) ⟹ boolean?
(elt= a b ) ⟹ *
Determines list equality, given an element-equality procedure. Proper list A equals proper list B if they are of the same length, and their corresponding elements are equal, as determined by elt=. If the element-comparison procedure's first argument is from listi, then its second argument is from listi+1, i.e. it is always called as (elt= a b) for a an element of list A, and b an element of list B. In the n-ary case, every listi is compared to listi+1 (as opposed, for example, to comparing list1 to every listi, for i>1). If there are no list arguments at all, list= simply returns true. It is an error to apply list= to anything except proper lists. While implementations may choose to extend it to circular lists, note that it cannot reasonably be extended to dotted lists, as it provides no way to specify an equality procedure for comparing the list terminators. Note that the dynamic order in which the elt= procedure is applied to pairs of elements is not specified. For example, if list= is applied to three lists, A, B, and C, it may first completely compare A to B, then compare B to C, or it may compare the first elements of A and B, then the first elements of B and C, then the second elements of A and B, and so forth. The equality procedure must be consistent with eq?. That is, it must be the case that (eq? x y) => (elt= x y). Note that this implies that two lists which are eq? are always list=, as well; implementations may exploit this fact to "short-cut" the element-by-element comparisons.
(srfi 1) procedure (caar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (car (pair pair?) ) ⟹ *
car, cdr These functions return the contents of the car and cdr field of their argument, respectively. Note that it is an error to apply them to the empty list.
(srfi 1) procedure (cdar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cdr (pair pair?) ) ⟹ *
car, cdr These functions return the contents of the car and cdr field of their argument, respectively. Note that it is an error to apply them to the empty list.
(srfi 1) procedure (caaaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (caaadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (caaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (caadar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (caaddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (caadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cadaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cadadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cadar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (caddar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cadddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (caddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cdaaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cdaadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cdaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cdadar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cdaddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cdadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cddaar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cddadr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cddar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cdddar (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cddddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (cdddr (pair pair?) ) ⟹ *
caar, cadr, ..., cddddr These procedures are compositions of car and cdr, where for example caddr could be defined by (define caddr (lambda (x) (car (cdr (cdr x))))).
(srfi 1) procedure (list-ref (clist list?) (i integer?) ) ⟹ *
(srfi 1) procedure (list-ref (clist circular-list?) (i integer?) ) ⟹ *
Returns the ith element of clist. (This is the same as the car of (drop clist i).) It is an error if i >= n, where n is the length of clist.
(srfi 1) procedure (first (pair pair?) ) ⟹ *
(srfi 1) procedure (second (pair pair?) ) ⟹ *
(srfi 1) procedure (third (pair pair?) ) ⟹ *
(srfi 1) procedure (fourth (pair pair?) ) ⟹ *
(srfi 1) procedure (fifth (pair pair?) ) ⟹ *
(srfi 1) procedure (sixth (pair pair?) ) ⟹ *
(srfi 1) procedure (seventh (pair pair?) ) ⟹ *
(srfi 1) procedure (eighth (pair pair?) ) ⟹ *
(srfi 1) procedure (ninth (pair pair?) ) ⟹ *
(srfi 1) procedure (tenth (pair pair?) ) ⟹ *
Synonyms for car, cadr, caddr, ...
(srfi 1) procedure (car+cdr (pair pair?) ) ⟹ (values **)
The fundamental pair deconstructor: (lambda (p) (values (car p) (cdr p)))
(srfi 1) procedure (take (x list?) (i integer?) ) ⟹ list?
(srfi 1) procedure (take (x circular-list?) (i integer?) ) ⟹ list?
(srfi 1) procedure (take (x dotted-list?) (i integer?) ) ⟹ list?
take, drop take returns the first i elements of list x. drop returns all but the first i elements of list x. x may be any value -- a proper, circular, or dotted list. For a legal i, take and drop partition the list in a manner which can be inverted with append: (append (take x i) (drop x i)) = x. drop is exactly equivalent to performing i cdr operations on x; the returned value shares a common tail with x. If the argument is a list of non-zero length, take is guaranteed to return a freshly-allocated list, even in the case where the entire list is taken, e.g. (take lis (length lis)).
(srfi 1) procedure (drop (x list?) (i integer?) ) ⟹ list?
(srfi 1) procedure (drop (x circular-list?) (i integer?) ) ⟹ circular-list?
(srfi 1) procedure (drop (x dotted-list?) (i integer?) ) ⟹ *
take, drop take returns the first i elements of list x. drop returns all but the first i elements of list x. x may be any value -- a proper, circular, or dotted list. For a legal i, take and drop partition the list in a manner which can be inverted with append: (append (take x i) (drop x i)) = x. drop is exactly equivalent to performing i cdr operations on x; the returned value shares a common tail with x. If the argument is a list of non-zero length, take is guaranteed to return a freshly-allocated list, even in the case where the entire list is taken, e.g. (take lis (length lis)).
(srfi 1) procedure (take-right (flist list?) (i integer?) ) ⟹ list?
(srfi 1) procedure (take-right (flist dotted-list?) (i integer?) ) ⟹ *
take-right, drop right take-right returns the last i elements of flist. drop-right returns all but the last i elements of flist. The returned list may share a common tail with the argument list. flist may be any finite list, either proper or dotted. For a legal i, take-right and drop-right partition the list in a manner which can be inverted with append: (append (take flist i) (drop flist i)) = flist. take-right's return value is guaranteed to share a common tail with flist. If the argument is a list of non-zero length, drop-right is guaranteed to return a freshly-allocated list, even in the case where nothing is dropped, e.g. (drop-right lis 0).
(srfi 1) procedure (drop-right (flist list?) (i integer?) ) ⟹ list?
(srfi 1) procedure (drop-right (flist dotted-list?) (i integer?) ) ⟹ list?
take-right, drop right take-right returns the last i elements of flist. drop-right returns all but the last i elements of flist. The returned list may share a common tail with the argument list. flist may be any finite list, either proper or dotted. For a legal i, take-right and drop-right partition the list in a manner which can be inverted with append: (append (take flist i) (drop flist i)) = flist. take-right's return value is guaranteed to share a common tail with flist. If the argument is a list of non-zero length, drop-right is guaranteed to return a freshly-allocated list, even in the case where nothing is dropped, e.g. (drop-right lis 0).
(srfi 1) procedure (take! (x list?) (i integer?) ) ⟹ list?
(srfi 1) procedure (take! (x circular-list?) (i integer?) ) ⟹ list?
(srfi 1) procedure (take! (x dotted-list?) (i integer?) ) ⟹ list?
take!, drop-right! take! and drop-right! are "linear-update" variants of take and drop-right: the procedure is allowed, but not required, to alter the argument list to produce the result. If x is circular, take! may return a shorter-than-expected list
(srfi 1) procedure (drop-right! (flist list?) (i integer?) ) ⟹ list?
(srfi 1) procedure (drop-right! (flist dotted-list?) (i integer?) ) ⟹ list?
take!, drop-right! take! and drop-right! are "linear-update" variants of take and drop-right: the procedure is allowed, but not required, to alter the argument list to produce the result. If x is circular, take! may return a shorter-than-expected list
(srfi 1) procedure (split-at (x list?) (i integer?) ) ⟹ (values list?list?)
(srfi 1) procedure (split-at (x circular-list?) (i integer?) ) ⟹ (values list?circular-list?)
(srfi 1) procedure (split-at (x dotted-list?) (i integer?) ) ⟹ (values list?*)
split-at, split-at! split-at splits the list x at index i, returning a list of the first i elements, and the remaining tail. It is equivalent to (values (take x i) (drop x i)). split-at! is the linear-update variant. It is allowed, but not required, to alter the argument list to produce the result.
(srfi 1) procedure (split-at! (x list?) (i integer?) ) ⟹ (values list?list?)
(srfi 1) procedure (split-at! (x circular-list?) (i integer?) ) ⟹ (values list?circular-list?)
(srfi 1) procedure (split-at! (x dotted-list?) (i integer?) ) ⟹ (values list?*)
split-at, split-at! split-at splits the list x at index i, returning a list of the first i elements, and the remaining tail. It is equivalent to (values (take x i) (drop x i)). split-at! is the linear-update variant. It is allowed, but not required, to alter the argument list to produce the result.
(srfi 1) procedure (last (pair list?) ) ⟹ *
last, last-pair last returns the last element of the non-empty, finite list pair. last-pair returns the last pair in the non-empty, finite list pair.
(srfi 1) procedure (last-pair (pair list?) ) ⟹ pair?
last, last-pair last returns the last element of the non-empty, finite list pair. last-pair returns the last pair in the non-empty, finite list pair.
(srfi 1) procedure (length (list list?) ) ⟹ integer?
length, length+ Both length and length+ return the length of the argument. It is an error to pass a value to length which is not a proper list (finite and nil-terminated). In particular, this means an implementation may diverge or signal an error when length is applied to a circular list. length+, on the other hand, returns #F when applied to a circular list. The length of a proper list is a non-negative integer n such that cdr applied n times to the list produces the empty list.
(srfi 1) procedure (length+ (clist list?) ) ⟹ integer?
(srfi 1) procedure (length+ (clist circular-list?) ) ⟹ boolean?
length, length+ Both length and length+ return the length of the argument. It is an error to pass a value to length which is not a proper list (finite and nil-terminated). In particular, this means an implementation may diverge or signal an error when length is applied to a circular list. length+, on the other hand, returns #F when applied to a circular list. The length of a proper list is a non-negative integer n such that cdr applied n times to the list produces the empty list.
(srfi 1) procedure (append (list list?) ... ) ⟹ list?
(srfi 1) procedure (append (list list?) ... obj ) ⟹ *
append, append! append returns a list consisting of the elements of list1 followed by the elements of the other list parameters. The resulting list is always newly allocated, except that it shares structure with the final listi argument. This last argument may be any value at all; an improper list results if it is not a proper list. All other arguments must be proper lists. append! is the "linear-update" variant of append -- it is allowed, but not required, to alter cons cells in the argument lists to construct the result list. The last argument is never altered; the result list shares structure with this parameter.
(srfi 1) procedure (append! (list list?) ... ) ⟹ list?
(srfi 1) procedure (append! (list list?) ... obj ) ⟹ *
append, append! append returns a list consisting of the elements of list1 followed by the elements of the other list parameters. The resulting list is always newly allocated, except that it shares structure with the final listi argument. This last argument may be any value at all; an improper list results if it is not a proper list. All other arguments must be proper lists. append! is the "linear-update" variant of append -- it is allowed, but not required, to alter cons cells in the argument lists to construct the result list. The last argument is never altered; the result list shares structure with this parameter.
(srfi 1) procedure (concatenate (list-of-lists list?) ) ⟹ *
list-of-lists ⟹ (list (lst list?) )
concatenate, concatenate! These functions append the elements of their argument together. That is, concatenate returns (apply append list-of-lists) or, equivalently, (reduce-right append '() list-of-lists). concatenate! is the linear-update variant, defined in terms of append! instead of append. Note that some Scheme implementations do not support passing more than a certain number (e.g., 64) of arguments to an n-ary procedure. In these implementations, the (apply append ...) idiom would fail when applied to long lists, but concatenate would continue to function properly. As with append and append!, the last element of the input list may be any value at all.
(srfi 1) procedure (concatenate! (list-of-lists list?) ) ⟹ *
list-of-lists ⟹ (list (lst list?) )
concatenate, concatenate! These functions append the elements of their argument together. That is, concatenate returns (apply append list-of-lists) or, equivalently, (reduce-right append '() list-of-lists). concatenate! is the linear-update variant, defined in terms of append! instead of append. Note that some Scheme implementations do not support passing more than a certain number (e.g., 64) of arguments to an n-ary procedure. In these implementations, the (apply append ...) idiom would fail when applied to long lists, but concatenate would continue to function properly. As with append and append!, the last element of the input list may be any value at all.
(srfi 1) procedure (reverse (list list?) ) ⟹ list?
reverse, reverse! reverse returns a newly allocated list consisting of the elements of list in reverse order. reverse! is the linear-update variant of reverse. It is permitted, but not required, to alter the argument's cons cells to produce the reversed list.
(srfi 1) procedure (reverse! (list list?) ) ⟹ list?
reverse, reverse! reverse returns a newly allocated list consisting of the elements of list in reverse order. reverse! is the linear-update variant of reverse. It is permitted, but not required, to alter the argument's cons cells to produce the reversed list.
(srfi 1) procedure (append-reverse (rev-head list?) (tail list?) ) ⟹ list?
(srfi 1) procedure (append-reverse (rev-head list?) tail ) ⟹ *
append-reverse, append-reverse! append-reverse returns (append (reverse rev-head) tail). It is provided because it is a common operation -- a common list-processing style calls for this exact operation to transfer values accumulated in reverse order onto the front of another list, and because the implementation is significantly more efficient than the simple composition it replaces. (But note that this pattern of iterative computation followed by a reverse can frequently be rewritten as a recursion, dispensing with the reverse and append-reverse steps, and shifting temporary, intermediate storage from the heap to the stack, which is typically a win for reasons of cache locality and eager storage reclamation.) append-reverse! is just the linear-update variant -- it is allowed, but not required, to alter rev-head's cons cells to construct the result.
(srfi 1) procedure (append-reverse! (rev-head list?) (tail list?) ) ⟹ list?
(srfi 1) procedure (append-reverse! (rev-head list?) tail ) ⟹ *
append-reverse, append-reverse! append-reverse returns (append (reverse rev-head) tail). It is provided because it is a common operation -- a common list-processing style calls for this exact operation to transfer values accumulated in reverse order onto the front of another list, and because the implementation is significantly more efficient than the simple composition it replaces. (But note that this pattern of iterative computation followed by a reverse can frequently be rewritten as a recursion, dispensing with the reverse and append-reverse steps, and shifting temporary, intermediate storage from the heap to the stack, which is typically a win for reasons of cache locality and eager storage reclamation.) append-reverse! is just the linear-update variant -- it is allowed, but not required, to alter rev-head's cons cells to construct the result.
(srfi 1) procedure (zip (clist1 list?) (clist2 list?) ... ) ⟹ list?
(lambda lists (apply map list lists)). If zip is passed n lists, it returns a list as long as the shortest of these lists, each element of which is an n-element list comprised of the corresponding elements from the parameter lists. At least one of the argument lists must be finite.
(srfi 1) procedure (unzip1 (list list?) ) ⟹ list?
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(srfi 1) procedure (unzip2 (list list?) ) ⟹ (values list?list?)
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(srfi 1) procedure (unzip3 (list list?) ) ⟹ (values list?list?list?)
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(srfi 1) procedure (unzip4 (list list?) ) ⟹ (values list?list?list?list?)
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(srfi 1) procedure (unzip5 (list list?) ) ⟹ (values list?list?list?list?list?)
unzip1 takes a list of lists, where every list must contain at least one element, and returns a list containing the initial element of each such list. That is, it returns (map car lists). unzip2 takes a list of lists, where every list must contain at least two elements, and returns two values: a list of the first elements, and a list of the second elements. unzip3 does the same for the first three elements of the lists, and so forth.
(srfi 1) procedure (count (pred procedure?) (clist1 list?) (clist2 list?) ... ) ⟹ integer?
(pred obj ... ) ⟹ *
pred is a procedure taking as many arguments as there are lists and returning a single value. It is applied element-wise to the elements of the lists, and a count is tallied of the number of elements that produce a true value. This count is returned. count is "iterative" in that it is guaranteed to apply pred to the list elements in a left-to-right order. The counting stops when the shortest list expires. At least one of the argument lists must be finite.
(srfi 1) procedure (fold (kons procedure?) knil (clist1 list?) (clist2 list?) ... ) ⟹ *
(kons obj1 obj2 ... fold-state ) ⟹ *
The fundamental list iterator. First, consider the single list-parameter case. If clist1 = (e1 e2 ... en), then this procedure returns (kons en ... (kons e2 (kons e1 knil)) ... ). If n list arguments are provided, then the kons function must take n+1 parameters: one element from each list, and the "seed" or fold state, which is initially knil. The fold operation terminates when the shortest list runs out of values. At least one of the list arguments must be finite.
(srfi 1) procedure (fold-right (kons procedure?) knil (clist1 list?) (clist2 list?) ... ) ⟹ *
(kons obj1 obj2 ... fold-state ) ⟹ *
The fundamental list recursion operator. First, consider the single list-parameter case. If clist1 = (e1 e2 ... en), then this procedure returns (kons e1 (kons e2 ... (kons en knil))). If n list arguments are provided, then the kons function must take n+1 parameters: one element from each list, and the "seed" or fold state, which is initially knil. The fold operation terminates when the shortest list runs out of values. At least one of the list arguments must be finite.
(srfi 1) procedure (pair-fold (kons procedure?) knil (clist1 list?) (clist2 list?) ... ) ⟹ *
(kons (pair1 pair?) (pair2 pair?) ... fold-state ) ⟹ *
Analogous to fold, but kons is applied to successive sublists of the lists, rather than successive elements -- that is, kons is applied to the pairs making up the lists. For finite lists, the kons function may reliably apply set-cdr! to the pairs it is given without altering the sequence of execution. At least one of the list arguments must be finite.
(srfi 1) procedure (pair-fold-right (kons procedure?) knil (clist1 list?) (clist2 list?) ... ) ⟹ *
(kons (pair1 pair?) (pair2 pair?) ... fold-state ) ⟹ *
Holds the same relationship with fold-right that pair-fold holds with fold. At least one of the list arguments must be finite.
(srfi 1) procedure (reduce (f procedure?) ridentity (list list?) ) ⟹ *
(f obj fold-state ) ⟹ *
reduce is a variant of fold. ridentity should be a "right identity" of the procedure f -- that is, for any value x acceptable to f, (f x ridentity) = x. reduce has the following definition: If list = (), return ridentity; Otherwise, return (fold f (car list) (cdr list)). ...in other words, we compute (fold f ridentity list). Note that ridentity is used only in the empty-list case. You typically use reduce when applying f is expensive and you'd like to avoid the extra application incurred when fold applies f to the head of list and the identity value, redundantly producing the same value passed in to f. For example, if f involves searching a file directory or performing a database query, this can be significant. In general, however, fold is useful in many contexts where reduce is not (consider the examples given in the fold definition -- only one of the five folds uses a function with a right identity. The other four may not be performed with reduce). Note: MIT Scheme and Haskell flip F's arg order for their reduce and fold functions.
(srfi 1) procedure (reduce-right (f procedure?) ridentity (list list?) ) ⟹ *
(f obj fold-state ) ⟹ *
reduce-right is the fold-right variant of reduce.
(srfi 1) procedure (unfold (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ list?
(srfi 1) procedure (unfold (p procedure?) (f procedure?) (g procedure?) seed (tail-gen list?) ) ⟹ *
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(tail-gen ) ⟹ *
unfold is best described by its basic recursion: (unfold p f g seed) = (if (p seed) (tail-gen seed) (cons (f seed) (unfold p f g (g seed)))). p determines when to stop unfolding. f maps each seed value to the corresponding list element. g maps each seed value to next seed value. seed the "state" value for the unfold. tail-gen creates the tail of the list; defaults to (lambda (x) '()). In other words, we use g to generate a sequence of seed values seed, g(seed), g2(seed), g3(seed), ... These seed values are mapped to list elements by f, producing the elements of the result list in a left-to-right order. P says when to stop. unfold is the fundamental recursive list constructor, just as fold-right is the fundamental recursive list consumer.
(srfi 1) procedure (unfold-right (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ list?
(srfi 1) procedure (unfold-right (p procedure?) (f procedure?) (g procedure?) seed (tail-gen list?) ) ⟹ *
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(tail-gen ) ⟹ *
unfold-right constructs a list with the following loop: (let lp ((seed seed) (lis tail)) (if (p seed) lis (lp (g seed) (cons (f seed) lis)))). p determines when to stop unfolding. f maps each seed value to the corresponding list element. g maps each seed value to next seed value. seed the "state" value for the unfold. tail list terminator; defaults to '(). In other words, we use g to generate a sequence of seed values seed, g(seed), g2(seed), g3(seed), ... These seed values are mapped to list elements by f, producing the elements of the result list in a right-to-left order. P says when to stop. unfold-right is the fundamental iterative list constructor, just as fold is the fundamental iterative list consumer.
(srfi 1) procedure (map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ *
proc is a procedure taking as many arguments as there are list arguments and returning a single value. 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. his procedure is extended from its R5RS specification to allow the arguments to be of unequal length; it terminates when the shortest list runs out. At least one of the argument lists must be finite.
(srfi 1) 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. This procedure is extended from its R5RS specification to allow the arguments to be of unequal length; it terminates when the shortest list runs out. At least one of the argument lists must be finite.
(srfi 1) procedure (append-map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ list?
append-map, append-map! Equivalent to (apply append (map f clist1 clist2 ...)) and (apply append! (map f clist1 clist2 ...)). Map f over the elements of the lists, just as in the map function. However, the results of the applications are appended together to make the final result. append-map uses append to append the results together; append-map! uses append!. The dynamic order in which the various applications of f are made is not specified.
(srfi 1) procedure (append-map! (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 objs2 ... ) ⟹ list?
append-map, append-map! Equivalent to (apply append (map f clist1 clist2 ...)) and (apply append! (map f clist1 clist2 ...)). Map f over the elements of the lists, just as in the map function. However, the results of the applications are appended together to make the final result. append-map uses append to append the results together; append-map! uses append!. The dynamic order in which the various applications of f are made is not specified.
(srfi 1) procedure (map! (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ *
Linear-update variant of map -- map! is allowed, but not required, to alter the cons cells of list1 to construct the result list. The dynamic order in which the various applications of f are made is not specified. In the n-ary case, clist2, clist3, ... must have at least as many elements as list1.
(srfi 1) procedure (map-in-order (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ *
A variant of the map procedure that guarantees to apply f across the elements of the listi arguments in a left-to-right order. This is useful for mapping procedures that both have side effects and return useful values. At least one of the list arguments must be finite.
(srfi 1) procedure (pair-for-each (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ undefined
(proc (obj1 pair?) (obj2 pair?) ... ) ⟹ undefined
Like for-each, but f is applied to successive sublists of the argument lists. That is, f is applied to the cons cells of the lists, rather than the lists' elements. These applications occur in left-to-right order. The f procedure may reliably apply set-cdr! to the pairs it is given without altering the sequence of execution.
(srfi 1) procedure (filter-map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ *
Like map, but only true values are saved. The dynamic order in which the various applications of f are made is not specified. At least one of the list arguments must be finite.
(srfi 1) procedure (filter (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
Return all the elements of list that satisfy predicate pred. The list is not disordered -- elements that appear in the result list occur in the same order as they occur in the argument list. The returned list may share a common tail with the argument list. The dynamic order in which the various applications of pred are made is not specified.
(srfi 1) procedure (filter! (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
filter!, partition!, remove! Linear-update variants of filter, partition and remove. These procedures are allowed, but not required, to alter the cons cells in the argument list to construct the result lists.
(srfi 1) procedure (partition (pred procedure?) (list list?) ) ⟹ (values list?list?)
(pred obj ) ⟹ *
Partitions the elements of list with predicate pred, and returns two values: the list of in-elements and the list of out-elements. The list is not disordered -- elements occur in the result lists in the same order as they occur in the argument list. The dynamic order in which the various applications of pred are made is not specified. One of the returned lists may share a common tail with the argument list.
(srfi 1) procedure (partition! (pred procedure?) (list list?) ) ⟹ (values list?list?)
(pred obj ) ⟹ *
filter!, partition!, remove! Linear-update variants of filter, partition and remove. These procedures are allowed, but not required, to alter the cons cells in the argument list to construct the result lists.
(srfi 1) procedure (remove (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
Returns list without the elements that satisfy predicate pred: (lambda (pred list) (filter (lambda (x) (not (pred x))) list)). The list is not disordered -- elements that appear in the result list occur in the same order as they occur in the argument list. The returned list may share a common tail with the argument list. The dynamic order in which the various applications of pred are made is not specified.
(srfi 1) procedure (remove! (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
filter!, partition!, remove! Linear-update variants of filter, partition and remove. These procedures are allowed, but not required, to alter the cons cells in the argument list to construct the result lists.
(srfi 1) procedure (find (pred procedure?) (list list?) ) ⟹ *
(pred obj ) ⟹ *
Return the first element of clist that satisfies predicate pred; false if no element does. Note that find has an ambiguity in its lookup semantics -- if find returns #f, you cannot tell (in general) if it found a #f element that satisfied pred, or if it did not find any element at all. In many situations, this ambiguity cannot arise -- either the list being searched is known not to contain any #f elements, or the list is guaranteed to have an element satisfying pred. However, in cases where this ambiguity can arise, you should use find-tail instead of find -- find-tail has no such ambiguity.
(srfi 1) procedure (find-tail (pred procedure?) (list list?) ) ⟹ pair? / #f /
(pred obj ) ⟹ *
Return the first pair of clist whose car satisfies pred. If no pair does, return false. find-tail can be viewed as a general-predicate variant of the member function. In the circular-list case, this procedure "rotates" the list. Find-tail is essentially drop-while, where the sense of the predicate is inverted: Find-tail searches until it finds an element satisfying the predicate; drop-while searches until it finds an element that doesn't satisfy the predicate.
(srfi 1) procedure (take-while (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
take-while, take-while! Returns the longest initial prefix of clist whose elements all satisfy the predicate pred. Take-while! is the linear-update variant. It is allowed, but not required, to alter the argument list to produce the result.
(srfi 1) procedure (take-while! (pred procedure?) (list list?) ) ⟹ list?
(pred obj ) ⟹ *
take-while, take-while! Returns the longest initial prefix of clist whose elements all satisfy the predicate pred. Take-while! is the linear-update variant. It is allowed, but not required, to alter the argument list to produce the result.
(srfi 1) procedure (drop-while (pred procedure?) (list list?) ) ⟹ list?
(srfi 1) procedure (drop-while (pred procedure?) (list circular-list?) ) ⟹ circular-list?
(pred obj ) ⟹ *
Drops the longest initial prefix of clist whose elements all satisfy the predicate pred, and returns the rest of the list. The circular-list case may be viewed as "rotating" the list.
(srfi 1) procedure (span (pred procedure?) (list list?) ) ⟹ (values list?list?)
(srfi 1) procedure (span (pred procedure?) (list circular-list?) ) ⟹ (values list?circular-list?)
(pred obj ) ⟹ *
span, span!, break, break! Span splits the list into the longest initial prefix whose elements all satisfy pred, and the remaining tail. Break inverts the sense of the predicate: the tail commences with the first element of the input list that satisfies the predicate. In other words: span finds the intial span of elements satisfying pred, and break breaks the list at the first element satisfying pred. Span is equivalent to (values (take-while pred clist) (drop-while pred clist)). Span! and break! are the linear-update variants. They are allowed, but not required, to alter the argument list to produce the result.
(srfi 1) procedure (span! (pred procedure?) (list list?) ) ⟹ (values list?list?)
(pred obj ) ⟹ *
span, span!, break, break! Span splits the list into the longest initial prefix whose elements all satisfy pred, and the remaining tail. Break inverts the sense of the predicate: the tail commences with the first element of the input list that satisfies the predicate. In other words: span finds the intial span of elements satisfying pred, and break breaks the list at the first element satisfying pred. Span is equivalent to (values (take-while pred clist) (drop-while pred clist)). Span! and break! are the linear-update variants. They are allowed, but not required, to alter the argument list to produce the result.
(srfi 1) procedure (break (pred procedure?) (list list?) ) ⟹ (values list?list?)
(srfi 1) procedure (break (pred procedure?) (list circular-list?) ) ⟹ (values list?circular-list?)
(pred obj ) ⟹ *
span, span!, break, break! Span splits the list into the longest initial prefix whose elements all satisfy pred, and the remaining tail. Break inverts the sense of the predicate: the tail commences with the first element of the input list that satisfies the predicate. In other words: span finds the intial span of elements satisfying pred, and break breaks the list at the first element satisfying pred. Span is equivalent to (values (take-while pred clist) (drop-while pred clist)). Span! and break! are the linear-update variants. They are allowed, but not required, to alter the argument list to produce the result.
(srfi 1) procedure (break! (pred procedure?) (list list?) ) ⟹ (values list?list?)
(pred obj ) ⟹ *
span, span!, break, break! Span splits the list into the longest initial prefix whose elements all satisfy pred, and the remaining tail. Break inverts the sense of the predicate: the tail commences with the first element of the input list that satisfies the predicate. In other words: span finds the intial span of elements satisfying pred, and break breaks the list at the first element satisfying pred. Span is equivalent to (values (take-while pred clist) (drop-while pred clist)). Span! and break! are the linear-update variants. They are allowed, but not required, to alter the argument list to produce the result.
(srfi 1) procedure (any (pred procedure?) (clist1 list?) (clist2 list?) ... ) ⟹ *
(pred obj1 obj2 ... ) ⟹ *
Applies the predicate across the lists, returning true if the predicate returns true on any application. If there are n list arguments clist1 ... clistn, then pred must be a procedure taking n arguments and returning a single value, interpreted as a boolean (that is, #f means false, and any other value means true). any applies pred to the first elements of the clisti parameters. If this application returns a true value, any immediately returns that value. Otherwise, it iterates, applying pred to the second elements of the clisti parameters, then the third, and so forth. The iteration stops when a true value is produced or one of the lists runs out of values; in the latter case, any returns #f. The application of pred to the last element of the lists is a tail call. Note the difference between find and any -- find returns the element that satisfied the predicate; any returns the true value that the predicate produced. Like every, any's name does not end with a question mark -- this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(srfi 1) procedure (every (pred procedure?) (clist1 list?) (clist2 list?) ... ) ⟹ *
(pred obj1 obj2 ... ) ⟹ *
Applies the predicate across the lists, returning true if the predicate returns true on every application. If there are n list arguments clist1 ... clistn, then pred must be a procedure taking n arguments and returning a single value, interpreted as a boolean (that is, #f means false, and any other value means true). every applies pred to the first elements of the clisti parameters. If this application returns false, every immediately returns false. Otherwise, it iterates, applying pred to the second elements of the clisti parameters, then the third, and so forth. The iteration stops when a false value is produced or one of the lists runs out of values. In the latter case, every returns the true value produced by its final application of pred. The application of pred to the last element of the lists is a tail call. If one of the clisti has no elements, every simply returns #t. Like any, every's name does not end with a question mark -- this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(srfi 1) procedure (list-index (pred procedure?) (clist1 list?) (clist2 list?) ... ) ⟹ integer? / #f /
(pred obj1 obj2 ... ) ⟹ *
Return the index of the leftmost element that satisfies pred. If there are n list arguments clist1 ... clistn, then pred must be a function taking n arguments and returning a single value, interpreted as a boolean (that is, #f means false, and any other value means true). list-index applies pred to the first elements of the clisti parameters. If this application returns true, list-index immediately returns zero. Otherwise, it iterates, applying pred to the second elements of the clisti parameters, then the third, and so forth. When it finds a tuple of list elements that cause pred to return true, it stops and returns the zero-based index of that position in the lists. The iteration stops when one of the lists runs out of values; in this case, list-index returns #f.
(srfi 1) procedure (member obj (list list?) ) ⟹ #f / list? /
(srfi 1) procedure (member obj (list list?) (= procedure?) ) ⟹ #f / list? /
(= obj1 obj2 ) ⟹ *
member, memq, memv These procedures return the first sublist of list whose car is x, where the sublists of list are the non-empty lists returned by (drop list i) for i less than the length of list. If x does not occur in list, then #f is returned. memq uses eq? to compare x with the elements of list, while memv uses eqv?, and member uses equal?. member is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key x in this way: (= x ei) ; list is (E1 ... En). That is, the first argument is always x, and the second argument is one of the list elements. Thus one can reliably find the first element of list that is greater than five with (member 5 list <). Note that fully general list searching may be performed with the find-tail and find procedures.
(srfi 1) procedure (memq obj (list list?) ) ⟹ #f / list? /
member, memq, memv These procedures return the first sublist of list whose car is x, where the sublists of list are the non-empty lists returned by (drop list i) for i less than the length of list. If x does not occur in list, then #f is returned. memq uses eq? to compare x with the elements of list, while memv uses eqv?, and member uses equal?. member is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key x in this way: (= x ei) ; list is (E1 ... En). That is, the first argument is always x, and the second argument is one of the list elements. Thus one can reliably find the first element of list that is greater than five with (member 5 list <). Note that fully general list searching may be performed with the find-tail and find procedures.
(srfi 1) procedure (memv obj (list list?) ) ⟹ #f / list? /
member, memq, memv These procedures return the first sublist of list whose car is x, where the sublists of list are the non-empty lists returned by (drop list i) for i less than the length of list. If x does not occur in list, then #f is returned. memq uses eq? to compare x with the elements of list, while memv uses eqv?, and member uses equal?. member is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key x in this way: (= x ei) ; list is (E1 ... En). That is, the first argument is always x, and the second argument is one of the list elements. Thus one can reliably find the first element of list that is greater than five with (member 5 list <). Note that fully general list searching may be performed with the find-tail and find procedures.
(srfi 1) procedure (delete obj (list list?) ) ⟹ list?
(srfi 1) procedure (delete obj (list list?) (= procedure?) ) ⟹ list?
(= obj1 obj2 ) ⟹ *
delete, delete! delete uses the comparison procedure =, which defaults to equal?, to find all elements of list that are equal to x, and deletes them from list. The dynamic order in which the various applications of = are made is not specified. The list is not disordered -- elements that appear in the result list occur in the same order as they occur in the argument list. The result may share a common tail with the argument list. Note that fully general element deletion can be performed with the remove and remove! procedures. The comparison procedure is used in this way: (= x ei). That is, x is always the first argument, and a list element is always the second argument. The comparison procedure will be used to compare each element of list exactly once; the order in which it is applied to the various ei is not specified. Thus, one can reliably remove all the numbers greater than five from a list with (delete 5 list <). delete! is the linear-update variant of delete. It is allowed, but not required, to alter the cons cells in its argument list to construct the result.
(srfi 1) procedure (delete! obj (list list?) ) ⟹ list?
(srfi 1) procedure (delete! obj (list list?) (= procedure?) ) ⟹ list?
(= obj1 obj2 ) ⟹ *
delete, delete! delete uses the comparison procedure =, which defaults to equal?, to find all elements of list that are equal to x, and deletes them from list. The dynamic order in which the various applications of = are made is not specified. The list is not disordered -- elements that appear in the result list occur in the same order as they occur in the argument list. The result may share a common tail with the argument list. Note that fully general element deletion can be performed with the remove and remove! procedures. The comparison procedure is used in this way: (= x ei). That is, x is always the first argument, and a list element is always the second argument. The comparison procedure will be used to compare each element of list exactly once; the order in which it is applied to the various ei is not specified. Thus, one can reliably remove all the numbers greater than five from a list with (delete 5 list <). delete! is the linear-update variant of delete. It is allowed, but not required, to alter the cons cells in its argument list to construct the result.
(srfi 1) procedure (delete-duplicates (list list?) ) ⟹ list?
(srfi 1) procedure (delete-duplicates (list list?) (= procedure?) ) ⟹ list?
(= obj1 obj2 ) ⟹ *
delete-duplicates, delete-duplicates! delete-duplicates removes duplicate elements from the list argument. If there are multiple equal elements in the argument list, the result list only contains the first or leftmost of these elements in the result. The order of these surviving elements is the same as in the original list -- delete-duplicates does not disorder the list (hence it is useful for "cleaning up" association lists). The = parameter is used to compare the elements of the list; it defaults to equal?. If x comes before y in list, then the comparison is performed (= x y). The comparison procedure will be used to compare each pair of elements in list no more than once; the order in which it is applied to the various pairs is not specified. Implementations of delete-duplicates are allowed to share common tails between argument and result lists -- for example, if the list argument contains only unique elements, it may simply return exactly this list. Be aware that, in general, delete-duplicates runs in time O(n2) for n-element lists. Uniquifying long lists can be accomplished in O(n lg n) time by sorting the list to bring equal elements together, then using a linear-time algorithm to remove equal elements. Alternatively, one can use algorithms based on element-marking, with linear-time results. delete-duplicates! is the linear-update variant of delete-duplicates; it is allowed, but not required, to alter the cons cells in its argument list to construct the result.
(srfi 1) procedure (delete-duplicates! (list list?) ) ⟹ list?
(srfi 1) procedure (delete-duplicates! (list list?) (= procedure?) ) ⟹ list?
(= obj1 obj2 ) ⟹ *
delete-duplicates, delete-duplicates! delete-duplicates removes duplicate elements from the list argument. If there are multiple equal elements in the argument list, the result list only contains the first or leftmost of these elements in the result. The order of these surviving elements is the same as in the original list -- delete-duplicates does not disorder the list (hence it is useful for "cleaning up" association lists). The = parameter is used to compare the elements of the list; it defaults to equal?. If x comes before y in list, then the comparison is performed (= x y). The comparison procedure will be used to compare each pair of elements in list no more than once; the order in which it is applied to the various pairs is not specified. Implementations of delete-duplicates are allowed to share common tails between argument and result lists -- for example, if the list argument contains only unique elements, it may simply return exactly this list. Be aware that, in general, delete-duplicates runs in time O(n2) for n-element lists. Uniquifying long lists can be accomplished in O(n lg n) time by sorting the list to bring equal elements together, then using a linear-time algorithm to remove equal elements. Alternatively, one can use algorithms based on element-marking, with linear-time results. delete-duplicates! is the linear-update variant of delete-duplicates; it is allowed, but not required, to alter the cons cells in its argument list to construct the result.
(srfi 1) procedure (assoc obj (alist list?) ) ⟹ list? / #f /
(srfi 1) procedure (assoc obj (alist list?) (= procedure?) ) ⟹ pair? / #f /
(= a b ) ⟹ *
assoc, assq, assv alist must be an association list -- a list of pairs. These procedures find the first pair in alist whose car field is key, and returns that pair. If no pair in alist has key as its car, then #f is returned. assq uses eq? to compare key with the car fields of the pairs in alist, while assv uses eqv? and assoc uses equal?. assoc is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key parameter in this way: (= key (car ei)) ; list is (E1 ... En). That is, the first argument is always key, and the second argument is one of the list elements. Thus one can reliably find the first entry of alist whose key is greater than five with (assoc 5 alist <). Note that fully general alist searching may be performed with the find-tail and find procedures
(srfi 1) procedure (assq obj (alist list?) ) ⟹ pair? / #f /
assoc, assq, assv alist must be an association list -- a list of pairs. These procedures find the first pair in alist whose car field is key, and returns that pair. If no pair in alist has key as its car, then #f is returned. assq uses eq? to compare key with the car fields of the pairs in alist, while assv uses eqv? and assoc uses equal?. assoc is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key parameter in this way: (= key (car ei)) ; list is (E1 ... En). That is, the first argument is always key, and the second argument is one of the list elements. Thus one can reliably find the first entry of alist whose key is greater than five with (assoc 5 alist <). Note that fully general alist searching may be performed with the find-tail and find procedures
(srfi 1) procedure (assv obj (alist list?) ) ⟹ pair? / #f /
assoc, assq, assv alist must be an association list -- a list of pairs. These procedures find the first pair in alist whose car field is key, and returns that pair. If no pair in alist has key as its car, then #f is returned. assq uses eq? to compare key with the car fields of the pairs in alist, while assv uses eqv? and assoc uses equal?. assoc is extended from its R5RS definition to allow the client to pass in an optional equality procedure = used to compare keys. The comparison procedure is used to compare the elements ei of list to the key parameter in this way: (= key (car ei)) ; list is (E1 ... En). That is, the first argument is always key, and the second argument is one of the list elements. Thus one can reliably find the first entry of alist whose key is greater than five with (assoc 5 alist <). Note that fully general alist searching may be performed with the find-tail and find procedures
(srfi 1) procedure (alist-cons key datum (alist list?) ) ⟹ list?
(lambda (key datum alist) (cons (cons key datum) alist)) Cons a new alist entry mapping key -> datum onto alist.
(srfi 1) procedure (alist-copy (alist list?) ) ⟹ list?
Make a fresh copy of alist. This means copying each pair that forms an association as well as the spine of the list.
(srfi 1) procedure (alist-delete key (alist list?) ) ⟹ list?
(srfi 1) procedure (alist-delete key (alist list?) (= procedure?) ) ⟹ list?
(= a b ) ⟹ *
alist-delete, alist-delete! alist-delete deletes all associations from alist with the given key, using key-comparison procedure =, which defaults to equal?. The dynamic order in which the various applications of = are made is not specified. Return values may share common tails with the alist argument. The alist is not disordered -- elements that appear in the result alist occur in the same order as they occur in the argument alist. The comparison procedure is used to compare the element keys ki of alist's entries to the key parameter in this way: (= key ki). Thus, one can reliably remove all entries of alist whose key is greater than five with (alist-delete 5 alist <). alist-delete! is the linear-update variant of alist-delete. It is allowed, but not required, to alter cons cells from the alist parameter to construct the result.
(srfi 1) procedure (alist-delete! key (alist list?) ) ⟹ list?
(srfi 1) procedure (alist-delete! key (alist list?) (= procedure?) ) ⟹ list?
(= a b ) ⟹ *
alist-delete, alist-delete! alist-delete deletes all associations from alist with the given key, using key-comparison procedure =, which defaults to equal?. The dynamic order in which the various applications of = are made is not specified. Return values may share common tails with the alist argument. The alist is not disordered -- elements that appear in the result alist occur in the same order as they occur in the argument alist. The comparison procedure is used to compare the element keys ki of alist's entries to the key parameter in this way: (= key ki). Thus, one can reliably remove all entries of alist whose key is greater than five with (alist-delete 5 alist <). alist-delete! is the linear-update variant of alist-delete. It is allowed, but not required, to alter cons cells from the alist parameter to construct the result.
(srfi 1) procedure (lset<= (= procedure?) (list1 list?) ... ) ⟹ boolean?
(= a b ) ⟹ *
Returns true iff every listi is a subset of listi+1, using = for the element-equality procedure. List A is a subset of list B if every element in A is equal to some element of B. When performing an element comparison, the = procedure's first argument is an element of A; its second, an element of B.
(srfi 1) procedure (lset= (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ boolean?
(= a b ) ⟹ *
Returns true iff every listi is set-equal to listi+1, using = for the element-equality procedure. "Set-equal" simply means that listi is a subset of listi+1, and listi+1 is a subset of listi. The = procedure's first argument is an element of listi; its second is an element of listi+1.
(srfi 1) procedure (lset-adjoin (= procedure?) (list list?) elt1 ... ) ⟹ list?
(= a b ) ⟹ *
Adds the elti elements not already in the list parameter to the result list. The result shares a common tail with the list parameter. The new elements are added to the front of the list, but no guarantees are made about their order. The = parameter is an equality procedure used to determine if an elti is already a member of list. Its first argument is an element of list; its second is one of the elti. The list parameter is always a suffix of the result -- even if the list parameter contains repeated elements, these are not reduced.
(srfi 1) procedure (lset-union (= procedure?) (list1 list?) ... ) ⟹ list?
(= a b ) ⟹ *
Returns the union of the lists, using = for the element-equality procedure. The union of lists A and B is constructed as follows: If A is the empty list, the answer is B (or a copy of B). Otherwise, the result is initialised to be list A (or a copy of A). Proceed through the elements of list B in a left-to-right order. If b is such an element of B, compare every element r of the current result list to b: (= r b). If all comparisons fail, b is consed onto the front of the result. However, there is no guarantee that = will be applied to every pair of arguments from A and B. In particular, if A is eq? to B, the operation may immediately terminate. In the n-ary case, the two-argument list-union operation is simply folded across the argument lists.
(srfi 1) procedure (lset-union! (= procedure?) (list1 list?) ... ) ⟹ list?
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(srfi 1) procedure (lset-intersection (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(= a b ) ⟹ *
Returns the intersection of the lists, using = for the element-equality procedure. The intersection of lists A and B is comprised of every element of A that is = to some element of B: (= a b), for a in A, and b in B. Note this implies that an element which appears in B and multiple times in list A will also appear multiple times in the result. The order in which elements appear in the result is the same as they appear in list1 -- that is, lset-intersection essentially filters list1, without disarranging element order. The result may share a common tail with list1. In the n-ary case, the two-argument list-intersection operation is simply folded across the argument lists. However, the dynamic order in which the applications of = are made is not specified. The procedure may check an element of list1 for membership in every other list before proceeding to consider the next element of list1, or it may completely intersect list1 and list2 before proceeding to list3, or it may go about its work in some third order.
(srfi 1) procedure (lset-intersection! (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(srfi 1) procedure (lset-difference (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(= a b ) ⟹ *
Returns the difference of the lists, using = for the element-equality procedure -- all the elements of list1 that are not = to any element from one of the other listi parameters. The = procedure's first argument is always an element of list1; its second is an element of one of the other listi. Elements that are repeated multiple times in the list1 parameter will occur multiple times in the result. The order in which elements appear in the result is the same as they appear in list1 -- that is, lset-difference essentially filters list1, without disarranging element order. The result may share a common tail with list1. The dynamic order in which the applications of = are made is not specified. The procedure may check an element of list1 for membership in every other list before proceeding to consider the next element of list1, or it may completely compute the difference of list1 and list2 before proceeding to list3, or it may go about its work in some third order.
(srfi 1) procedure (lset-difference! (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(srfi 1) procedure (lset-xor (= procedure?) (list1 list?) ... ) ⟹ list?
(= a b ) ⟹ *
Returns the exclusive-or of the sets, using = for the element-equality procedure. If there are exactly two lists, this is all the elements that appear in exactly one of the two lists. The operation is associative, and thus extends to the n-ary case -- the elements that appear in an odd number of the lists. The result may share a common tail with any of the listi parameters. More precisely, for two lists A and B, A xor B is a list of every element a of A such that there is no element b of B such that (= a b), and every element b of B such that there is no element a of A such that (= b a). However, an implementation is allowed to assume that = is symmetric -- that is, that (= a b) => (= b a). This means, for example, that if a comparison (= a b) produces true for some a in A and b in B, both a and b may be removed from inclusion in the result. In the n-ary case, the binary-xor operation is simply folded across the lists.
(srfi 1) procedure (lset-xor! (= procedure?) (list1 list?) ... ) ⟹ list?
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(srfi 1) procedure (lset-diff+intersection (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ (values list?list?)
(= a b ) ⟹ *
Returns two values -- the difference and the intersection of the lists. Is equivalent to (values (lset-difference = list1 list2 ...) (lset-intersection = list1 (lset-union = list2 ...))) but can be implemented more efficiently. The = procedure's first argument is an element of list1; its second is an element of one of the other listi. Either of the answer lists may share a common tail with list1. This operation essentially partitions list1.
(srfi 1) procedure (lset-diff+intersection! (= procedure?) (list1 list?) (list2 list?) ... ) ⟹ (values list?list?)
(= a b ) ⟹ *
lset-union!, lset-intersection!, lset-difference!, lset-xor!, lset-diff+intersection! These are linear-update variants. They are allowed, but not required, to use the cons cells in their first list parameter to construct their answer. lset-union! is permitted to recycle cons cells from any of its list arguments.
(srfi 1) procedure (set-car! (pair pair?) object ) ⟹ undefined
set-car!, set-cdr! These procedures store object in the car and cdr field of pair, respectively. The value returned is unspecified.
(srfi 1) procedure (set-cdr! (pair pair?) object ) ⟹ undefined
set-car!, set-cdr! These procedures store object in the car and cdr field of pair, respectively. The value returned is unspecified.
library (srfi 2)
(srfi 2) syntax (and-let* () ((_ (claw ...) body)) )
(variable expression) (expression) bound-variable
In case of an ordinary AND formed of proper boolean expressions: (AND E1 E2 ...) expression E2, if it gets to be evaluated, knows that E1 has returned non-#f. Moreover, E2 knows exactly what the result of E1 was -- #t -- which E2 can use to its advantage. If E1 however is an extended boolean expression, E2 can no longer tell which particular non-#f value E1 has returned. Chances are it took a lot of work to evaluate E1, and the produced result (a number, a vector, a string, etc) may be of value to E2. Alas, the AND form merely checks that the result is not an #f, and throws it away. If E2 needs it, it has to compute that value anew. This proposed AND-LET* special form lets constituent expressions get hold of the results of already evaluated expressions, without re-doing their work.
AND-LET* can be thought of as a combination of LET* and AND, or a generalization of COND's send operator =>. An AND-LET* form can also be considered a sequence of guarded expressions. In a regular program, forms may produce results, bind them to variables and let other forms use these results. AND-LET* differs in that it checks to make sure that every produced result "makes sense" (that is, not an #f). The first "failure" triggers the guard and aborts the rest of the sequence (which presumably would not make any sense to execute anyway).
library (srfi 4)
(srfi 4) procedure (u8vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous u8vector, #f otherwise.
(srfi 4) procedure (make-u8vector (size integer?) ) ⟹ u8vector?
(srfi 4) procedure (make-u8vector (size integer?) (fill integer?) ) ⟹ u8vector?
Create homogenous u8 vector. If fill is given, it must be unsigned exact integer in the range 0 to (2^8)-1. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the u8vector.
(srfi 4) procedure (u8vector (value integer?) ... ) ⟹ u8vector?
Create homogenous u8 vector. Each value must be unsigned exact integer in the range 0 to (2^8)-1.
(srfi 4) procedure (u8vector-length (vec u8vector?) ) ⟹ integer?
Returns the number of elements in u8vector as an exact integer.
(srfi 4) procedure (u8vector-ref (vec u8vector?) (i integer?) ) ⟹ integer?
Returns i-th element in the vector. i must be in range [0, (u8vector-length vec))
(srfi 4) procedure (u8vector-set! (vec u8vector?) (i integer?) (value integer?) ) ⟹ undefined
u8vector-set! stores value in element k of vector. Value must be unsigned exact integer in the range 0 to (2^8)-1. i must be in range [0, (u8vector-length vec))
(srfi 4) procedure (u8vector->list (vec u8vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->u8vector (proper-list list?) ) ⟹ u8vector?
proper-list ⟹ (list integer? )
Converts a list to a homogenous u8vector. Each element in input list must be unsigned exact integer in the range 0 to (2^8)-1.
library (srfi 4)
(srfi 4) procedure (s8vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous s8vector, #f otherwise.
(srfi 4) procedure (make-s8vector (size integer?) ) ⟹ s8vector?
(srfi 4) procedure (make-s8vector (size integer?) (fill integer?) ) ⟹ s8vector?
Create homogenous s8 vector. If fill is given, it must be signed exact integer in the range -(2^7) to (2^7)-1. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the s8vector.
(srfi 4) procedure (s8vector (value integer?) ... ) ⟹ s8vector?
Create homogenous s8 vector. Each value must be signed exact integer in the range -(2^7) to (2^7)-1.
(srfi 4) procedure (s8vector-length (vec s8vector?) ) ⟹ integer?
Returns the number of elements in s8vector as an exact integer.
(srfi 4) procedure (s8vector-ref (vec s8vector?) (i integer?) ) ⟹ integer?
Returns i-th element in the vector. i must be in range [0, (s8vector-length vec))
(srfi 4) procedure (s8vector-set! (vec s8vector?) (i integer?) (value integer?) ) ⟹ undefined
s8vector-set! stores value in element k of vector. Value must be signed exact integer in the range -(2^7) to (2^7)-1. i must be in range [0, (s8vector-length vec))
(srfi 4) procedure (s8vector->list (vec s8vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->s8vector (proper-list list?) ) ⟹ s8vector?
proper-list ⟹ (list integer? )
Converts a list to a homogenous s8vector. Each element in input list must be signed exact integer in the range -(2^7) to (2^7)-1.
library (srfi 4)
(srfi 4) procedure (u16vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous u16vector, #f otherwise.
(srfi 4) procedure (make-u16vector (size integer?) ) ⟹ u16vector?
(srfi 4) procedure (make-u16vector (size integer?) (fill integer?) ) ⟹ u16vector?
Create homogenous u16 vector. If fill is given, it must be unsigned exact integer in the range 0 to (2^16)-1. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the u16vector.
(srfi 4) procedure (u16vector (value integer?) ... ) ⟹ u16vector?
Create homogenous u16 vector. Each value must be unsigned exact integer in the range 0 to (2^16)-1.
(srfi 4) procedure (u16vector-length (vec u16vector?) ) ⟹ integer?
Returns the number of elements in u16vector as an exact integer.
(srfi 4) procedure (u16vector-ref (vec u16vector?) (i integer?) ) ⟹ integer?
Returns i-th element in the vector. i must be in range [0, (u16vector-length vec))
(srfi 4) procedure (u16vector-set! (vec u16vector?) (i integer?) (value integer?) ) ⟹ undefined
u16vector-set! stores value in element k of vector. Value must be unsigned exact integer in the range 0 to (2^16)-1. i must be in range [0, (u16vector-length vec))
(srfi 4) procedure (u16vector->list (vec u16vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->u16vector (proper-list list?) ) ⟹ u16vector?
proper-list ⟹ (list integer? )
Converts a list to a homogenous u16vector. Each element in input list must be unsigned exact integer in the range 0 to (2^16)-1.
library (srfi 4)
(srfi 4) procedure (s16vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous s16vector, #f otherwise.
(srfi 4) procedure (make-s16vector (size integer?) ) ⟹ s16vector?
(srfi 4) procedure (make-s16vector (size integer?) (fill integer?) ) ⟹ s16vector?
Create homogenous s16 vector. If fill is given, it must be signed exact integer in the range -(2^15) to (2^15)-1. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the s16vector.
(srfi 4) procedure (s16vector (value integer?) ... ) ⟹ s16vector?
Create homogenous s16 vector. Each value must be signed exact integer in the range -(2^15) to (2^15)-1.
(srfi 4) procedure (s16vector-length (vec s16vector?) ) ⟹ integer?
Returns the number of elements in s16vector as an exact integer.
(srfi 4) procedure (s16vector-ref (vec s16vector?) (i integer?) ) ⟹ integer?
Returns i-th element in the vector. i must be in range [0, (s16vector-length vec))
(srfi 4) procedure (s16vector-set! (vec s16vector?) (i integer?) (value integer?) ) ⟹ undefined
s16vector-set! stores value in element k of vector. Value must be signed exact integer in the range -(2^15) to (2^15)-1. i must be in range [0, (s16vector-length vec))
(srfi 4) procedure (s16vector->list (vec s16vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->s16vector (proper-list list?) ) ⟹ s16vector?
proper-list ⟹ (list integer? )
Converts a list to a homogenous s16vector. Each element in input list must be signed exact integer in the range -(2^15) to (2^15)-1.
library (srfi 4)
(srfi 4) procedure (u32vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous u32vector, #f otherwise.
(srfi 4) procedure (make-u32vector (size integer?) ) ⟹ u32vector?
(srfi 4) procedure (make-u32vector (size integer?) (fill integer?) ) ⟹ u32vector?
Create homogenous u32 vector. If fill is given, it must be unsigned exact integer in the range 0 to (2^32)-1. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the u32vector.
(srfi 4) procedure (u32vector (value integer?) ... ) ⟹ u32vector?
Create homogenous u32 vector. Each value must be unsigned exact integer in the range 0 to (2^32)-1.
(srfi 4) procedure (u32vector-length (vec u32vector?) ) ⟹ integer?
Returns the number of elements in u32vector as an exact integer.
(srfi 4) procedure (u32vector-ref (vec u32vector?) (i integer?) ) ⟹ integer?
Returns i-th element in the vector. i must be in range [0, (u32vector-length vec))
(srfi 4) procedure (u32vector-set! (vec u32vector?) (i integer?) (value integer?) ) ⟹ undefined
u32vector-set! stores value in element k of vector. Value must be unsigned exact integer in the range 0 to (2^32)-1. i must be in range [0, (u32vector-length vec))
(srfi 4) procedure (u32vector->list (vec u32vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->u32vector (proper-list list?) ) ⟹ u32vector?
proper-list ⟹ (list integer? )
Converts a list to a homogenous u32vector. Each element in input list must be unsigned exact integer in the range 0 to (2^32)-1.
library (srfi 4)
(srfi 4) procedure (s32vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous s32vector, #f otherwise.
(srfi 4) procedure (make-s32vector (size integer?) ) ⟹ s32vector?
(srfi 4) procedure (make-s32vector (size integer?) (fill integer?) ) ⟹ s32vector?
Create homogenous s32 vector. If fill is given, it must be signed exact integer in the range -(2^31) to (2^31)-1. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the s32vector.
(srfi 4) procedure (s32vector (value integer?) ... ) ⟹ s32vector?
Create homogenous s32 vector. Each value must be signed exact integer in the range -(2^31) to (2^31)-1.
(srfi 4) procedure (s32vector-length (vec s32vector?) ) ⟹ integer?
Returns the number of elements in s32vector as an exact integer.
(srfi 4) procedure (s32vector-ref (vec s32vector?) (i integer?) ) ⟹ integer?
Returns i-th element in the vector. i must be in range [0, (s32vector-length vec))
(srfi 4) procedure (s32vector-set! (vec s32vector?) (i integer?) (value integer?) ) ⟹ undefined
s32vector-set! stores value in element k of vector. Value must be signed exact integer in the range -(2^31) to (2^31)-1. i must be in range [0, (s32vector-length vec))
(srfi 4) procedure (s32vector->list (vec s32vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->s32vector (proper-list list?) ) ⟹ s32vector?
proper-list ⟹ (list integer? )
Converts a list to a homogenous s32vector. Each element in input list must be signed exact integer in the range -(2^31) to (2^31)-1.
library (srfi 4)
(srfi 4) procedure (u64vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous u64vector, #f otherwise.
(srfi 4) procedure (make-u64vector (size integer?) ) ⟹ u64vector?
(srfi 4) procedure (make-u64vector (size integer?) (fill integer?) ) ⟹ u64vector?
Create homogenous u64 vector. If fill is given, it must be unsigned exact integer in the range 0 to (2^64)-1. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the u64vector.
(srfi 4) procedure (u64vector (value integer?) ... ) ⟹ u64vector?
Create homogenous u64 vector. Each value must be unsigned exact integer in the range 0 to (2^64)-1.
(srfi 4) procedure (u64vector-length (vec u64vector?) ) ⟹ integer?
Returns the number of elements in u64vector as an exact integer.
(srfi 4) procedure (u64vector-ref (vec u64vector?) (i integer?) ) ⟹ integer?
Returns i-th element in the vector. i must be in range [0, (u64vector-length vec))
(srfi 4) procedure (u64vector-set! (vec u64vector?) (i integer?) (value integer?) ) ⟹ undefined
u64vector-set! stores value in element k of vector. Value must be unsigned exact integer in the range 0 to (2^64)-1. i must be in range [0, (u64vector-length vec))
(srfi 4) procedure (u64vector->list (vec u64vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->u64vector (proper-list list?) ) ⟹ u64vector?
proper-list ⟹ (list integer? )
Converts a list to a homogenous u64vector. Each element in input list must be unsigned exact integer in the range 0 to (2^64)-1.
library (srfi 4)
(srfi 4) procedure (s64vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous s64vector, #f otherwise.
(srfi 4) procedure (make-s64vector (size integer?) ) ⟹ s64vector?
(srfi 4) procedure (make-s64vector (size integer?) (fill integer?) ) ⟹ s64vector?
Create homogenous s64 vector. If fill is given, it must be signed exact integer in the range -(2^63) to (2^63)-1. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the s64vector.
(srfi 4) procedure (s64vector (value integer?) ... ) ⟹ s64vector?
Create homogenous s64 vector. Each value must be signed exact integer in the range -(2^63) to (2^63)-1.
(srfi 4) procedure (s64vector-length (vec s64vector?) ) ⟹ integer?
Returns the number of elements in s64vector as an exact integer.
(srfi 4) procedure (s64vector-ref (vec s64vector?) (i integer?) ) ⟹ integer?
Returns i-th element in the vector. i must be in range [0, (s64vector-length vec))
(srfi 4) procedure (s64vector-set! (vec s64vector?) (i integer?) (value integer?) ) ⟹ undefined
s64vector-set! stores value in element k of vector. Value must be signed exact integer in the range -(2^63) to (2^63)-1. i must be in range [0, (s64vector-length vec))
(srfi 4) procedure (s64vector->list (vec s64vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->s64vector (proper-list list?) ) ⟹ s64vector?
proper-list ⟹ (list integer? )
Converts a list to a homogenous s64vector. Each element in input list must be signed exact integer in the range -(2^63) to (2^63)-1.
library (srfi 4)
(srfi 4) procedure (f32vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous f32vector, #f otherwise.
(srfi 4) procedure (make-f32vector (size integer?) ) ⟹ f32vector?
(srfi 4) procedure (make-f32vector (size integer?) (fill real?) ) ⟹ f32vector?
Create homogenous f32 vector. If fill is given, it must be inexact real. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the f32vector.
(srfi 4) procedure (f32vector (value real?) ... ) ⟹ f32vector?
Create homogenous f32 vector. Each value must be inexact real.
(srfi 4) procedure (f32vector-length (vec f32vector?) ) ⟹ integer?
Returns the number of elements in f32vector as an exact integer.
(srfi 4) procedure (f32vector-ref (vec f32vector?) (i integer?) ) ⟹ real?
Returns i-th element in the vector. i must be in range [0, (f32vector-length vec))
(srfi 4) procedure (f32vector-set! (vec f32vector?) (i integer?) (value real?) ) ⟹ undefined
f32vector-set! stores value in element k of vector. Value must be inexact real. i must be in range [0, (f32vector-length vec))
(srfi 4) procedure (f32vector->list (vec f32vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->f32vector (proper-list list?) ) ⟹ f32vector?
proper-list ⟹ (list real? )
Converts a list to a homogenous f32vector. Each element in input list must be inexact real.
library (srfi 4)
(srfi 4) procedure (f64vector? obj ) ⟹ boolean?
Returns #t if the if an object is homogenous f64vector, #f otherwise.
(srfi 4) procedure (make-f64vector (size integer?) ) ⟹ f64vector?
(srfi 4) procedure (make-f64vector (size integer?) (fill real?) ) ⟹ f64vector?
Create homogenous f64 vector. If fill is given, it must be inexact real. If fill isn't given, vector is filled with unspecified values which are guaranteed to fit into the range of the f64vector.
(srfi 4) procedure (f64vector (value real?) ... ) ⟹ f64vector?
Create homogenous f64 vector. Each value must be inexact real.
(srfi 4) procedure (f64vector-length (vec f64vector?) ) ⟹ integer?
Returns the number of elements in f64vector as an exact integer.
(srfi 4) procedure (f64vector-ref (vec f64vector?) (i integer?) ) ⟹ real?
Returns i-th element in the vector. i must be in range [0, (f64vector-length vec))
(srfi 4) procedure (f64vector-set! (vec f64vector?) (i integer?) (value real?) ) ⟹ undefined
f64vector-set! stores value in element k of vector. Value must be inexact real. i must be in range [0, (f64vector-length vec))
(srfi 4) procedure (f64vector->list (vec f64vector?) ) ⟹ list?
Converts a homogenous vector to a list.
(srfi 4) procedure (list->f64vector (proper-list list?) ) ⟹ f64vector?
proper-list ⟹ (list real? )
Converts a list to a homogenous f64vector. Each element in input list must be inexact real.
library (srfi 5)
(srfi 5) syntax (let () ((_ ((var1 init1) ...) body)) ((_ name ((var1 init1) ...) body)) ((_ name ((var1 init1) ... var-rest rest-init ...) body)) ((_ (name (var1 init1) ...) body)) ((_ (name (var1 init1) ... var-rest rest-init ...) body)) )
An informal specification follows.
Unnamed
(let ((<parameter> <argument>)...)
<body>...)
Named, non-signature-style, no rest argument
(let <name> ((<parameter> <argument>)...)
<body>...)
Named, signature-style, no rest argument
(let (<name> (<parameter> <argument>)...)
<body>...)
Named, non-signature-style, rest argument
(let <name> ((<parameter> <argument>)...
. (<rest-parameter> <rest-argument>...))
<body>...)
Named, signature-style, rest argument
(let (<name> (<parameter> <argument>)...
. (<rest-parameter> <rest-argument>...))
<body>...)
Let $lambda and $letrec be hygienic bindings for the lambda and letrec forms, respectively.
For informal syntax 1:
(($lambda (<parameter>...) <body>...) <argument>...)
For informal syntaxes 2 and 3:
($letrec ((<name> ($lambda (<parameter>...) <body>...)))
(<name> <argument>...))
For informal syntaxes 4 and 5:
($letrec ((<name> ($lambda (<parameter>...
. <rest-parameter>) <body>...)))
(<name> <argument>... <rest-argument>...))
library (srfi 6)
(srfi 6) 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.
(srfi 6) procedure (open-output-string ) ⟹ output-port?
Returns a textual output port that will accumulate characters for retrieval by get-output-string.
(srfi 6) 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 (srfi 8)
(srfi 8) syntax (receive () ((_ formals expression body)) )
(variable1 ...) variable (variable1 ... variable_n . variable_n+1)
<Formals>, <expression>, and <body> are as described in R5RS. Specifically, <formals> can have any of three forms:
library (srfi 9)
(srfi 9) 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 (srfi 11)
(srfi 11) 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.
(srfi 11) 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 (srfi 13)
(srfi 13) procedure (string? obj ) ⟹ boolean?
Returns #t if obj is a string, otherwise returns #f.
(srfi 13) procedure (string-null? (s string?) ) ⟹ boolean?
Is s the empty string?
(srfi 13) procedure (string-every (c (or char?char-set?procedure?)) (s string?) ) ⟹ *
(srfi 13) procedure (string-every (c (or char?char-set?procedure?)) (s string?) (start integer?) ) ⟹ *
(srfi 13) procedure (string-every (c (or char?char-set?procedure?)) (s string?) (start integer?) (end integer?) ) ⟹ *
(c (char char?) ) ⟹ *
Checks to see if the given criteria is true of every character in s, proceeding from left (index start) to right (index end). If char/char-set/pred is a character, it is tested for equality with the elements of s. If char/char-set/pred is a character set, the elements of s are tested for membership in the set. If char/char-set/pred is a predicate procedure, it is applied to the elements of s. The predicate is "witness-generating:". If string-every returns true, the returned true value is the one produced by the final application of the predicate to s[end-1]. If string-every is applied to an empty sequence of characters, it simply returns #t. If string-every applies the predicate to the final element of the selected sequence (i.e., s[end-1]), that final application is a tail call.
(srfi 13) procedure (string-any (c (or char?char-set?procedure?)) (s string?) ) ⟹ *
(srfi 13) procedure (string-any (c (or char?char-set?procedure?)) (s string?) (start integer?) ) ⟹ *
(srfi 13) procedure (string-any (c (or char?char-set?procedure?)) (s string?) (start integer?) (end integer?) ) ⟹ *
(c (char char?) ) ⟹ *
Checks to see if the given criteria is true of every character in s, proceeding from left (index start) to right (index end). If char/char-set/pred is a character, it is tested for equality with the elements of s. If char/char-set/pred is a character set, the elements of s are tested for membership in the set. If char/char-set/pred is a predicate procedure, it is applied to the elements of s. The predicate is "witness-generating:". If string-any returns true, the returned true value is the one produced by the application of the predicate. If string-any is applied to an empty sequence of characters, it simply returns #t. If string-every applies the predicate to the final element of the selected sequence (i.e., s[end-1]), that final application is a tail call.
(srfi 13) procedure (make-string (k integer?) ) ⟹ string?
(srfi 13) procedure (make-string (k integer?) (char char?) ) ⟹ string?
make-string returns a newly allocated string of length len. If char is given, then all elements of the string are initialized to char, otherwise the contents of the string are unspecified.
(srfi 13) procedure (string (char char?) ... ) ⟹ string?
Returns a newly allocated string composed of the argument characters.
(srfi 13) procedure (string-tabulate (proc procedure?) (len integer?) ) ⟹ string?
(proc (index integer?) ) ⟹ char?
Proc is an integer->char procedure. Construct a string of size len by applying proc to each index to produce the corresponding string element. The order in which proc is applied to the indices is not specified.
(srfi 13) procedure (string->list (string string?) ) ⟹ list?
(srfi 13) procedure (string->list (string string?) (start integer?) ) ⟹ list?
(srfi 13) procedure (string->list (string string?) (start integer?) (end integer?) ) ⟹ list?
string->list returns a newly allocated list of the characters that make up the given string.
(srfi 13) procedure (list->string (list list?) ) ⟹ string?
list->string returns a newly allocated string formed from the characters in the list char-list, which must be a list of characters.
(srfi 13) procedure (reverse-list->string (list list?) ) ⟹ string?
An efficient implementation of (compose list->string reverse)
(srfi 13) procedure (string-join (string-list list?) ) ⟹ string?
(srfi 13) procedure (string-join (string-list list?) (delimiter string?) ) ⟹ string?
(srfi 13) procedure (string-join (string-list list?) (delimiter string?) (grammar symbol?) ) ⟹ string?
This procedure is a simple unparser --- it pastes strings together using the delimiter string.
The grammar argument is a symbol that determines how the delimiter is used, and defaults to 'infix.
'infix means an infix or separator grammar: insert the delimiter between list elements. An empty list will produce an empty string -- note, however, that parsing an empty string with an infix or separator grammar is ambiguous. Is it an empty list, or a list of one element, the empty string?
'strict-infix means the same as 'infix, but will raise an error if given an empty list.
'suffix means a suffix or terminator grammar: insert the delimiter after every list element. This grammar has no ambiguities.
'prefix means a prefix grammar: insert the delimiter before every list element. This grammar has no ambiguities.
The delimiter is the string used to delimit elements; it defaults to a single space " ".
(srfi 13) procedure (string-length (string string?) ) ⟹ integer?
Returns the number of characters in the string s.
(srfi 13) procedure (string-ref (string string?) (k integer?) ) ⟹ char?
Returns character s[i] using zero-origin indexing. I must be a valid index of s.
(srfi 13) procedure (string-copy (string string?) ) ⟹ string?
(srfi 13) procedure (string-copy (string string?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-copy (string string?) (start integer?) (end integer?) ) ⟹ string?
string-copy is extended from its R5RS definition by the addition of its optional start/end parameters. In contrast to substring/shared, it is guaranteed to produce a freshly-allocated string.
(srfi 13) procedure (string-copy! (to string?) (at integer?) (from string?) ) ⟹ undefined
(srfi 13) procedure (string-copy! (to string?) (at integer?) (from string?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-copy! (to string?) (at integer?) (from string?) (start integer?) (end integer?) ) ⟹ undefined
Copy the sequence of characters from index range [start,end) in string s to string target, beginning at index tstart. The characters are copied left-to-right or right-to-left as needed -- the copy is guaranteed to work, even if target and s are the same string. It is an error if the copy operation runs off the end of the target string.
(srfi 13) procedure (string-take (s string?) (nchars integer?) ) ⟹ string?
string-take returns the first nchars of s
(srfi 13) procedure (string-drop (s string?) (nchars integer?) ) ⟹ string?
string-drop returns all but the first nchars of s.
(srfi 13) procedure (string-take-right (s string?) (nchars integer?) ) ⟹ string?
string-take-right returns the last nchars of s
(srfi 13) procedure (string-drop-right (s string?) (nchars integer?) ) ⟹ string?
string-drop-right returns all but the last nchars of s.
(srfi 13) procedure (string-pad (s string?) (len integer?) ) ⟹ string?
(srfi 13) procedure (string-pad (s string?) (len integer?) (char char?) ) ⟹ string?
(srfi 13) procedure (string-pad (s string?) (len integer?) (char char?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-pad (s string?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ string?
Build a string of length len comprised of s padded on the left by as many occurrences of the character char as needed. If s has more than len chars, it is truncated on the left to length len. Char defaults to #\space. If len <= end-start, the returned value is allowed to share storage with s, or be exactly s (if len = end-start).
(srfi 13) procedure (string-pad-right (s string?) (len integer?) ) ⟹ string?
(srfi 13) procedure (string-pad-right (s string?) (len integer?) (char char?) ) ⟹ string?
(srfi 13) procedure (string-pad-right (s string?) (len integer?) (char char?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-pad-right (s string?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ string?
Build a string of length len comprised of s padded on the right by as many occurrences of the character char as needed. If s has more than len chars, it is truncated on the right to length len. Char defaults to #\space. If len <= end-start, the returned value is allowed to share storage with s, or be exactly s (if len = end-start).
(srfi 13) procedure (string-trim (s string?) (c (or char?char-set?procedure?)) ) ⟹ string?
(srfi 13) procedure (string-trim (s string?) (c (or char?char-set?procedure?)) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-trim (s string?) (c (or char?char-set?procedure?)) (start integer?) (end integer?) ) ⟹ string?
(c (char char?) ) ⟹ *
Trim s by skipping over all characters on the left that satisfy the second parameter char/char-set/pred:
Char/char-set/pred defaults to the character set char-set:whitespace defined in SRFI 14.
(srfi 13) procedure (string-trim-right (s string?) (c (or char?char-set?procedure?)) ) ⟹ string?
(srfi 13) procedure (string-trim-right (s string?) (c (or char?char-set?procedure?)) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-trim-right (s string?) (c (or char?char-set?procedure?)) (start integer?) (end integer?) ) ⟹ string?
(c (char char?) ) ⟹ *
Trim s by skipping over all characters on the right that satisfy the second parameter char/char-set/pred:
Char/char-set/pred defaults to the character set char-set:whitespace defined in SRFI 14.
(srfi 13) procedure (string-trim-both (s string?) (c (or char?char-set?procedure?)) ) ⟹ string?
(srfi 13) procedure (string-trim-both (s string?) (c (or char?char-set?procedure?)) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-trim-both (s string?) (c (or char?char-set?procedure?)) (start integer?) (end integer?) ) ⟹ string?
(c (char char?) ) ⟹ *
Trim s by skipping over all characters on both sides that satisfy the second parameter char/char-set/pred:
Char/char-set/pred defaults to the character set char-set:whitespace defined in SRFI 14.
(srfi 13) procedure (string-set! (string string?) (i integer?) (char char?) ) ⟹ undefined
i must be a valid index of s. string-set! stores char in element i of s. Constant string literals appearing in code are immutable; it is an error to use them in a string-set!.
(srfi 13) procedure (string-fill! (s string?) (fill char?) ) ⟹ undefined
(srfi 13) procedure (string-fill! (s string?) (fill char?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-fill! (s string?) (fill char?) (start integer?) (end integer?) ) ⟹ undefined
Stores char in every element of s. string-fill is extended from the R5RS definition to take optional start/end arguments.
(srfi 13) procedure (string-compare (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) ) ⟹ *
(srfi 13) procedure (string-compare (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) (start1 integer?) ) ⟹ *
(srfi 13) procedure (string-compare (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) (start1 integer?) (end1 integer?) ) ⟹ *
(srfi 13) procedure (string-compare (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ *
(srfi 13) procedure (string-compare (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ *
(proc< (index integer?) ) ⟹ *
(proc= (index integer?) ) ⟹ *
(proc> (index integer?) ) ⟹ *
Apply proc<, proc=, or proc> to the mismatch index, depending upon whether s1 is less than, equal to, or greater than s2. The "mismatch index" is the largest index i such that for every 0 <= j < i, s1[j] = s2[j] -- that is, i is the first position that doesn't match. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2. The mismatch index is always an index into s1; in the case of proc=, it is always end1; we observe the protocol in this redundant case for uniformity.
(srfi 13) procedure (string-compare-ci (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) ) ⟹ *
(srfi 13) procedure (string-compare-ci (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) (start1 integer?) ) ⟹ *
(srfi 13) procedure (string-compare-ci (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) (start1 integer?) (end1 integer?) ) ⟹ *
(srfi 13) procedure (string-compare-ci (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ *
(srfi 13) procedure (string-compare-ci (s1 string?) (s2 string?) (proc< procedure?) (proc= procedure?) (proc> procedure?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ *
(proc< (index integer?) ) ⟹ *
(proc= (index integer?) ) ⟹ *
(proc> (index integer?) ) ⟹ *
Apply proc<, proc=, or proc> to the mismatch index, depending upon whether s1 is less than, equal to, or greater than s2 in case-insensitive way. The "mismatch index" is the largest index i such that for every 0 <= j < i, s1[j] = s2[j] -- that is, i is the first position that doesn't match. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2. The mismatch index is always an index into s1; in the case of proc=, it is always end1; we observe the protocol in this redundant case for uniformity.
(srfi 13) procedure (string= (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string= (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string<> (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string<> (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string<> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string<> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string<> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string< (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string< (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string< (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string< (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string< (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string> (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string> (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string<= (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string<= (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string<= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string<= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string<= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string>= (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string>= (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string>= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string>= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string>= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-ci= (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-ci= (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering on characters, case-insensitive. 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-ci<> (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-ci<> (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci<> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci<> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci<> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering on characters, case-insensitive. 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-ci< (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-ci< (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci< (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci< (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci< (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering on characters, case-insensitive. 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-ci> (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-ci> (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci> (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering on characters, case-insensitive. 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-ci<= (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-ci<= (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci<= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci<= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci<= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering on characters, case-insensitive. 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-ci>= (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-ci>= (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci>= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci>= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-ci>= (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Lexicographic extensions to strings of the corresponding ordering on characters, case-insensitive. 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. The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-hash (s string?) ) ⟹ integer?
(srfi 13) procedure (string-hash (s string?) (bound integer?) ) ⟹ integer?
(srfi 13) procedure (string-hash (s string?) (bound integer?) (start integer?) ) ⟹ integer?
(srfi 13) procedure (string-hash (s string?) (bound integer?) (start integer?) (end integer?) ) ⟹ integer?
Compute a hash value for the string s. Bound is a non-negative exact integer specifying the range of the hash function. A positive value restricts the return value to the range [0,bound). If bound is either zero or not given, the implementation may use an implementation-specific default value, chosen to be as large as is efficiently practical. For instance, the default range might be chosen for a given implementation to map all strings into the range of integers that can be represented with a single machine word. The optional start/end indices restrict the hash operation to the indicated substring of s.
(srfi 13) procedure (string-hash-ci (s string?) ) ⟹ integer?
(srfi 13) procedure (string-hash-ci (s string?) (bound integer?) ) ⟹ integer?
(srfi 13) procedure (string-hash-ci (s string?) (bound integer?) (start integer?) ) ⟹ integer?
(srfi 13) procedure (string-hash-ci (s string?) (bound integer?) (start integer?) (end integer?) ) ⟹ integer?
Compute a hash value for the string s, case-insensitive. Bound is a non-negative exact integer specifying the range of the hash function. A positive value restricts the return value to the range [0,bound). If bound is either zero or not given, the implementation may use an implementation-specific default value, chosen to be as large as is efficiently practical. For instance, the default range might be chosen for a given implementation to map all strings into the range of integers that can be represented with a single machine word. The optional start/end indices restrict the hash operation to the indicated substring of s.
(srfi 13) procedure (string-prefix-length (s1 string?) (s2 string?) ) ⟹ integer?
(srfi 13) procedure (string-prefix-length (s1 string?) (s2 string?) (start1 integer?) ) ⟹ integer?
(srfi 13) procedure (string-prefix-length (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 13) procedure (string-prefix-length (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 13) procedure (string-prefix-length (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
Return the length of the longest common prefix of the two strings.
(srfi 13) procedure (string-suffix-length (s1 string?) (s2 string?) ) ⟹ integer?
(srfi 13) procedure (string-suffix-length (s1 string?) (s2 string?) (start1 integer?) ) ⟹ integer?
(srfi 13) procedure (string-suffix-length (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 13) procedure (string-suffix-length (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 13) procedure (string-suffix-length (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
Return the length of the longest common suffix of the two strings.
(srfi 13) procedure (string-prefix-length-ci (s1 string?) (s2 string?) ) ⟹ integer?
(srfi 13) procedure (string-prefix-length-ci (s1 string?) (s2 string?) (start1 integer?) ) ⟹ integer?
(srfi 13) procedure (string-prefix-length-ci (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 13) procedure (string-prefix-length-ci (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 13) procedure (string-prefix-length-ci (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
Return the length of the longest common prefix of the two strings, case-insensitive.
(srfi 13) procedure (string-suffix-length-ci (s1 string?) (s2 string?) ) ⟹ integer?
(srfi 13) procedure (string-suffix-length-ci (s1 string?) (s2 string?) (start1 integer?) ) ⟹ integer?
(srfi 13) procedure (string-suffix-length-ci (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 13) procedure (string-suffix-length-ci (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 13) procedure (string-suffix-length-ci (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
Return the length of the longest common suffix of the two strings, case-insensitive.
(srfi 13) procedure (string-prefix? (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-prefix? (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-prefix? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-prefix? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-prefix? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Is s1 a prefix of s2? The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-suffix? (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-suffix? (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-suffix? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-suffix? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-suffix? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Is s1 a suffix of s2? The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-prefix-ci? (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-prefix-ci? (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-prefix-ci? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-prefix-ci? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-prefix-ci? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Is s1 a prefix of s2, case-insensitive? The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-suffix-ci? (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 13) procedure (string-suffix-ci? (s1 string?) (s2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-suffix-ci? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-suffix-ci? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 13) procedure (string-suffix-ci? (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Is s1 a suffix of s2, case-insensitive? The optional start/end indices restrict the comparison to the indicated substrings of s1 and s2.
(srfi 13) procedure (string-index (c (or char?char-set?procedure?)) (s string?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-index (c (or char?char-set?procedure?)) (s string?) (start integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-index (c (or char?char-set?procedure?)) (s string?) (start integer?) (end integer?) ) ⟹ integer? / #f /
(c (char char?) ) ⟹ *
string-index searches through the string from the left, returning the index of the first occurrence of a character which
If no match is found, the functions return false. The start and end parameters specify the beginning and end indices of the search; the search includes the start index, but not the end index.
(srfi 13) procedure (string-index-right (c (or char?char-set?procedure?)) (s string?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-index-right (c (or char?char-set?procedure?)) (s string?) (start integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-index-right (c (or char?char-set?procedure?)) (s string?) (start integer?) (end integer?) ) ⟹ integer? / #f /
(c (char char?) ) ⟹ *
string-index-right searches through the string from the right, returning the index of the first occurrence of a character which
If no match is found, the functions return false. The start and end parameters specify the beginning and end indices of the search; the search includes the start index, but not the end index.
(srfi 13) procedure (string-skip (c (or char?char-set?procedure?)) (s string?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-skip (c (or char?char-set?procedure?)) (s string?) (start integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-skip (c (or char?char-set?procedure?)) (s string?) (start integer?) (end integer?) ) ⟹ integer? / #f /
(c (char char?) ) ⟹ *
string-skip searches through the string from the left, returning the index of the first occurrence of a character which doesn't
If no match is found, the functions return false. The start and end parameters specify the beginning and end indices of the search; the search includes the start index, but not the end index.
(srfi 13) procedure (string-skip-right (c (or char?char-set?procedure?)) (s string?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-skip-right (c (or char?char-set?procedure?)) (s string?) (start integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-skip-right (c (or char?char-set?procedure?)) (s string?) (start integer?) (end integer?) ) ⟹ integer? / #f /
(c (char char?) ) ⟹ *
string-skip-right searches through the string from the right, returning the index of the first occurrence of a character which doesn't
If no match is found, the functions return false. The start and end parameters specify the beginning and end indices of the search; the search includes the start index, but not the end index.
(srfi 13) procedure (string-count (c (or char?char-set?procedure?)) (s string?) ) ⟹ integer?
(srfi 13) procedure (string-count (c (or char?char-set?procedure?)) (s string?) (start integer?) ) ⟹ integer?
(srfi 13) procedure (string-count (c (or char?char-set?procedure?)) (s string?) (start integer?) (end integer?) ) ⟹ integer?
(c (char char?) ) ⟹ *
Return a count of the number of characters in s that satisfy the char/char-set/pred argument. If this argument is a procedure, it is applied to the character as a predicate; if it is a character set, the character is tested for membership; if it is a character, it is used in an equality test.
(srfi 13) procedure (string-contains (s1 string?) (s2 string?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-contains (s1 string?) (s2 string?) (start1 integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-contains (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-contains (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-contains (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer? / #f /
Does string s1 contain string s2? Return the index in s1 where s2 occurs as a substring, or false. The optional start/end indices restrict the operation to the indicated substrings.
(srfi 13) procedure (string-contains-ci (s1 string?) (s2 string?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-contains-ci (s1 string?) (s2 string?) (start1 integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-contains-ci (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-contains-ci (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer? / #f /
(srfi 13) procedure (string-contains-ci (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer? / #f /
Does string s1 contain string s2, case-insensitive? Return the index in s1 where s2 occurs as a substring, or false. The optional start/end indices restrict the operation to the indicated substrings.
(srfi 13) procedure (string-titlecase (s string?) ) ⟹ string?
(srfi 13) procedure (string-titlecase (s string?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-titlecase (s string?) (start integer?) (end integer?) ) ⟹ string?
For every character c in the selected range of s, if c is preceded by a cased character, it is downcased; otherwise it is titlecased.
(srfi 13) procedure (string-titlecase! (s string?) ) ⟹ undefined
(srfi 13) procedure (string-titlecase! (s string?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-titlecase! (s string?) (start integer?) (end integer?) ) ⟹ undefined
For every character c in the selected range of s, if c is preceded by a cased character, it is downcased; otherwise it is titlecased. String is changed in-place.
(srfi 13) procedure (string-upcase (s string?) ) ⟹ string?
(srfi 13) procedure (string-upcase (s string?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-upcase (s string?) (start integer?) (end integer?) ) ⟹ string?
Raise the case of the alphabetic characters in the string.
(srfi 13) procedure (string-upcase! (s string?) ) ⟹ undefined
(srfi 13) procedure (string-upcase! (s string?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-upcase! (s string?) (start integer?) (end integer?) ) ⟹ undefined
Raise the case of the alphabetic characters in the string. String is changed in-place.
(srfi 13) procedure (string-downcase (s string?) ) ⟹ string?
(srfi 13) procedure (string-downcase (s string?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-downcase (s string?) (start integer?) (end integer?) ) ⟹ string?
Lower the case of the alphabetic characters in the string.
(srfi 13) procedure (string-downcase! (s string?) ) ⟹ undefined
(srfi 13) procedure (string-downcase! (s string?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-downcase! (s string?) (start integer?) (end integer?) ) ⟹ undefined
Lower the case of the alphabetic characters in the string. String is changed in-place.
(srfi 13) procedure (string-reverse (s string?) ) ⟹ string?
(srfi 13) procedure (string-reverse (s string?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-reverse (s string?) (start integer?) (end integer?) ) ⟹ string?
Reverse the string.
(srfi 13) procedure (string-reverse! (s string?) ) ⟹ undefined
(srfi 13) procedure (string-reverse! (s string?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-reverse! (s string?) (start integer?) (end integer?) ) ⟹ undefined
Reverse the string. String is changed in-place.
(srfi 13) procedure (string-append (string string?) ... ) ⟹ string?
Returns a newly allocated string whose characters form the concatenation of the given strings.
(srfi 13) procedure (string-concatenate (string-list list?) ) ⟹ string?
Append the elements of string-list together into a single string. Guaranteed to return a freshly allocated string. Note that the (apply string-append string-list) idiom is not robust for long lists of strings, as some Scheme implementations limit the number of arguments that may be passed to an n-ary procedure.
(srfi 13) procedure (string-concatenate-reverse (string-list list?) ) ⟹ string?
(srfi 13) procedure (string-concatenate-reverse (string-list list?) (final-string string?) ) ⟹ string?
(srfi 13) procedure (string-concatenate-reverse (string-list list?) (final-string string?) (end integer?) ) ⟹ string?
With no optional arguments, the function is equivalent to (string-concatenate (reverse string-list)). If the optional argument final-string is specified, it is consed onto the beginning of string-list before performing the list-reverse and string-concatenate operations. If the optional argument end is given, only the first end characters of final-string are added to the string list.
(srfi 13) procedure (string-map (proc procedure?) (s string?) ) ⟹ string?
(srfi 13) procedure (string-map (proc procedure?) (s string?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-map (proc procedure?) (s string?) (start integer?) (end integer?) ) ⟹ string?
(proc (c char?) ... ) ⟹ char?
Proc is a char->char procedure; it is mapped over s. string-map returns the result string and does not alter its s parameter.
(srfi 13) procedure (string-map! (proc procedure?) (s string?) ) ⟹ undefined
(srfi 13) procedure (string-map! (proc procedure?) (s string?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-map! (proc procedure?) (s string?) (start integer?) (end integer?) ) ⟹ undefined
(proc (c char?) ... ) ⟹ char?
Proc is a char->char procedure; it is mapped over s. string-map! is the in-place side-effecting variant.
(srfi 13) procedure (string-fold (kons procedure?) knil (s string?) ) ⟹ *
(srfi 13) procedure (string-fold (kons procedure?) knil (s string?) (start integer?) ) ⟹ *
(srfi 13) procedure (string-fold (kons procedure?) knil (s string?) (start integer?) (end integer?) ) ⟹ *
(kons (c char?) state ) ⟹ *
The left-fold operator maps the kons procedure across the string from left to right (... (kons s[2] (kons s[1] (kons s[0] knil))))
(srfi 13) procedure (string-fold-right (kons procedure?) knil (s string?) ) ⟹ *
(srfi 13) procedure (string-fold-right (kons procedure?) knil (s string?) (start integer?) ) ⟹ *
(srfi 13) procedure (string-fold-right (kons procedure?) knil (s string?) (start integer?) (end integer?) ) ⟹ *
(kons (c char?) state ) ⟹ *
The right-fold operator maps the kons procedure across the string from right to left (kons s[0] (... (kons s[end-3] (kons s[end-2] (kons s[end-1] knil)))))
(srfi 13) procedure (string-unfold (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ string?
(srfi 13) procedure (string-unfold (p procedure?) (f procedure?) (g procedure?) seed (base string?) ) ⟹ string?
(srfi 13) procedure (string-unfold (p procedure?) (f procedure?) (g procedure?) seed (base string?) (make-final procedure?) ) ⟹ string?
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(make-final seed ) ⟹ string?
This is a fundamental constructor for strings.
The final string constructed does not share storage with either base or the value produced by make-final.
(srfi 13) procedure (string-unfold-right (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ string?
(srfi 13) procedure (string-unfold-right (p procedure?) (f procedure?) (g procedure?) seed (base string?) ) ⟹ string?
(srfi 13) procedure (string-unfold-right (p procedure?) (f procedure?) (g procedure?) seed (base string?) (make-final procedure?) ) ⟹ string?
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(make-final seed ) ⟹ string?
This is a fundamental constructor for strings.
The final string constructed does not share storage with either base or the value produced by make-final.
(srfi 13) procedure (string-for-each (proc procedure?) (s string?) ) ⟹ undefined
(srfi 13) procedure (string-for-each (proc procedure?) (s string?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-for-each (proc procedure?) (s string?) (start integer?) (end integer?) ) ⟹ undefined
(proc (c char?) ) ⟹ undefined
Apply proc to each character in s. string-for-each is required to iterate from start to end in increasing order.
(srfi 13) procedure (string-for-each-index (proc procedure?) (s string?) ) ⟹ undefined
(srfi 13) procedure (string-for-each-index (proc procedure?) (s string?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-for-each-index (proc procedure?) (s string?) (start integer?) (end integer?) ) ⟹ undefined
(proc (index integer?) ) ⟹ undefined
Apply proc to each index of s, in order. The optional start/end pairs restrict the endpoints of the loop. This is simply a method of looping over a string that is guaranteed to be safe and correct.
(srfi 13) procedure (xsubstring (s string?) (from integer?) ) ⟹ string?
(srfi 13) procedure (xsubstring (s string?) (from integer?) (to integer?) ) ⟹ string?
(srfi 13) procedure (xsubstring (s string?) (from integer?) (to integer?) (start integer?) ) ⟹ string?
(srfi 13) procedure (xsubstring (s string?) (from integer?) (to integer?) (start integer?) (end integer?) ) ⟹ string?
This is the "extended substring" procedure that implements replicated copying of a substring of some string. S is a string; start and end are optional arguments that demarcate a substring of s, defaulting to 0 and the length of s (i.e., the whole string). Replicate this substring up and down index space, in both the positive and negative directions. xsubstring returns the substring of this string beginning at index from, and ending at to (which defaults to from+(end-start)).
(srfi 13) procedure (string-xcopy! (target string?) (tstart integer?) (s string?) (sfrom integer?) ) ⟹ undefined
(srfi 13) procedure (string-xcopy! (target string?) (tstart integer?) (s string?) (sfrom integer?) (sto integer?) ) ⟹ undefined
(srfi 13) procedure (string-xcopy! (target string?) (tstart integer?) (s string?) (sfrom integer?) (sto integer?) (start integer?) ) ⟹ undefined
(srfi 13) procedure (string-xcopy! (target string?) (tstart integer?) (s string?) (sfrom integer?) (sto integer?) (start integer?) (end integer?) ) ⟹ undefined
Exactly the same as xsubstring, but the extracted text is written into the string target starting at index tstart. This operation is not defined if (eq? target s) or these two arguments share storage -- you cannot copy a string on top of itself.
(srfi 13) procedure (string-replace (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) ) ⟹ string?
(srfi 13) procedure (string-replace (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ string?
(srfi 13) procedure (string-replace (s1 string?) (s2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ string?
Segment of characters in s1 from start1 to end1 is replaced by the segment of characters in s2 from start2 to end2. If start1=end1, this simply splices the s2 characters into s1 at the specified index.
(srfi 13) procedure (string-tokenize (s string?) ) ⟹ list?
(srfi 13) procedure (string-tokenize (s string?) (token-set char-set?) ) ⟹ list?
(srfi 13) procedure (string-tokenize (s string?) (token-set char-set?) (start integer?) ) ⟹ list?
(srfi 13) procedure (string-tokenize (s string?) (token-set char-set?) (start integer?) (end integer?) ) ⟹ list?
Split the string s into a list of substrings, where each substring is a maximal non-empty contiguous sequence of characters from the character set token-set.
This function provides a minimal parsing facility for simple applications. More sophisticated parsers that handle quoting and backslash effects can easily be constructed using regular-expression systems; be careful not to use string-tokenize in contexts where more serious parsing is needed.
(srfi 13) procedure (string-filter (c (or char?char-set?procedure?)) (s string?) ) ⟹ string?
(srfi 13) procedure (string-filter (c (or char?char-set?procedure?)) (s string?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-filter (c (or char?char-set?procedure?)) (s string?) (start integer?) (end integer?) ) ⟹ string?
(c (char char?) ) ⟹ *
Filter the string s, retaining only those characters that satisfy the char/char-set/pred argument. If this argument is a procedure, it is applied to the character as a predicate; if it is a char-set, the character is tested for membership; if it is a character, it is used in an equality test. If the string is unaltered by the filtering operation, the function may return either s or a copy of s.
(srfi 13) procedure (string-delete (c (or char?char-set?procedure?)) (s string?) ) ⟹ string?
(srfi 13) procedure (string-delete (c (or char?char-set?procedure?)) (s string?) (start integer?) ) ⟹ string?
(srfi 13) procedure (string-delete (c (or char?char-set?procedure?)) (s string?) (start integer?) (end integer?) ) ⟹ string?
(c (char char?) ) ⟹ *
Filter the string s, retaining only those characters that do not satisfy the char/char-set/pred argument. If this argument is a procedure, it is applied to the character as a predicate; if it is a char-set, the character is tested for membership; if it is a character, it is used in an equality test. If the string is unaltered by the filtering operation, the function may return either s or a copy of s.
(srfi 13) procedure (string-parse-start+end (proc procedure?) (s string?) (args list?) ) ⟹ (values list?integer?integer?)
string-parse-start+end may be used to parse a pair of optional start/end arguments from an argument list, defaulting them to 0 and the length of some string s, respectively. Let the length of string s be slen.
If any of the checks fail, an error condition is raised, and proc is used as part of the error condition -- it should be the client procedure whose argument list string-parse-start+end is parsing.
(srfi 13) procedure (string-parse-final-start+end (proc procedure?) (s string?) (args list?) ) ⟹ (values integer?integer?)
string-parse-final-start+end is exactly the same as string-parse-start+end, except that the args list passed to it is required to be of length two or less; if it is longer, an error condition is raised. It may be used when the optional start/end parameters are final arguments to the procedure.
(srfi 13) syntax (let-string-start+end () ((_ (start end) proc s args body ...)) ((_ (rest start end) proc s args body ...)) )
proc ⟹ procedure?
s ⟹ string?
args ⟹ list?
Syntactic sugar for an application of string-parse-start+end or string-parse-final-start+end. If a rest variable is given, the form is equivalent to
(call-with-values
(lambda () (string-parse-start+end proc-exp s-exp args-exp))
(lambda (rest start end) body ...))
If no rest variable is given, the form is equivalent to
(call-with-values
(lambda () (string-parse-final-start+end proc-exp s-exp args-exp))
(lambda (start end) body ...))
(srfi 13) procedure (check-substring-spec (proc procedure?) (s string?) (start integer?) (end integer?) ) ⟹ undefined
Check values s, start and end to ensure they specify a valid substring. This means that s is a string, start and end are exact integers, and 0 <= start <= end <= (string-length s). If the values are not proper check-substring-spec raises an error condition. proc is used as part of the error condition, and should be the procedure whose parameters we are checking.
(srfi 13) procedure (substring-spec-ok? (s string?) (start integer?) (end integer?) ) ⟹ boolean?
Check values s, start and end to ensure they specify a valid substring. This means that s is a string, start and end are exact integers, and 0 <= start <= end <= (string-length s). If the values are not proper substring-spec-ok? returns false.
(srfi 13) procedure (make-kmp-restart-vector (s string?) ) ⟹ vector?
(srfi 13) procedure (make-kmp-restart-vector (s string?) (c= procedure?) ) ⟹ vector?
(srfi 13) procedure (make-kmp-restart-vector (s string?) (c= procedure?) (start integer?) ) ⟹ vector?
(srfi 13) procedure (make-kmp-restart-vector (s string?) (c= procedure?) (start integer?) (end integer?) ) ⟹ vector?
(c= (a char?) (b char?) ) ⟹ boolean?
Build a Knuth-Morris-Pratt "restart vector," which is useful for quickly searching character sequences for the occurrence of string s (or the substring of s demarcated by the optional start/end parameters, if provided). C= is a character-equality function used to construct the restart vector. It defaults to char=?; use char-ci=? instead for case-folded string search.
The definition of the restart vector rv for string s is: If we have matched chars 0..i-1 of s against some search string ss, and s[i] doesn't match ss[k], then reset i := rv[i], and try again to match ss[k]. If rv[i] = -1, then punt ss[k] completely, and move on to ss[k+1] and s[0].
In other words, if you have matched the first i chars of s, but the i+1'th char doesn't match, rv[i] tells you what the next-longest prefix of s is that you have matched.
The optional start/end parameters restrict the restart vector to the indicated substring of pat; rv is end - start elements long. If start > 0, then rv is offset by start elements from pat. That is, rv[i] describes pattern element pat[i + start]. Elements of rv are themselves indices that range just over [0, end-start), not [start, end).
(srfi 13) procedure (kmp-step (pat string?) (rv vector?) (c char?) (i integer?) (c= procedure?) (p-start integer?) ) ⟹ integer?
(c= (a char?) (b char?) ) ⟹ boolean?
This function encapsulates the work performed by one step of the KMP string search; it can be used to scan strings, input ports, or other on-line character sources for fixed strings.
Pat is the non-empty string specifying the text for which we are searching. Rv is the Knuth-Morris-Pratt restart vector for the pattern, as constructed by make-kmp-restart-vector. The pattern begins at pat[p-start], and is (vector-length rv) characters long. C= is the character-equality function used to construct the restart vector, typically char=? or char-ci=?.
Suppose the pattern is N characters in length: pat[p-start, p-start + n). We have already matched i characters: pat[p-start, p-start + i). (P-start is typically zero.) C is the next character in the input stream. kmp-step returns the new i value -- that is, how much of the pattern we have matched, including character c. When i reaches n, the entire pattern has been matched.
(srfi 13) procedure (string-kmp-partial-search (pat string?) (rv vector?) (s string?) (i integer?) ) ⟹ integer?
(srfi 13) procedure (string-kmp-partial-search (pat string?) (rv vector?) (s string?) (i integer?) (c= procedure?) ) ⟹ integer?
(srfi 13) procedure (string-kmp-partial-search (pat string?) (rv vector?) (s string?) (i integer?) (c= procedure?) (p-start integer?) ) ⟹ integer?
(srfi 13) procedure (string-kmp-partial-search (pat string?) (rv vector?) (s string?) (i integer?) (c= procedure?) (p-start integer?) (s-start integer?) ) ⟹ integer?
(srfi 13) procedure (string-kmp-partial-search (pat string?) (rv vector?) (s string?) (i integer?) (c= procedure?) (p-start integer?) (s-start integer?) (s-end integer?) ) ⟹ integer?
(c= (a char?) (b char?) ) ⟹ boolean?
Applies kmp-step across s; optional s-start/s-end bounds parameters restrict search to a substring of s. The pattern is (vector-length rv) characters long; optional p-start index indicates non-zero start of pattern in pat.
Suppose plen = (vector-length rv) is the length of the pattern. I is an integer index into the pattern (that is, 0 <= i < plen) indicating how much of the pattern has already been matched. (This means the pattern must be non-empty -- plen > 0.)
Hence:
This utility is designed to allow searching for occurrences of a fixed string that might extend across multiple buffers of text. This is why, for example, we do not provide the index of the start of the match on success -- it may have occurred in a previous buffer.
library (srfi 14)
(srfi 14) procedure (char-set? obj ) ⟹ boolean?
Is the object obj a character set?
(srfi 14) procedure (char-set= (cs1 char-set?) ... ) ⟹ boolean?
Are the character sets equal?
Boundary cases:
(char-set=) => true
(char-set= cs) => true
Rationale: transitive binary relations are generally extended to n-ary relations in Scheme, which enables clearer, more concise code to be written. While the zero-argument and one-argument cases will almost certainly not arise in first-order uses of such relations, they may well arise in higher-order cases or macro-generated code. E.g., consider
(apply char-set= cset-list)
This is well-defined if the list is empty or a singleton list. Hence we extend these relations to any number of arguments. Implementors have reported actual uses of n-ary relations in higher-order cases allowing for fewer than two arguments. The way of Scheme is to handle the general case; we provide the fully general extension.
A counter-argument to this extension is that R5RS's transitive binary arithmetic relations (=, <, etc.) require at least two arguments, hence this decision is a break with the prior convention -- although it is at least one that is backwards-compatible.
(srfi 14) procedure (char-set<= (cs1 char-set?) ... ) ⟹ boolean?
Returns true if every character set csi is a subset of character set csi+1.
Boundary cases:
(char-set<=) => true
(char-set<= cs) => true
Rationale: See char-set= for discussion of zero- and one-argument applications. Consider testing a list of char-sets for monotonicity with
(apply char-set<= cset-list)
(srfi 14) procedure (char-set-hash (cs char-set?) ) ⟹ integer?
(srfi 14) procedure (char-set-hash (cs char-set?) (bound integer?) ) ⟹ integer?
Compute a hash value for the character set cs. Bound is a non-negative exact integer specifying the range of the hash function. A positive value restricts the return value to the range [0,bound).
If bound is either zero or not given, the implementation may use an implementation-specific default value, chosen to be as large as is efficiently practical. For instance, the default range might be chosen for a given implementation to map all strings into the range of integers that can be represented with a single machine word.
Invariant:
(char-set= cs1 cs2) => (= (char-set-hash cs1 b) (char-set-hash cs2 b))
A legal but nonetheless discouraged implementation:
(define (char-set-hash cs . maybe-bound) 1)
Rationale: allowing the user to specify an explicit bound simplifies user code by removing the mod operation that typically accompanies every hash computation, and also may allow the implementation of the hash function to exploit a reduced range to efficiently compute the hash value. E.g., for small bounds, the hash function may be computed in a fashion such that intermediate values never overflow into bignum integers, allowing the implementor to provide a fixnum-specific "fast path" for computing the common cases very rapidly.
(srfi 14) procedure (char-set-cursor (cset char-set?) ) ⟹ *
(shared description for char-set-cursor, char-set-ref, char-set-cursor-next, end-of-char-set?)
Cursors are a low-level facility for iterating over the characters in a set. A cursor is a value that indexes a character in a char set. char-set-cursor produces a new cursor for a given char set. The set element indexed by the cursor is fetched with char-set-ref. A cursor index is incremented with char-set-cursor-next; in this way, code can step through every character in a char set. Stepping a cursor "past the end" of a char set produces a cursor that answers true to end-of-char-set?. It is an error to pass such a cursor to char-set-ref or to char-set-cursor-next.
A cursor value may not be used in conjunction with a different character set; if it is passed to char-set-ref or char-set-cursor-next with a character set other than the one used to create it, the results and effects are undefined.
Cursor values are not necessarily distinct from other types. They may be integers, linked lists, records, procedures or other values. This license is granted to allow cursors to be very "lightweight" values suitable for tight iteration, even in fairly simple implementations.
Note that these primitives are necessary to export an iteration facility for char sets to loop macros.
Rationale: Note that the cursor API's four functions "fit" the functional protocol used by the unfolders provided by the list, string and char-set SRFIs (see the example above). By way of contrast, here is a simpler, two-function API that was rejected for failing this criterion. Besides char-set-cursor, it provided a single function that mapped a cursor and a character set to two values, the indexed character and the next cursor. If the cursor had exhausted the character set, then this function returned false instead of the character value, and another end-of-char-set cursor. In this way, the other three functions of the current API were combined together.
(srfi 14) procedure (char-set-ref (cset char-set?) cursor ) ⟹ char?
(shared description for char-set-cursor, char-set-ref, char-set-cursor-next, end-of-char-set?)
Cursors are a low-level facility for iterating over the characters in a set. A cursor is a value that indexes a character in a char set. char-set-cursor produces a new cursor for a given char set. The set element indexed by the cursor is fetched with char-set-ref. A cursor index is incremented with char-set-cursor-next; in this way, code can step through every character in a char set. Stepping a cursor "past the end" of a char set produces a cursor that answers true to end-of-char-set?. It is an error to pass such a cursor to char-set-ref or to char-set-cursor-next.
A cursor value may not be used in conjunction with a different character set; if it is passed to char-set-ref or char-set-cursor-next with a character set other than the one used to create it, the results and effects are undefined.
Cursor values are not necessarily distinct from other types. They may be integers, linked lists, records, procedures or other values. This license is granted to allow cursors to be very "lightweight" values suitable for tight iteration, even in fairly simple implementations.
Note that these primitives are necessary to export an iteration facility for char sets to loop macros.
Rationale: Note that the cursor API's four functions "fit" the functional protocol used by the unfolders provided by the list, string and char-set SRFIs (see the example above). By way of contrast, here is a simpler, two-function API that was rejected for failing this criterion. Besides char-set-cursor, it provided a single function that mapped a cursor and a character set to two values, the indexed character and the next cursor. If the cursor had exhausted the character set, then this function returned false instead of the character value, and another end-of-char-set cursor. In this way, the other three functions of the current API were combined together.
(srfi 14) procedure (char-set-cursor-next (cset char-set?) cursor ) ⟹ *
(shared description for char-set-cursor, char-set-ref, char-set-cursor-next, end-of-char-set?)
Cursors are a low-level facility for iterating over the characters in a set. A cursor is a value that indexes a character in a char set. char-set-cursor produces a new cursor for a given char set. The set element indexed by the cursor is fetched with char-set-ref. A cursor index is incremented with char-set-cursor-next; in this way, code can step through every character in a char set. Stepping a cursor "past the end" of a char set produces a cursor that answers true to end-of-char-set?. It is an error to pass such a cursor to char-set-ref or to char-set-cursor-next.
A cursor value may not be used in conjunction with a different character set; if it is passed to char-set-ref or char-set-cursor-next with a character set other than the one used to create it, the results and effects are undefined.
Cursor values are not necessarily distinct from other types. They may be integers, linked lists, records, procedures or other values. This license is granted to allow cursors to be very "lightweight" values suitable for tight iteration, even in fairly simple implementations.
Note that these primitives are necessary to export an iteration facility for char sets to loop macros.
Rationale: Note that the cursor API's four functions "fit" the functional protocol used by the unfolders provided by the list, string and char-set SRFIs (see the example above). By way of contrast, here is a simpler, two-function API that was rejected for failing this criterion. Besides char-set-cursor, it provided a single function that mapped a cursor and a character set to two values, the indexed character and the next cursor. If the cursor had exhausted the character set, then this function returned false instead of the character value, and another end-of-char-set cursor. In this way, the other three functions of the current API were combined together.
(srfi 14) procedure (end-of-char-set? cursor ) ⟹ boolean?
(shared description for char-set-cursor, char-set-ref, char-set-cursor-next, end-of-char-set?)
Cursors are a low-level facility for iterating over the characters in a set. A cursor is a value that indexes a character in a char set. char-set-cursor produces a new cursor for a given char set. The set element indexed by the cursor is fetched with char-set-ref. A cursor index is incremented with char-set-cursor-next; in this way, code can step through every character in a char set. Stepping a cursor "past the end" of a char set produces a cursor that answers true to end-of-char-set?. It is an error to pass such a cursor to char-set-ref or to char-set-cursor-next.
A cursor value may not be used in conjunction with a different character set; if it is passed to char-set-ref or char-set-cursor-next with a character set other than the one used to create it, the results and effects are undefined.
Cursor values are not necessarily distinct from other types. They may be integers, linked lists, records, procedures or other values. This license is granted to allow cursors to be very "lightweight" values suitable for tight iteration, even in fairly simple implementations.
Note that these primitives are necessary to export an iteration facility for char sets to loop macros.
Rationale: Note that the cursor API's four functions "fit" the functional protocol used by the unfolders provided by the list, string and char-set SRFIs (see the example above). By way of contrast, here is a simpler, two-function API that was rejected for failing this criterion. Besides char-set-cursor, it provided a single function that mapped a cursor and a character set to two values, the indexed character and the next cursor. If the cursor had exhausted the character set, then this function returned false instead of the character value, and another end-of-char-set cursor. In this way, the other three functions of the current API were combined together.
(srfi 14) procedure (char-set-fold (kons procedure?) knil (cs char-set?) ) ⟹ *
(kons (c char?) state ) ⟹ *
This is the fundamental iterator for character sets. Applies the function kons across the character set cs using initial state value knil. That is, if cs is the empty set, the procedure returns knil. Otherwise, some element c of cs is chosen; let cs' be the remaining, unchosen characters. The procedure returns
(char-set-fold kons (kons c knil) cs')
(srfi 14) procedure (char-set-unfold (f procedure?) (p procedure?) (g procedure?) seed ) ⟹ char-set?
(srfi 14) procedure (char-set-unfold (f procedure?) (p procedure?) (g procedure?) seed (base-cs char-set?) ) ⟹ char-set?
(f seed ) ⟹ char?
(p seed ) ⟹ boolean?
(g seed ) ⟹ *
(shared description for char-set-unfold, char-set-unfold!) This is a fundamental constructor for char-sets.
(srfi 14) procedure (char-set-unfold! (f procedure?) (p procedure?) (g procedure?) seed (base-cs char-set?) ) ⟹ char-set?
(f seed ) ⟹ char?
(p seed ) ⟹ boolean?
(g seed ) ⟹ *
(shared description for char-set-unfold, char-set-unfold!) This is a fundamental constructor for char-sets.
(srfi 14) procedure (char-set-for-each (proc procedure?) (cs char-set?) ) ⟹ undefined
(proc (c char?) ) ⟹ undefined
Apply procedure proc to each character in the character set cs. Note that the order in which proc is applied to the characters in the set is not specified, and may even change from one procedure application to another.
Nothing at all is specified about the value returned by this procedure; it is not even required to be consistent from call to call. It is simply required to be a value (or values) that may be passed to a command continuation, e.g. as the value of an expression appearing as a non-terminal subform of a begin expression. Note that in R5RS, this restricts the procedure to returning a single value; non-R5RS systems may not even provide this restriction.
(srfi 14) procedure (char-set-map (proc procedure?) (cs char-set?) ) ⟹ char-set?
(proc (c char?) ) ⟹ char?
proc is a char->char procedure. Apply it to all the characters in the char-set cs, and collect the results into a new character set.
Essentially lifts proc from a char->char procedure to a char-set -> char-set procedure.
(srfi 14) procedure (char-set-copy (cs char-set?) ) ⟹ char-set?
Returns a copy of the character set cs. "Copy" means that if either the input parameter or the result value of this procedure is passed to one of the linear-update procedures described below, the other character set is guaranteed not to be altered.
A system that provides pure-functional implementations of the linear-operator suite could implement this procedure as the identity function -- so copies are not guaranteed to be distinct by eq?.
(srfi 14) procedure (char-set (char1 char?) ... ) ⟹ char-set?
Return a character set containing the given characters.
(srfi 14) procedure (list->char-set (char-list list?) ) ⟹ char-set?
(srfi 14) procedure (list->char-set (char-list list?) (base-cs char-set?) ) ⟹ char-set?
(shared description for list->char-set, list->char-set!) Return a character set containing the characters in the list of characters char-list.
If character set base-cs is provided, the characters from char-list are added to it. list->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; list->char-set produces a fresh character set.
(srfi 14) procedure (list->char-set! (char-list list?) (base-cs char-set?) ) ⟹ char-set?
(shared description for list->char-set, list->char-set!) Return a character set containing the characters in the list of characters char-list.
If character set base-cs is provided, the characters from char-list are added to it. list->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; list->char-set produces a fresh character set.
(srfi 14) procedure (string->char-set (s string?) ) ⟹ char-set?
(srfi 14) procedure (string->char-set (s string?) (base-cs char-set?) ) ⟹ char-set?
(shared description for string->char-set, string->char-set!) Return a character set containing the characters in the string s.
If character set base-cs is provided, the characters from s are added to it. string->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; string->char-set produces a fresh character set.
(srfi 14) procedure (string->char-set! (s string?) (base-cs char-set?) ) ⟹ char-set?
(shared description for string->char-set, string->char-set!) Return a character set containing the characters in the string s.
If character set base-cs is provided, the characters from s are added to it. string->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; string->char-set produces a fresh character set.
(srfi 14) procedure (char-set-filter (pred procedure?) (cs char-set?) ) ⟹ char-set?
(srfi 14) procedure (char-set-filter (pred procedure?) (cs char-set?) (base-cs char-set?) ) ⟹ char-set?
(pred (c char?) ) ⟹ boolean?
(shared description for char-set-filter, char-set-filter!) Returns a character set containing every character c in cs such that (pred c) returns true.
If character set base-cs is provided, the characters specified by pred are added to it. char-set-filter! is allowed, but not required, to side-effect and reuse the storage in base-cs; char-set-filter produces a fresh character set.
An implementation may not save away a reference to pred and invoke it after char-set-filter or char-set-filter! returns -- that is, "lazy", on-demand implementations are not allowed, as pred may have external dependencies on mutable data or have other side-effects.
Rationale: This procedure provides a means of converting a character predicate into its equivalent character set; the cs parameter allows the programmer to bound the predicate's domain. Programmers should be aware that filtering a character set such as char-set:full could be a very expensive operation in an implementation that provided an extremely large character type, such as 32-bit Unicode. An earlier draft of this library provided a simple predicate->char-set procedure, which was rejected in favor of char-set-filter for this reason.
(srfi 14) procedure (char-set-filter! (pred procedure?) (cs char-set?) (base-cs char-set?) ) ⟹ char-set?
(pred (c char?) ) ⟹ boolean?
(shared description for char-set-filter, char-set-filter!) Returns a character set containing every character c in cs such that (pred c) returns true.
If character set base-cs is provided, the characters specified by pred are added to it. char-set-filter! is allowed, but not required, to side-effect and reuse the storage in base-cs; char-set-filter produces a fresh character set.
An implementation may not save away a reference to pred and invoke it after char-set-filter or char-set-filter! returns -- that is, "lazy", on-demand implementations are not allowed, as pred may have external dependencies on mutable data or have other side-effects.
Rationale: This procedure provides a means of converting a character predicate into its equivalent character set; the cs parameter allows the programmer to bound the predicate's domain. Programmers should be aware that filtering a character set such as char-set:full could be a very expensive operation in an implementation that provided an extremely large character type, such as 32-bit Unicode. An earlier draft of this library provided a simple predicate->char-set procedure, which was rejected in favor of char-set-filter for this reason.
(srfi 14) procedure (ucs-range->char-set (lower integer?) (upper integer?) ) ⟹ char-set?
(srfi 14) procedure (ucs-range->char-set (lower integer?) (upper integer?) (error? boolean?) ) ⟹ char-set?
(srfi 14) procedure (ucs-range->char-set (lower integer?) (upper integer?) (error? boolean?) (base-cs char-set?) ) ⟹ char-set?
(shared description for ucs-range->char-set, ucs-range->char-set!) Lower and upper are exact non-negative integers; lower <= upper.
Returns a character set containing every character whose ISO/IEC 10646 UCS-4 code lies in the half-open range [lower,upper).
* If the requested range includes unassigned UCS values, these are silently ignored (the current UCS specification has "holes" in the space of assigned codes).
* If the requested range includes "private" or "user space" codes, these are handled in an implementation-specific manner; however, a UCS- or Unicode-based Scheme implementation should pass them through transparently.
* If any code from the requested range specifies a valid, assigned UCS character that has no corresponding representative in the implementation's character type, then (1) an error is raised if error? is true, and (2) the code is ignored if error? is false (the default). This might happen, for example, if the implementation uses ASCII characters, and the requested range includes non-ASCII characters.
If character set base-cs is provided, the characters specified by the range are added to it. ucs-range->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; ucs-range->char-set produces a fresh character set.
Note that ASCII codes are a subset of the Latin-1 codes, which are in turn a subset of the 16-bit Unicode codes, which are themselves a subset of the 32-bit UCS-4 codes. We commit to a specific encoding in this routine, regardless of the underlying representation of characters, so that client code using this library will be portable. I.e., a conformant Scheme implementation may use EBCDIC or SHIFT-JIS to encode characters; it must simply map the UCS characters from the given range into the native representation when possible, and report errors when not possible.
(srfi 14) procedure (ucs-range->char-set! (lower integer?) (upper integer?) (error? boolean?) (base-cs char-set?) ) ⟹ char-set?
(shared description for ucs-range->char-set, ucs-range->char-set!) Lower and upper are exact non-negative integers; lower <= upper.
Returns a character set containing every character whose ISO/IEC 10646 UCS-4 code lies in the half-open range [lower,upper).
* If the requested range includes unassigned UCS values, these are silently ignored (the current UCS specification has "holes" in the space of assigned codes).
* If the requested range includes "private" or "user space" codes, these are handled in an implementation-specific manner; however, a UCS- or Unicode-based Scheme implementation should pass them through transparently.
* If any code from the requested range specifies a valid, assigned UCS character that has no corresponding representative in the implementation's character type, then (1) an error is raised if error? is true, and (2) the code is ignored if error? is false (the default). This might happen, for example, if the implementation uses ASCII characters, and the requested range includes non-ASCII characters.
If character set base-cs is provided, the characters specified by the range are added to it. ucs-range->char-set! is allowed, but not required, to side-effect and reuse the storage in base-cs; ucs-range->char-set produces a fresh character set.
Note that ASCII codes are a subset of the Latin-1 codes, which are in turn a subset of the 16-bit Unicode codes, which are themselves a subset of the 32-bit UCS-4 codes. We commit to a specific encoding in this routine, regardless of the underlying representation of characters, so that client code using this library will be portable. I.e., a conformant Scheme implementation may use EBCDIC or SHIFT-JIS to encode characters; it must simply map the UCS characters from the given range into the native representation when possible, and report errors when not possible.
(srfi 14) procedure (->char-set (x string?) ) ⟹ char-set?
(srfi 14) procedure (->char-set (x char?) ) ⟹ char-set?
(srfi 14) procedure (->char-set (x char-set?) ) ⟹ char-set?
Coerces x into a char-set. X may be a string, character or char-set. A string is converted to the set of its constituent characters; a character is converted to a singleton set; a char-set is returned as-is. This procedure is intended for use by other procedures that want to provide "user-friendly", wide-spectrum interfaces to their clients.
(srfi 14) procedure (char-set-size (cs char-set?) ) ⟹ integer?
Returns the number of elements in character set cs.
(srfi 14) procedure (char-set-count (pred procedure?) (cs char-set?) ) ⟹ integer?
(pred (c char?) ) ⟹ boolean?
Apply pred to the chars of character set cs, and return the number of chars that caused the predicate to return true.
(srfi 14) procedure (char-set->list (cs char-set?) ) ⟹ list?
This procedure returns a list of the members of character set cs. The order in which cs's characters appear in the list is not defined, and may be different from one call to another.
(srfi 14) procedure (char-set->string (cs char-set?) ) ⟹ string?
This procedure returns a string containing the members of character set cs. The order in which cs's characters appear in the string is not defined, and may be different from one call to another.
(srfi 14) procedure (char-set-contains? (cs char-set?) (char char?) ) ⟹ boolean?
This procedure tests char for membership in character set cs.
The MIT Scheme character-set package called this procedure char-set-member?, but the argument order isn't consistent with the name.
(srfi 14) procedure (char-set-every (pred procedure?) (cs char-set?) ) ⟹ boolean?
(pred (c char?) ) ⟹ boolean?
(shared description for char-set-every, char-set-any) The char-set-every procedure returns true if predicate pred returns true of every character in the character set cs. Likewise, char-set-any applies pred to every character in character set cs, and returns the first true value it finds. If no character produces a true value, it returns false. The order in which these procedures sequence through the elements of cs is not specified.
Note that if you need to determine the actual character on which a predicate returns true, use char-set-any and arrange for the predicate to return the character parameter as its true value
(srfi 14) procedure (char-set-any (pred procedure?) (cs char-set?) ) ⟹ boolean?
(pred (c char?) ) ⟹ boolean?
(shared description for char-set-every, char-set-any) The char-set-every procedure returns true if predicate pred returns true of every character in the character set cs. Likewise, char-set-any applies pred to every character in character set cs, and returns the first true value it finds. If no character produces a true value, it returns false. The order in which these procedures sequence through the elements of cs is not specified.
Note that if you need to determine the actual character on which a predicate returns true, use char-set-any and arrange for the predicate to return the character parameter as its true value
(srfi 14) procedure (char-set-adjoin (cs char-set?) (char1 char?) ... ) ⟹ char-set?
Add the chari characters to character set cs.
(srfi 14) procedure (char-set-delete (cs char-set?) (char1 char?) ... ) ⟹ char-set?
Delete the chari characters from character set cs.
(srfi 14) procedure (char-set-adjoin! (cs char-set?) (char1 char?) ... ) ⟹ char-set?
Add the chari characters to character set cs. Linear-update variant. The procedure is allowed, but not required, to side-effect its first parameter.
(srfi 14) procedure (char-set-delete! (cs char-set?) (char1 char?) ... ) ⟹ char-set?
Delete the chari characters from character set cs. Linear-update variant. The procedure is allowed, but not required, to side-effect its first parameter.
(srfi 14) procedure (char-set-complement (cs char-set?) ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(srfi 14) procedure (char-set-union (cs1 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(srfi 14) procedure (char-set-intersection (cs1 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(srfi 14) procedure (char-set-difference (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(srfi 14) procedure (char-set-xor (cs1 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(srfi 14) procedure (char-set-diff+intersection (cs1 char-set?) (cs2 char-set?) ... ) ⟹ (values char-set?char-set?)
(shared description for char-set-complement, char-set-union, char-set-intersection, char-set-difference, char-set-xor, char-set-diff+intersection) These procedures implement set complement, union, intersection, difference, and exclusive-or for character sets. The union, intersection and xor operations are n-ary. The difference function is also n-ary, associates to the left (that is, it computes the difference between its first argument and the union of all the other arguments), and requires at least one argument.
Boundary cases:
(char-set-union) => char-set:empty
(char-set-intersection) => char-set:full
(char-set-xor) => char-set:empty
(char-set-difference cs) => cs
char-set-diff+intersection returns both the difference and the intersection of the arguments -- it partitions its first parameter. It is equivalent to
(values (char-set-difference cs1 cs2 ...)
(char-set-intersection cs1 (char-set-union cs2 ...)))
but can be implemented more efficiently.
Programmers should be aware that char-set-complement could potentially be a very expensive operation in Scheme implementations that provide a very large character type, such as 32-bit Unicode. If this is a possibility, sets can be complimented with respect to a smaller universe using char-set-difference.
(srfi 14) procedure (char-set-complement! (cs char-set?) ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(srfi 14) procedure (char-set-union (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(srfi 14) procedure (char-set-intersection! (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(srfi 14) procedure (char-set-difference! (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(srfi 14) procedure (char-set-xor! (cs1 char-set?) (cs2 char-set?) ... ) ⟹ char-set?
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
(srfi 14) procedure (char-set-diff+intersection! (cs1 char-set?) (cs2 char-set?) (cs3 char-set?) ... ) ⟹ (values char-set?char-set?)
(shared description for char-set-complement!, char-set-union!, char-set-intersection!, char-set-difference!, char-set-xor!, char-set-diff+intersection!)
These are linear-update variants of the set-algebra functions. They are allowed, but not required, to side-effect their first (required) parameter.
char-set-diff+intersection! is allowed to side-effect both of its two required parameters, cs1 and cs2.
char-set:lower-case ⟹ char-set?
Lower-case letters
char-set:upper-case ⟹ char-set?
Upper-case letters
char-set:title-case ⟹ char-set?
Title-case letters
char-set:letter ⟹ char-set?
Letters
char-set:digit ⟹ char-set?
Digits
char-set:letter+digit ⟹ char-set?
Letters and digits
char-set:graphic ⟹ char-set?
Printing characters except spaces
char-set:printing ⟹ char-set?
Printing characters including spaces
char-set:whitespace ⟹ char-set?
Whitespace characters
char-set:iso-control ⟹ char-set?
The ISO control characters
char-set:punctuation ⟹ char-set?
Punctuation characters
char-set:symbol ⟹ char-set?
Symbol characters
char-set:hex-digit ⟹ char-set?
A hexadecimal digit: 0-9, A-F, a-f
char-set:blank ⟹ char-set?
Blank characters -- horizontal whitespace
char-set:ascii ⟹ char-set?
All characters in the ASCII set.
char-set:empty ⟹ char-set?
Empty set
char-set:full ⟹ char-set?
All characters
library (srfi 16)
(srfi 16) 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 (srfi 17)
(srfi 17) syntax (set! () ((_ variable expression)) ((_ (proc args ...) expression)) )
The special form set! is extended so the first operand can be a procedure application, and not just a variable. The procedure is typically one that extracts a component from some data structure. Informally, when the procedure is called in the first operand of set!, it causes the corresponding component to be replaced by the second operand. For example, (set! (vector-ref x i) v) would be equivalent to (vector-set! x i v).
Each procedure that may be used as the first operand to set! must have a corresponding "setter" procedure. The builtin procedure setter takes a procedure and returns the corresponding setter procedure.
The following standard procedures have pre-defined setters:
(set! (car x) v) == (set-car! x v)
(set! (cdr x) v) == (set-cdr! x v)
(set! (caar x) v) == (set-car! (car x) v)
(set! (cadr x) v) == (set-car! (cdr x) v)
....
(set! (caXXr x) v) == (set-car! (cXXr x) v)
(set! (cdXXr x) v) == (set-cdr! (cXXr x) v)
(set! (string-ref x i) v) == (string-set! x i v)
(set! (vector-ref x i) v) == (vector-set! x i v)
(srfi 17) procedure (setter (proc procedure?) ) ⟹ procedure?
Returns an associated setter procedure. We define:
(set! (proc arg ...) value)
as:
((setter proc) arg ... value)
This SRFI specifies the special case for the setter property. This is defined such that:
(set! (setter proc) setter)
sets the setter procedure associated with proc to setter. For example, we can assume
(set! (setter car) set-car!)
has been executed by the Scheme prologue.
(srfi 17) procedure (getter-with-setter (getter procedure?) (setter procedure?) ) ⟹ procedure?
This evaluates to a new anonymous procedure which when applied invokes getter, and whose setter is setter. It is an error for a program to subsequently try to modify the setter of the resulting compound.
For example, we could define:
(define car (getter-with-setter %primitive-car %primitive-set-car!))
(define set-car! %primitive-set-car!)
library (srfi 18)
(srfi 18) procedure (current-thread ) ⟹ thread?
Returns the current thread.
(srfi 18) procedure (thread? object ) ⟹ boolean?
Returns #t if obj is a thread, otherwise returns #f.
(srfi 18) procedure (make-thread (thunk procedure?) ) ⟹ thread?
(srfi 18) procedure (make-thread (thunk procedure?) name ) ⟹ thread?
(thunk ) ⟹ *
Returns a new thread. This thread is not automatically made runnable (the procedure thread-start! must be used for this). A thread has the following fields: name, specific, end-result, end-exception, and a list of locked/owned mutexes it owns. The thread's execution consists of a call to thunk with the "initial continuation". This continuation causes the (then) current thread to store the result in its end-result field, abandon all mutexes it owns, and finally terminate. The dynamic-wind stack of the initial continuation is empty. The optional name is an arbitrary Scheme object which identifies the thread (useful for debugging); it defaults to an unspecified value. The specific field is set to an unspecified value. The thread inherits the dynamic environment from the current thread. Moreover, in this dynamic environment the exception handler is bound to the "initial exception handler" which is a unary procedure which causes the (then) current thread to store in its end-exception field an "uncaught exception" object whose "reason" is the argument of the handler, abandon all mutexes it owns, and finally terminate.
(srfi 18) procedure (thread-name (thread thread?) ) ⟹ *
Returns the name of the thread.
(srfi 18) procedure (thread-specific (thread thread?) ) ⟹ *
Returns the content of the thread's specific field.
(srfi 18) procedure (thread-specific-set! (thread thread?) obj ) ⟹ undefined
Stores obj into the thread's specific field. thread-specific-set! returns an unspecified value.
(srfi 18) procedure (thread-start! (thread thread?) ) ⟹ undefined
Makes thread runnable. The thread must be a new thread. thread-start! returns the thread.
(srfi 18) procedure (thread-yield! (thread thread?) ) ⟹ undefined
The current thread exits the running state as if its quantum had expired. thread-yield! returns an unspecified value.
(srfi 18) procedure (thread-sleep! (timeout integer?) ) ⟹ undefined
The current thread waits until the timeout is reached. This blocks the thread only if timeout represents a point in the future. It is an error for timeout to be #f. thread-sleep! returns an unspecified value.
(srfi 18) procedure (thread-terminate! (thread thread?) ) ⟹ undefined
Causes an abnormal termination of the thread. If the thread is not already terminated, all mutexes owned by the thread become unlocked/abandoned and a "terminated thread exception" object is stored in the thread's end-exception field. If thread is the current thread, thread-terminate! does not return. Otherwise thread-terminate! returns an unspecified value; the termination of the thread will occur before thread-terminate! returns.
(srfi 18) procedure (thread-join! (thread thread?) ) ⟹ *
(srfi 18) procedure (thread-join! (thread thread?) (timeout integer?) ) ⟹ *
(srfi 18) procedure (thread-join! (thread thread?) (timeout integer?) timeout-val ) ⟹ *
The current thread waits until the thread terminates (normally or not) or until the timeout is reached if timeout is supplied. If the timeout is reached, thread-join! returns timeout-val if it is supplied, otherwise a "join timeout exception" is raised. If the thread terminated normally, the content of the end-result field is returned, otherwise the content of the end-exception field is raised.
(srfi 18) procedure (mutex? object ) ⟹ boolean?
Returns #t if obj is a mutex, otherwise returns #f.
(srfi 18) procedure (make-mutex ) ⟹ mutex?
(srfi 18) procedure (make-mutex name ) ⟹ mutex?
Returns a new mutex in the unlocked/not-abandoned state. The optional name is an arbitrary Scheme object which identifies the mutex (useful for debugging); it defaults to an unspecified value. The mutex's specific field is set to an unspecified value.
(srfi 18) procedure (mutex-name (mutex mutex?) ) ⟹ *
Returns the name of the mutex.
(srfi 18) procedure (mutex-specific (mutex mutex?) ) ⟹ *
Returns the content of the mutex's specific field.
(srfi 18) procedure (mutex-specific-set! (mutex mutex?) obj ) ⟹ undefined
Stores obj into the mutex's specific field. mutex-specific-set! returns an unspecified value.
(srfi 18) procedure (mutex-state (mutex mutex?) ) ⟹ thread? / symbol? /
Returns information about the state of the mutex. The possible results are:
(srfi 18) procedure (mutex-lock! (mutex mutex?) ) ⟹ boolean?
(srfi 18) procedure (mutex-lock! (mutex mutex?) (timeout integer?) ) ⟹ boolean?
(srfi 18) procedure (mutex-lock! (mutex mutex?) (timeout integer?) (thread (or #fthread?)) ) ⟹ boolean?
If the mutex is currently locked, the current thread waits until the mutex is unlocked, or until the timeout is reached if timeout is supplied. If the timeout is reached, mutex-lock! returns #f. Otherwise, the state of the mutex is changed as follows:
if T is terminated the mutex becomes unlocked/abandoned,
otherwise mutex becomes locked/owned with T as the owner.
After changing the state of the mutex, an "abandoned mutex exception" is raised if the mutex was unlocked/abandoned before the state change, otherwise mutex-lock! returns #t. It is not an error if the mutex is owned by the current thread (but the current thread will have to wait).
(srfi 18) procedure (mutex-unlock! (mutex mutex?) ) ⟹ boolean?
(srfi 18) procedure (mutex-unlock! (mutex mutex?) (condition-variable condition-variable?) ) ⟹ boolean?
(srfi 18) procedure (mutex-unlock! (mutex mutex?) (condition-variable condition-variable?) (timeout integer?) ) ⟹ boolean?
Unlocks the mutex by making it unlocked/not-abandoned. It is not an error to unlock an unlocked mutex and a mutex that is owned by any thread. If condition-variable is supplied, the current thread is blocked and added to the condition-variable before unlocking mutex; the thread can unblock at any time but no later than when an appropriate call to condition-variable-signal! or condition-variable-broadcast! is performed (see below), and no later than the timeout (if timeout is supplied). If there are threads waiting to lock this mutex, the scheduler selects a thread, the mutex becomes locked/owned or locked/not-owned, and the thread is unblocked. mutex-unlock! returns #f when the timeout is reached, otherwise it returns #t.
NOTE: The reason the thread can unblock at any time (when condition-variable is supplied) is to allow extending this SRFI with primitives that force a specific blocked thread to become runnable. For example a primitive to interrupt a thread so that it performs a certain operation, whether the thread is blocked or not, may be useful to handle the case where the scheduler has detected a serious problem (such as a deadlock) and it must unblock one of the threads (such as the primordial thread) so that it can perform some appropriate action. After a thread blocked on a condition-variable has handled such an interrupt it would be wrong for the scheduler to return the thread to the blocked state, because any calls to condition-variable-broadcast! during the interrupt will have gone unnoticed. It is necessary for the thread to remain runnable and return from the call to mutex-unlock! with a result of #t.
NOTE: mutex-unlock! is related to the "wait" operation on condition variables available in other thread systems. The main difference is that "wait" automatically locks mutex just after the thread is unblocked. This operation is not performed by mutex-unlock! and so must be done by an explicit call to mutex-lock!. This has the advantages that a different timeout and exception handler can be specified on the mutex-lock! and mutex-unlock! and the location of all the mutex operations is clearly apparent.
(srfi 18) procedure (condition-variable? object ) ⟹ boolean?
Returns #t if obj is a condition variable, otherwise returns #f.
(srfi 18) procedure (make-condition-variable ) ⟹ condition-variable?
(srfi 18) procedure (make-condition-variable name ) ⟹ condition-variable?
(srfi 18) procedure (make-condition-variable name ) ⟹ condition-variable?
Returns a new empty condition variable. The optional name is an arbitrary Scheme object which identifies the condition variable (useful for debugging); it defaults to an unspecified value. The condition variable's specific field is set to an unspecified value.
(srfi 18) procedure (condition-variable-name (condition-variable condition-variable?) ) ⟹ *
Returns the name of the condition-variable.
(srfi 18) procedure (condition-variable-specific (condition-variable condition-variable?) ) ⟹ *
Returns the content of the condition-variable's specific field.
(srfi 18) procedure (condition-variable-specific-set! (condition-variable condition-variable?) obj ) ⟹ undefined
Stores obj into the condition-variable's specific field. condition-variable-specific-set! returns an unspecified value.
(srfi 18) procedure (condition-variable-signal! (condition-variable condition-variable?) ) ⟹ undefined
If there are threads blocked on the condition-variable, the scheduler selects a thread and unblocks it. condition-variable-signal! returns an unspecified value.
(srfi 18) procedure (condition-variable-broadcast! (condition-variable condition-variable?) ) ⟹ undefined
Unblocks all the threads blocked on the condition-variable. condition-variable-broadcast! returns an unspecified value.
(srfi 18) procedure (current-time ) ⟹ time?
Returns the time object corresponding to the current time.
(srfi 18) procedure (time? obj ) ⟹ boolean?
Returns #t if obj is a time object, otherwise returns #f.
(srfi 18) procedure (time->seconds (time time?) ) ⟹ real?
Converts the time object time into an exact or inexact real number representing the number of seconds elapsed since some implementation dependent reference point.
(srfi 18) procedure (seconds->time (seconds real?) ) ⟹ time?
Converts into a time object the exact or inexact real number x representing the number of seconds elapsed since some implementation dependent reference point.
(srfi 18) procedure (current-exception-handler ) ⟹ procedure?
(return err ) ⟹ *
Returns the current exception handler.
(srfi 18) procedure (with-exception-handler (handler procedure?) (thunk procedure?) ) ⟹ *
(handler err ) ⟹ *
(thunk ) ⟹ *
Returns the result(s) of calling thunk with no arguments. The handler, which must be a procedure, is installed as the current exception handler in the dynamic environment in effect during the call to thunk.
(srfi 18) procedure (raise obj ) ⟹ undefined
Calls the current exception handler with obj as the single argument. obj may be any Scheme object.
(srfi 18) procedure (join-timeout-exception? obj ) ⟹ boolean?
Returns #t if obj is a "join timeout exception" object, otherwise returns #f. A join timeout exception is raised when thread-join! is called, the timeout is reached and no timeout-val is supplied.
(srfi 18) procedure (abandoned-mutex-exception? obj ) ⟹ boolean?
Returns #t if obj is an "abandoned mutex exception" object, otherwise returns #f. An abandoned mutex exception is raised when the current thread locks a mutex that was owned by a thread which terminated (see mutex-lock!).
(srfi 18) procedure (terminated-thread-exception? obj ) ⟹ boolean?
Returns #t if obj is a "terminated thread exception" object, otherwise returns #f. A terminated thread exception is raised when thread-join! is called and the target thread has terminated as a result of a call to thread-terminate!.
(srfi 18) procedure (uncaught-exception? obj ) ⟹ boolean?
Returns #t if obj is an "uncaught exception" object, otherwise returns #f. An uncaught exception is raised when thread-join! is called and the target thread has terminated because it raised an exception that called the initial exception handler of that thread.
(srfi 18) procedure (uncaught-exception-reason (exc uncaught-exception?) ) ⟹ *
exc must be an "uncaught exception" object. uncaught-exception-reason returns the object which was passed to the initial exception handler of that thread.
library (srfi 19)
time-duration ⟹ time-type
Symbol representing Time duration.
time-monotonic ⟹ time-type
Symbol representing monotonic time.
time-process ⟹ time-type
Symbol representing time spent in current process.
time-tai ⟹ time-type
Symbol representing TAI time.
time-thread ⟹ time-type
Symbol representing time spent in current thread.
time-utc ⟹ time-type
Symbol representing UTC time.
(srfi 19) procedure (current-date ) ⟹ date?
(srfi 19) procedure (current-date (tz-offset integer?) ) ⟹ date?
Date corresponding to the current UTC time.
(srfi 19) procedure (current-julian-day ) ⟹ real?
Current Julian Day.
(srfi 19) procedure (current-modified-julian-day ) ⟹ real?
Current Modified Julian Day.
(srfi 19) procedure (current-time ) ⟹ time?
(srfi 19) procedure (current-time (type time-type) ) ⟹ time?
Current time, of type time-type system, which defaults to TIME-UTC.
(srfi 19) procedure (time-resolution ) ⟹ integer?
(srfi 19) procedure (time-resolution (type time-type) ) ⟹ integer?
Clock resolution, in nanoseconds, of the system clock of type type time-type system, which defaults to TIME-UTC.
(srfi 19) procedure (make-time (type time-type) (nanosecond integer?) (second integer?) ) ⟹ time?
Creates a time object.
(srfi 19) procedure (time? obj ) ⟹ boolean?
#t if object is a time object, otherwise, #f.
(srfi 19) procedure (time-type (time time?) ) ⟹ time-type
Time type.
(srfi 19) procedure (time-nanosecond (time time?) ) ⟹ integer?
Time nanosecond.
(srfi 19) procedure (time-second (time time?) ) ⟹ integer?
Time second.
(srfi 19) procedure (set-time-type! (time time?) (time-type time-type) ) ⟹ undefined
Changes time type. Note: This changes the semantics of the time object. To convert a time to another system of representation, use one of the conversion procedures.
(srfi 19) procedure (set-time-nanosecond! (time time?) (nanosecond integer?) ) ⟹ undefined
Changes time nanosecond.
(srfi 19) procedure (set-time-second! (time time?) (second integer?) ) ⟹ undefined
Changes time second.
(srfi 19) procedure (copy-time (time time?) ) ⟹ time?
Creates a new time object, with the same time type, nanosecond, and second as time1.
(srfi 19) procedure (time<=? (time1 time?) (time2 time?) ) ⟹ boolean?
#t if time1 is before or at (less than or equal to) time2, #f otherwise.
(srfi 19) procedure (time<? (time1 time?) (time2 time?) ) ⟹ boolean?
#t if time1 is before (less than) time2, #f otherwise.
(srfi 19) procedure (time=? (time1 time?) (time2 time?) ) ⟹ boolean?
#t if time1 at (equal) time2, #f otherwise.
(srfi 19) procedure (time>=? (time1 time?) (time2 time?) ) ⟹ boolean?
#t if time1 is at or after (greater than or equal to) time2, #f otherwise.
(srfi 19) procedure (time>? (time1 time?) (time2 time?) ) ⟹ boolean?
#t if time1 is after (greater than) time2, #f otherwise.
(srfi 19) procedure (time-difference (time1 time?) (time2 time?) ) ⟹ time?
The TIME-DURATION between time1 and time2. It is an error if time1 and time2 are of different time types. A new time object is created.
(srfi 19) procedure (time-difference! (time1 time?) (time2 time?) ) ⟹ time?
The TIME-DURATION between time1 and time2. It is an error if time1 and time2 are of different time types. Time1 may be used to create the resulting TIME-DURATION object.
(srfi 19) procedure (add-duration (time1 time?) (time-duration time?) ) ⟹ time?
The time resulting from adding time-duration to time1, which is a time object of the same time type as time1. A new time object is created.
(srfi 19) procedure (add-duration! (time1 time?) (time-duration time?) ) ⟹ time?
The time resulting from adding time-duration to time1, which is a time object of the same time type as time1. Time1 may used to create the resulting time object.
(srfi 19) procedure (subtract-duration (time1 time?) (time-duration time?) ) ⟹ time?
The time resulting from subtracting time-duration from time1, which is a time object of the same time type as time1. A new time object is created.
(srfi 19) procedure (subtract-duration! (time1 time?) (time-duration time?) ) ⟹ time?
The time resulting from subtracting time-duration from time1, which is a time object of the same time type as time1. Time1 may used to create the resulting time object.
(srfi 19) procedure (make-date (nanosecond integer?) (second integer?) (minute integer?) (hour integer?) (day integer?) (month integer?) (year integer?) (zone-offset integer?) ) ⟹ date?
Creates a date object.
(srfi 19) procedure (date? obj ) ⟹ boolean?
#t if object is a time object, otherwise, #f.
(srfi 19) procedure (date-nanosecond (date date?) ) ⟹ integer?
Date nanosecond.
(srfi 19) procedure (date-second (date date?) ) ⟹ integer?
Date second.
(srfi 19) procedure (date-minute (date date?) ) ⟹ integer?
Date minute.
(srfi 19) procedure (date-hour (date date?) ) ⟹ integer?
Date hour.
(srfi 19) procedure (date-day (date date?) ) ⟹ integer?
Date day.
(srfi 19) procedure (date-month (date date?) ) ⟹ integer?
Date month.
(srfi 19) procedure (date-year (date date?) ) ⟹ integer?
Date year.
(srfi 19) procedure (date-zone-offset (date date?) ) ⟹ integer?
Date time zone offset.
(srfi 19) procedure (date-year-day (date date?) ) ⟹ integer?
The ordinal day of the year of this date. January 1 is 1, etc.
(srfi 19) procedure (date-week-day (date date?) ) ⟹ integer?
The day of the week of this date, where Sunday=0, Monday=1, etc.
(srfi 19) procedure (date-week-number (date date?) (day-of-week-starting-week integer?) ) ⟹ integer?
The ordinal week of the year which holds this date, ignoring a first partial week. 'Day-of-week-starting-week' is the integer corresponding to the day of the week which is to be considered the first day of the week (Sunday=0, Monday=1, etc.).
(srfi 19) procedure (date->julian-day (date date?) ) ⟹ real?
Convert date to Julian Day.
(srfi 19) procedure (date->modified-julian-day (date date?) ) ⟹ real?
Convert date to Modified Julian Day.
(srfi 19) procedure (date->time-monotonic (date date?) ) ⟹ time?
Convert date to monotonic time.
(srfi 19) procedure (date->time-tai (date date?) ) ⟹ time?
Convert date to TAI time.
(srfi 19) procedure (date->time-utc (date date?) ) ⟹ time?
Convert date to UTC time.
(srfi 19) procedure (julian-day->date (jd real?) ) ⟹ date?
(srfi 19) procedure (julian-day->date (jd real?) (tz-offset integer?) ) ⟹ date?
Convert Julian Day to date, , using time zone offset, which defaults to the local time zone.
(srfi 19) procedure (julian-day->time-monotonic (jd real?) ) ⟹ time?
Convert Julian Day to monotonic time.
(srfi 19) procedure (julian-day->time-tai (jd real?) ) ⟹ time?
Convert Julian Day to TAI time.
(srfi 19) procedure (julian-day->time-utc (jd real?) ) ⟹ time?
Convert Julian Day to UTC time.
(srfi 19) procedure (modified-julian-day->date (jd real?) ) ⟹ date?
(srfi 19) procedure (modified-julian-day->date (jd real?) (tz-offset integer?) ) ⟹ date?
Convert Modified Julian Day to date, using time zone offset, which defaults to the local time zone.
(srfi 19) procedure (modified-julian-day->time-monotonic (jd real?) ) ⟹ time?
Convert Modified Julian Day to monotonic time.
(srfi 19) procedure (modified-julian-day->time-tai (jd real?) ) ⟹ time?
Convert Modified Julian Day to TAI time.
(srfi 19) procedure (modified-julian-day->time-utc (jd real?) ) ⟹ time?
Convert Modified Julian Day to UTC time.
(srfi 19) procedure (time-monotonic->date (time-monotonic time?) ) ⟹ date?
(srfi 19) procedure (time-monotonic->date (time-monotonic time?) (tz-offset integer?) ) ⟹ date?
Convert monotonic time to date, using time zone offset, which defaults to the local time zone.
(srfi 19) procedure (time-monotonic->julian-day (time-monotonic time?) ) ⟹ real?
Convert monotonic time to Julian Day.
(srfi 19) procedure (time-monotonic->modified-julian-day (time-monotonic time?) ) ⟹ real?
Convert monotonic time to Modified Julian Day.
(srfi 19) procedure (time-monotonic->time-tai (time-monotonic time?) ) ⟹ time?
Convert monotonic time to TAI time.
(srfi 19) procedure (time-monotonic->time-tai! (time-monotonic time?) ) ⟹ time?
Convert monotonic time to TAI time. The time structure may be reused.
(srfi 19) procedure (time-monotonic->time-utc (time-monotonic time?) ) ⟹ time?
Convert monotonic time to UTC time.
(srfi 19) procedure (time-monotonic->time-utc! (time-monotonic time?) ) ⟹ time?
Convert monotonic time to UTC time. The time structure may be reused.
(srfi 19) procedure (time-tai->date (time-tai time?) ) ⟹ date?
(srfi 19) procedure (time-tai->date (time-tai time?) (tz-offset integer?) ) ⟹ date?
Convert TAI time to date, using time zone offset, which defaults to the local time zone.
(srfi 19) procedure (time-tai->julian-day (time-tai time?) ) ⟹ real?
Convert TAI time to Julian Day.
(srfi 19) procedure (time-tai->modified-julian-day (time-tai time?) ) ⟹ real?
Convert TAI time to Modified Julian Day.
(srfi 19) procedure (time-tai->time-monotonic (time-tai time?) ) ⟹ time?
Convert TAI time to monotonic time.
(srfi 19) procedure (time-tai->time-monotonic! (time-tai time?) ) ⟹ time?
Convert TAI time to monotonic time. The time structure may be reused.
(srfi 19) procedure (time-tai->time-utc (time-tai time?) ) ⟹ time?
Convert TAI time to UTC time.
(srfi 19) procedure (time-tai->time-utc! (time-tai time?) ) ⟹ time?
Convert TAI time to UTC time. The time structure may be reused.
(srfi 19) procedure (time-utc->date (time-utc time?) ) ⟹ date?
(srfi 19) procedure (time-utc->date (time-utc time?) (tz-offset integer?) ) ⟹ date?
Convert UTC time to date, using time zone offset, which defaults to the local time zone.
(srfi 19) procedure (time-utc->julian-day (time-utc time?) ) ⟹ real?
Convert UTC time to Julian Day
(srfi 19) procedure (time-utc->modified-julian-day (time-utc time?) ) ⟹ real?
Convert UTC time to Modified Julian Day.
(srfi 19) procedure (time-utc->time-tai (time-utc time?) ) ⟹ time?
Convert UTC time to TAI time.
(srfi 19) procedure (time-utc->time-tai! (time-utc time?) ) ⟹ time?
Convert UTC time to TAI time. The time structure may be reused.
(srfi 19) procedure (date->string (date date?) ) ⟹ string?
(srfi 19) procedure (date->string (date date?) (format-string string?) ) ⟹ string?
Converts a date to a string, using the format string. The format string is copied as is; except escape characters (indicated by the tilde) are replaced with specific conversions.
~~ a literal ~
~a locale's abbreviated weekday name (Sun...Sat)
~A locale's full weekday name (Sunday...Saturday)
~b locale's abbreviate month name (Jan...Dec)
~B locale's full month day (January...December)
~c locale's date and time (e.g., "Fri Jul 14 20:28:42-0400 2000")
~d day of month, zero padded (01...31)
~D date (mm/dd/yy)
~e day of month, blank padded ( 1...31)
~f seconds+fractional seconds, using locale's decimal separator (e.g. 5.2).
~h same as ~b
~H hour, zero padded, 24-hour clock (00...23)
~I hour, zero padded, 12-hour clock (01...12)
~j day of year, zero padded
~k hour, blank padded, 24-hour clock ( 0...23)
~l hour, blank padded, 12-hour clock ( 1...12)
~m month, zero padded (01...12)
~M minute, zero padded (00...59)
~n new line
~N nanosecond, zero padded
~p locale's AM or PM
~r time, 12 hour clock, same as "~I:~M:~S ~p"
~s number of full seconds since "the epoch" (in UTC)
~S second, zero padded (00...60)
~t horizontal tab
~T time, 24 hour clock, same as "~H:~M:~S"
~U week number of year with Sunday as first day of week (00...53)
~V ISO 8601 week number of the year with Monday as first day of week (01..53)[1]
~w day of week (0...6)
~W week number of year with Monday as first day of week (01...52)
~x locale's date representation[1]
~X locale's time representation[1]
~y last two digits of year (00...99)
~Y year
~z time zone in RFC-822 style
~Z symbol time zone (not-implemented)
~1 ISO-8601 year-month-day format
~2 ISO-8601 hour-minute-second-timezone format
~3 ISO-8601 hour-minute-second format
~4 ISO-8601 year-month-day-hour-minute-second-timezone format
~5 ISO-8601 year-month-day-hour-minute-second format
(srfi 19) procedure (string->date (input-string string?) (template-string string?) ) ⟹ date?
Converts an input string to a date, using the template string. The input string must match the template string as is; except escape characters (indicate by the tilde) indicate special converters which (1) move to the next character in the input string fulfilling a criterion; (2) read a value, and (3) act on this value in some way.
Char: ~~. Skip to: any. Read: read literal ~ . Set: nothing.
Char: ~a. Skip to: char-alphabetic?. Read: abbreviated weekday in locale . Set: nothing.
Char: ~A. Skip to: char-alphabetic?. Read: full weekday in locale . Set: nothing.
Char: ~b. Skip to: char-alphabetic?. Read: abbreviated month name in locale . Set: nothing.
Char: ~B. Skip to: char-alphabetic?. Read: full month name in locale . Set: nothing.
Char: ~d. Skip to: char-numeric?. Read: day of month . Set: date-day.
Char: ~e. Skip to: any. Read: day of month, blank padded . Set: date-day.
Char: ~h. Skip to: char-alphabetic?. Read: same as ~b . Set: nothing.
Char: ~H. Skip to: char-numeric?. Read: hour . Set: date-hour.
Char: ~k. Skip to: any. Read: hour, blank padded . Set: date-hour.
Char: ~m. Skip to: char-numeric?. Read: month . Set: date-month.
Char: ~M. Skip to: char-numeric?. Read: minute . Set: date-minute.
Char: ~S. Skip to: char-numeric?. Read: second . Set: date-second.
Char: ~y. Skip to: any. Read: 2-digit year . Set: date-year within 50 years.
Char: ~Y. Skip to: char-numeric?. Read: year . Set: date-year.
Char: ~z. Skip to: any. Read: time zone . Set: date-zone-offset.
library (srfi 21)
(srfi 21) procedure (current-thread ) ⟹ thread?
Returns the current thread.
(srfi 21) procedure (thread? object ) ⟹ boolean?
Returns #t if obj is a thread, otherwise returns #f.
(srfi 21) procedure (make-thread (thunk procedure?) ) ⟹ thread?
(srfi 21) procedure (make-thread (thunk procedure?) name ) ⟹ thread?
(thunk ) ⟹ *
Returns a new thread. This thread is not automatically made runnable (the procedure thread-start! must be used for this). A thread has the following fields: base priority, priority boost, boosted flag, quantum, name, specific, end-result, end-exception, and a list of locked/owned mutexes it owns. The thread's execution consists of a call to thunk with the "initial continuation". This continuation causes the (then) current thread to store the result in its end-result field, abandon all mutexes it owns, and finally terminate. The dynamic-wind stack of the initial continuation is empty. The optional name is an arbitrary Scheme object which identifies the thread (useful for debugging); it defaults to an unspecified value. The specific field is set to an unspecified value. The base priority, priority boost, and quantum of the thread are set to the same value as the current thread and the boosted flag is set to false. The thread inherits the dynamic environment from the current thread. Moreover, in this dynamic environment the exception handler is bound to the "initial exception handler" which is a unary procedure which causes the (then) current thread to store in its end-exception field an "uncaught exception" object whose "reason" is the argument of the handler, abandon all mutexes it owns, and finally terminate.
(srfi 21) procedure (thread-name (thread thread?) ) ⟹ *
Returns the name of the thread.
(srfi 21) procedure (thread-specific (thread thread?) ) ⟹ *
Returns the content of the thread's specific field.
(srfi 21) procedure (thread-specific-set! (thread thread?) obj ) ⟹ undefined
Stores obj into the thread's specific field. thread-specific-set! returns an unspecified value.
(srfi 21) procedure (thread-base-priority (thread thread?) ) ⟹ real?
Returns a real number which corresponds to the base priority of the thread.
(srfi 21) procedure (thread-base-priority-set! (thread thread?) (priority real?) ) ⟹ undefined
Changes the base priority of the thread to priority. The priority must be a real number. thread-base-priority-set! returns an unspecified value.
(srfi 21) procedure (thread-priority-boost (thread thread?) ) ⟹ real?
Returns a real number which corresponds to the priority boost of the thread.
(srfi 21) procedure (thread-priority-boost-set! (thread thread?) (priority-boost real?) ) ⟹ undefined
Changes the priority boost of the thread to priority-boost. The priority-boost must be a non-negative real. thread-priority-boost-set! returns an unspecified value.
(srfi 21) procedure (thread-quantum (thread thread?) ) ⟹ real?
Returns a real number which corresponds to the quantum of the thread.
(srfi 21) procedure (thread-quantum-set! (thread thread?) (quantum real?) ) ⟹ undefined
Changes the quantum of the thread to quantum. The quantum must be a non-negative real. A value of zero selects the smallest quantum supported by the implementation. thread-quantum-set! returns an unspecified value.
(srfi 21) procedure (thread-start! (thread thread?) ) ⟹ thread?
Makes thread runnable. The thread must be a new thread. thread-start! returns the thread.
(srfi 21) procedure (thread-yield! (thread thread?) ) ⟹ undefined
The current thread exits the running state as if its quantum had expired. thread-yield! returns an unspecified value.
(srfi 21) procedure (thread-sleep! (timeout integer?) ) ⟹ undefined
The current thread waits until the timeout is reached. This blocks the thread only if timeout represents a point in the future. It is an error for timeout to be #f. thread-sleep! returns an unspecified value.
(srfi 21) procedure (thread-terminate! (thread thread?) ) ⟹ undefined
Causes an abnormal termination of the thread. If the thread is not already terminated, all mutexes owned by the thread become unlocked/abandoned and a "terminated thread exception" object is stored in the thread's end-exception field. If thread is the current thread, thread-terminate! does not return. Otherwise thread-terminate! returns an unspecified value; the termination of the thread will occur before thread-terminate! returns.
(srfi 21) procedure (thread-join! (thread thread?) ) ⟹ *
(srfi 21) procedure (thread-join! (thread thread?) (timeout integer?) ) ⟹ *
(srfi 21) procedure (thread-join! (thread thread?) (timeout integer?) timeout-val ) ⟹ *
The current thread waits until the thread terminates (normally or not) or until the timeout is reached if timeout is supplied. If the timeout is reached, thread-join! returns timeout-val if it is supplied, otherwise a "join timeout exception" is raised. If the thread terminated normally, the content of the end-result field is returned, otherwise the content of the end-exception field is raised.
(srfi 21) procedure (mutex? object ) ⟹ boolean?
Returns #t if obj is a mutex, otherwise returns #f.
(srfi 21) procedure (make-mutex ) ⟹ mutex?
(srfi 21) procedure (make-mutex name ) ⟹ mutex?
Returns a new mutex in the unlocked/not-abandoned state. The optional name is an arbitrary Scheme object which identifies the mutex (useful for debugging); it defaults to an unspecified value. The mutex's specific field is set to an unspecified value.
(srfi 21) procedure (mutex-name (mutex mutex?) ) ⟹ *
Returns the name of the mutex.
(srfi 21) procedure (mutex-specific (mutex mutex?) ) ⟹ *
Returns the content of the mutex's specific field.
(srfi 21) procedure (mutex-specific-set! (mutex mutex?) obj ) ⟹ undefined
Stores obj into the mutex's specific field. mutex-specific-set! returns an unspecified value.
(srfi 21) procedure (mutex-state (mutex mutex?) ) ⟹ thread? / symbol? /
Returns information about the state of the mutex. The possible results are:
(srfi 21) procedure (mutex-lock! (mutex mutex?) ) ⟹ boolean?
(srfi 21) procedure (mutex-lock! (mutex mutex?) (timeout integer?) ) ⟹ boolean?
(srfi 21) procedure (mutex-lock! (mutex mutex?) (timeout integer?) (thread (or #fthread?)) ) ⟹ boolean?
If the mutex is currently locked, the current thread waits until the mutex is unlocked, or until the timeout is reached if timeout is supplied. If the timeout is reached, mutex-lock! returns #f. Otherwise, the state of the mutex is changed as follows:
if T is terminated the mutex becomes unlocked/abandoned,
otherwise mutex becomes locked/owned with T as the owner.
After changing the state of the mutex, an "abandoned mutex exception" is raised if the mutex was unlocked/abandoned before the state change, otherwise mutex-lock! returns #t. It is not an error if the mutex is owned by the current thread (but the current thread will have to wait).
(srfi 21) procedure (mutex-unlock! (mutex mutex?) ) ⟹ boolean?
(srfi 21) procedure (mutex-unlock! (mutex mutex?) (condition-variable condition-variable?) ) ⟹ boolean?
(srfi 21) procedure (mutex-unlock! (mutex mutex?) (condition-variable condition-variable?) (timeout integer?) ) ⟹ boolean?
Unlocks the mutex by making it unlocked/not-abandoned. It is not an error to unlock an unlocked mutex and a mutex that is owned by any thread. If condition-variable is supplied, the current thread is blocked and added to the condition-variable before unlocking mutex; the thread can unblock at any time but no later than when an appropriate call to condition-variable-signal! or condition-variable-broadcast! is performed (see below), and no later than the timeout (if timeout is supplied). If there are threads waiting to lock this mutex, the scheduler selects a thread, the mutex becomes locked/owned or locked/not-owned, and the thread is unblocked. mutex-unlock! returns #f when the timeout is reached, otherwise it returns #t.
(srfi 21) procedure (condition-variable? object ) ⟹ boolean?
Returns #t if obj is a condition variable, otherwise returns #f.
(srfi 21) procedure (make-condition-variable ) ⟹ condition-variable?
(srfi 21) procedure (make-condition-variable name ) ⟹ condition-variable?
(srfi 21) procedure (make-condition-variable name ) ⟹ condition-variable?
Returns a new empty condition variable. The optional name is an arbitrary Scheme object which identifies the condition variable (useful for debugging); it defaults to an unspecified value. The condition variable's specific field is set to an unspecified value.
(srfi 21) procedure (condition-variable-name (condition-variable condition-variable?) ) ⟹ *
Returns the name of the condition-variable.
(srfi 21) procedure (condition-variable-specific (condition-variable condition-variable?) ) ⟹ *
Returns the content of the condition-variable's specific field.
(srfi 21) procedure (condition-variable-specific-set! (condition-variable condition-variable?) obj ) ⟹ undefined
Stores obj into the condition-variable's specific field. condition-variable-specific-set! returns an unspecified value.
(srfi 21) procedure (condition-variable-signal! (condition-variable condition-variable?) ) ⟹ undefined
If there are threads blocked on the condition-variable, the scheduler selects a thread and unblocks it. condition-variable-signal! returns an unspecified value.
(srfi 21) procedure (condition-variable-broadcast! (condition-variable condition-variable?) ) ⟹ undefined
Unblocks all the threads blocked on the condition-variable. condition-variable-broadcast! returns an unspecified value.
(srfi 21) procedure (current-time ) ⟹ time?
Returns the time object corresponding to the current time.
(srfi 21) procedure (time? obj ) ⟹ boolean?
Returns #t if obj is a time object, otherwise returns #f.
(srfi 21) procedure (time->seconds (time time?) ) ⟹ real?
Converts the time object time into an exact or inexact real number representing the number of seconds elapsed since some implementation dependent reference point.
(srfi 21) procedure (seconds->time (seconds real?) ) ⟹ time?
Converts into a time object the exact or inexact real number x representing the number of seconds elapsed since some implementation dependent reference point.
(srfi 21) procedure (current-exception-handler ) ⟹ procedure?
(return err ) ⟹ *
Returns the current exception handler.
(srfi 21) procedure (with-exception-handler (handler procedure?) (thunk procedure?) ) ⟹ *
(handler err ) ⟹ *
(thunk ) ⟹ *
Returns the result(s) of calling thunk with no arguments. The handler, which must be a procedure, is installed as the current exception handler in the dynamic environment in effect during the call to thunk.
(srfi 21) procedure (raise obj ) ⟹ undefined
Calls the current exception handler with obj as the single argument. obj may be any Scheme object.
(srfi 21) procedure (join-timeout-exception? obj ) ⟹ boolean?
Returns #t if obj is a "join timeout exception" object, otherwise returns #f. A join timeout exception is raised when thread-join! is called, the timeout is reached and no timeout-val is supplied.
(srfi 21) procedure (abandoned-mutex-exception? obj ) ⟹ boolean?
Returns #t if obj is an "abandoned mutex exception" object, otherwise returns #f. An abandoned mutex exception is raised when the current thread locks a mutex that was owned by a thread which terminated (see mutex-lock!).
(srfi 21) procedure (terminated-thread-exception? obj ) ⟹ boolean?
Returns #t if obj is a "terminated thread exception" object, otherwise returns #f. A terminated thread exception is raised when thread-join! is called and the target thread has terminated as a result of a call to thread-terminate!.
(srfi 21) procedure (uncaught-exception? obj ) ⟹ boolean?
Returns #t if obj is an "uncaught exception" object, otherwise returns #f. An uncaught exception is raised when thread-join! is called and the target thread has terminated because it raised an exception that called the initial exception handler of that thread.
(srfi 21) procedure (uncaught-exception-reason (exc uncaught-exception?) ) ⟹ *
exc must be an "uncaught exception" object. uncaught-exception-reason returns the object which was passed to the initial exception handler of that thread.
library (srfi 23)
(srfi 23) 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 (srfi 25)
(srfi 25) procedure (array? obj ) ⟹ boolean?
Returns #t if obj is an array, otherwise returns #f.
(srfi 25) procedure (make-array (shape array?) ) ⟹ array?
(srfi 25) procedure (make-array (shape array?) obj ) ⟹ array?
Returns a newly allocated array whose shape is given by shape. If obj is provided, then each element is initialized to it. Otherwise the initial contents of each element is unspecified. The array does not retain a dependence to shape.
(srfi 25) procedure (shape (lowerbound1 integer?) (upperbound1 integer?) ... ) ⟹ array?
Returns a shape. The sequence bound ... must consist of an even number of exact integers that are pairwise not decreasing. Each pair gives the lower and upper bound of a dimension. If the shape is used to specify the dimensions of an array and bound ... is the sequence b0 e0 ... bk ek ... of n pairs of bounds, then a valid index to the array is any sequence j0 ... jk ... of n exact integers where each jk satisfies (<= bk jk) and (< jk ek).
The shape of a d-dimensional array is a d × 2 array where the element at k 0 contains the lower bound for an index along dimension k and the element at k 1 contains the corresponding upper bound, where k satisfies (<= 0 k) and (< k d).
(srfi 25) procedure (array (shape array?) obj ... ) ⟹ array?
Returns a new array whose shape is given by shape and the initial contents of the elements are obj ... in row major order. The array does not retain a dependence to shape.
(srfi 25) procedure (array-rank (shape array?) ) ⟹ integer?
Returns the number of dimensions of array.
(srfi 25) procedure (array-start (shape array?) (k integer?) ) ⟹ integer?
Returns the lower bound for the index along dimension k.
(srfi 25) procedure (array-end (shape array?) (k integer?) ) ⟹ integer?
Returns the upper bound for the index along dimension k.
(srfi 25) procedure (array-ref (shape array?) (k integer?) ... ) ⟹ *
(srfi 25) procedure (array-ref (shape array?) (index (or vector?array?)) ) ⟹ *
Returns the contents of the element of array at index k .... The sequence k ... must be a valid index to array. In the second form, index must be either a vector or a 0-based 1-dimensional array containing k ....
(srfi 25) procedure (array-set! (shape array?) (k integer?) ... obj ) ⟹ undefined
(srfi 25) procedure (array-set! (shape array?) (index (or vector?array?)) obj ) ⟹ undefined
Stores obj in the element of array at index k .... Returns an unspecified value. The sequence k ... must be a valid index to array. In the second form, index must be either a vector or a 0-based 1-dimensional array containing k ....
library (srfi 26)
(srfi 26) syntax (cut (<> <...> ) ((_ slot-or-expr slot-or-expr ...) procedure? ) ((_ slot-or-expr slot-or-expr ... <...>) procedure? ) )
<> expression
The macro cut transforms a <cut-expression> into a <lambda expression> with as many formal variables as there are slots in the list <slot-or-expr>*. The body of the resulting <lambda expression> calls the first <slot-or-expr> with arguments from <slot-or-expr>* in the order they appear. In case there is a rest-slot symbol, the resulting procedure is also of variable arity, and the body calls the first <slot-or-expr> with all arguments provided to the actual call of the specialized procedure.
(srfi 26) syntax (cute (<> <...> ) ((_ slot-or-expr slot-or-expr ...) procedure? ) ((_ slot-or-expr slot-or-expr ... <...>) procedure? ) )
<> expression
The macro cute is similar to the macro cut, except that it first binds new variables to the result of evaluating the non-slot expressions (in an unspecific order) and then substituting the variables for the non-slot expressions. In effect, cut evaluates non-slot expressions at the time the resulting procedure is called, whereas cute evaluates the non-slot expressions at the time the procedure is constructed.
library (srfi 27)
(srfi 27) procedure (random-integer (n integer?) ) ⟹ integer?
The next integer x in {0, ..., n-1} obtained from default-random-source. Subsequent results of this procedure appear to be independent uniformly distributed over the range {0, ..., n-1}. The argument n must be a positive integer, otherwise an error is signalled.
(srfi 27) procedure (random-real ) ⟹ real?
The next number 0 < x < 1 obtained from default-random-source. Subsequent results of this procedure appear to be independent uniformly distributed. The numerical type of the results and the quantization of the output range depend on the implementation; refer to random-source-make-reals for details.
default-random-source ⟹ random-source?
A random source from which random-integer and random-real have been derived using random-source-make-integers and random-source-make-reals. Note that an assignment to default-random-source does not change random or random-real; it is also strongly recommended not to assign a new value.
(srfi 27) procedure (make-random-source ) ⟹ random-source?
Creates a new random source s. Implementations may accept additional, optional arguments in order to create different types of random sources. A random source created with make-random-source represents a deterministic stream of random bits generated by some form of pseudo random number generator. Each random source obtained as (make-random-source) generates the same stream of values, unless the state is modified with one of the procedures below.
(srfi 27) procedure (random-source? obj ) ⟹ boolean?
Tests if obj is a random source. Objects of type random source are distinct from all other types of objects.
(srfi 27) procedure (random-source-state-ref (s random-source?) ) ⟹ random-source-state
Get the current state of a random source s. The structure of the object state depends on the implementation; the only portable use of it is as argument to random-source-state-set!. It is, however, required that a state possess an external representation.
(srfi 27) procedure (random-source-state-set! (s random-source?) (state random-source-state) ) ⟹ undefined
Set the current state of a random source s.
(srfi 27) procedure (random-source-randomize! (s random-source?) ) ⟹ undefined
Makes an effort to set the state of the random source s to a truly random state. The actual quality of this randomization depends on the implementation but it can at least be assumed that the procedure sets s to a different state for each subsequent run of the Scheme system.
(srfi 27) procedure (random-source-pseudo-randomize! (s random-source?) (i integer?) (j integer?) ) ⟹ undefined
Changes the state of the random source s into the initial state of the (i, j)-th independent random source, where i and j are non-negative integers. This procedure provides a mechanism to obtain a large number of independent random sources (usually all derived from the same backbone generator), indexed by two integers. In contrast to random-source-randomize!, this procedure is entirely deterministic.
(srfi 27) procedure (random-source-make-integers (s random-source?) ) ⟹ procedure?
(return (n integer?) ) ⟹ integer?
Obtains a procedure rand to generate random integers using the random source s. Rand takes a single argument n, which must be a positive integer, and returns the next uniformly distributed random integer from the interval {0, ..., n-1} by advancing the state of the source s.
If an application obtains and uses several generators for the same random source s, a call to any of these generators advances the state of s. Hence, the generators do not produce the same sequence of random integers each but rather share a state. This also holds for all other types of generators derived from a fixed random sources. Implementations that support concurrency make sure that the state of a generator is properly advanced.
(srfi 27) procedure (random-source-make-reals (s random-source?) ) ⟹ procedure?
(srfi 27) procedure (random-source-make-reals (s random-source?) (unit real?) ) ⟹ procedure?
(return ) ⟹ real?
Obtains a procedure rand to generate random real numbers 0 < x < 1 using the random source s. The procedure rand is called without arguments.
The optional parameter unit determines the type of numbers being produced by rand and the quantization of the output. Unit must be a number such that 0 < unit < 1. The numbers created by rand are of the same numerical type as unit and the potential output values are spaced by at most unit. One can imagine rand to create numbers as x*unit where x is a random integer in {1, ..., floor(1/unit)-1}. Note, however, that this need not be the way the values are actually created and that the actual resolution of rand can be much higher than unit. In case unit is absent it defaults to a reasonably small value (related to the width of the mantissa of an efficient number format).
library (srfi 28)
(srfi 28) procedure (format (format-string string?) obj ... ) ⟹ string?
Accepts a message template (a Scheme String), and processes it, replacing any escape sequences in order with one or more characters, the characters themselves dependent on the semantics of the escape sequence encountered.
An escape sequence is a two character sequence in the string where the first character is a tilde '~'. Each escape code's meaning is as follows:
~a The corresponding value is inserted into the string as if printed with display.
~s The corresponding value is inserted into the string as if printed with write.
~% A newline is inserted.
~~ A tilde '~' is inserted.
~a and ~s, when encountered, require a corresponding Scheme value to be present after the format string. The values provided as operands are used by the escape sequences in order. It is an error if fewer values are provided than escape sequences that require them.
~% and ~~ require no corresponding value.
library (srfi 29)
(srfi 29) procedure (current-language ) ⟹ symbol?
(srfi 29) procedure (current-language (lang symbol?) ) ⟹ undefined
When given no arguments, returns the current ISO 639-1 language code as a symbol. If provided with an argument, the current language is set to that named by the symbol for the currently executing Scheme thread (or for the entire Scheme system if such a distinction is not possible).
(srfi 29) procedure (current-country ) ⟹ symbol?
(srfi 29) procedure (current-country (country symbol?) ) ⟹ undefined
returns the current ISO 3166-1 country code as a symbol. If provided with an argument, the current country is set to that named by the symbol for the currently executing Scheme thread (or for the entire Scheme system if such a distinction is not possible).
(srfi 29) procedure (current-locale-details ) ⟹ list?
(srfi 29) procedure (current-locale-details (symbols list?) ) ⟹ undefined
Returns a list of additional locale details as a list of symbols. This list may contain information about encodings or other more specific information. If provided with an argument, the current locale details are set to those given in the currently executing Scheme thread (or for the entire Scheme system if such a distinction is not possible).
(srfi 29) procedure (declare-bundle! (bundle-specifier list?) (alist list?) ) ⟹ undefined
Declares a new bundle named by the given bundle-specifier. The contents of the bundle are defined by the provided association list. The list contains associations between Scheme symbols and the message templates (Scheme strings) they name. If a bundle already exists with the given name, it is overwritten with the newly declared bundle.
(srfi 29) procedure (store-bundle (bundle-specifier list?) ) ⟹ boolean?
Attempts to store a bundle named by the given bundle specifier, and previously made available using declare-bundle! or load-bundle!, in an unspecified mechanism that may be persistent across Scheme system restarts. If successful, a non-false value is returned. If unsuccessful, #f is returned.
(srfi 29) procedure (load-bundle! (bundle-specifier list?) ) ⟹ boolean?
Attempts to retrieve a bundle from an unspecified mechanism which stores bundles outside the Scheme system. If the bundle was retrieved successfully, the function returns a non-false value, and the bundle is immediately available to the Scheme system. If the bundle could not be found or loaded successfully, the function returns #f, and the Scheme system's bundle registry remains unaffected.
(srfi 29) procedure (localized-template (package-name symbol?) (message-tpl-name symbol?) ) ⟹ string? / #f /
Retrieves a localized message template for the given package name and the given message template name (both symbols). If no such message could be found, false (#f) is returned.
library (srfi 31)
(srfi 31) syntax (rec () ((_ (name variables ...) body ...) procedure? ) ((_ name expression)) )
(define-syntax rec
(syntax-rules ()
((rec (NAME . VARIABLES) . BODY)
(letrec ( (NAME (lambda VARIABLES . BODY)) ) NAME))
((rec NAME EXPRESSION)
(letrec ( (NAME EXPRESSION) ) NAME))))
library (srfi 34)
(srfi 34) 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.
(srfi 34) 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.
(srfi 34) 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 (srfi 35)
(srfi 35) procedure (make-condition-type (id symbol?) (parent condition-type?) (field-names list?) ) ⟹ condition-type?
Make-condition-type returns a new condition type. Id must be a symbol that serves as a symbolic name for the condition type. Parent must itself be a condition type. Field-names must be a list of symbols. It identifies the fields of the conditions associated with the condition type.
Field-names must be disjoint from the field names of parent and its ancestors.
(srfi 35) procedure (condition-type? obj ) ⟹ boolean?
Condition-type? is a predicate for condition types: it returns #t if thing is a condition type, and #f otherwise
(srfi 35) procedure (make-condition (type condition-type?) (field-name1 symbol?) value1 ... ) ⟹ condition?
Make-condition creates a condition value belonging condition type type. The following arguments must be, in turn, a field name and an arbitrary value. There must be such a pair for each field of type and its direct and indirect supertypes. Make-condition returns the condition value, with the argument values associated with their respective fields.
(srfi 35) procedure (condition? obj ) ⟹ boolean?
Condition? is a predicate for conditions: it returns #t if thing is a condition type, and #f otherwise
(srfi 35) procedure (condition-has-type? (condition condition?) (type condition-type?) ) ⟹ boolean?
Condition-has-type? tests if condition condition belongs to condition type condition-type. It returns #t if any of condition 's types includes condition-type either directly or as an ancestor and #f otherwise. It is an error if condition is not a condition, or if condition-type is not a condition type.
(srfi 35) procedure (condition-ref (condition condition?) (field-name symbol?) ) ⟹ *
Condition must be a condition, and field-name a symbol. Moreover, condition must belong to a condition type which has a field name called field-name, or one of its (direct or indirect) supertypes must have the field. Condition-ref returns the value associated with field-name.
It is an error to refer to a field the condition does not have.
(srfi 35) procedure (make-compound-condition (condition1 condition?) (condition2 condition?) ... ) ⟹ condition?
Make-compound-condition returns a compound condition belonging to all condition types that the conditioni belong to.
Condition-ref, when applied to a compound condition will return the value from the first of the conditioni that has such a field.
(srfi 35) procedure (extract-condition (condition condition?) (type condition-type?) ) ⟹ condition?
Condition must be a condition belonging to condition-type. Extract-condition returns a condition of condition type condition-type with the field values specified by condition.
If condition is a compound condition, extract-condition extracts the field values from the subcondition belonging to condition-type that appeared first in the call to make-compound-condition that created the the condition. The returned condition may be newly created
(srfi 35) syntax (define-condition-type () ((_ condition-type supertype predicate field-spec ...)) )
(field accessor)
supertype ⟹ condition-type?
This defines a new condition type. <Condition-type>, <supertypes>, and <predicate> must all be identifiers. Define-condition-type defines an identifier <condition-type> to some value describing the condition type. <supertype> must be the name of a previously defined condition type.
Define-condition-type also defines <predicate> to a predicate that identifies conditions associated with that type, or with any of its subtypes.
Each <field-spec> must be of the form ( <field> <accessor>) where both <field> and <accessor> must be identifiers. Define-condition-type defines each <accessor> to a procedure which extracts the value of the named field from a condition associated with this condition type.
(srfi 35) syntax (condition () ((_ type-field-binding ...) condition? ) )
(condition-type field-binding)
(field exp)
condition-type ⟹ condition-type?
This creates a condition value. Each <type-field-binding> must be of the form ( <condition-type> <field-binding> ...) Each <field-binding> must be of the form ( <field> <exp>) where <field> is a field identifier from the definition of <condition-type>.
The <exp> are evaluated in some unspecified order; their values can later be extracted from the condition object via the accessors of the associated condition types or their supertypes.
The condition returned by condition is created by a call of form
(make-compound-condition
(make-condition <condition-type> '<field-name> <value>...)
...)
with the condition types retaining their order from thecondition form. The field names and values are duplicated as necessary as described below.
Each <type-field-binding> must contain field bindings for all fields of <condition-type> without duplicates. There is an exception to this rule: if a field binding is missing, and the field belongs to a supertype shared with one of the other <type-field-binding> subforms, then the value defaults to that of the first such binding in the condition form.
&condition ⟹ condition-type?
This is the root of the entire condition type hierarchy. It has a no fields.
&message ⟹ condition-type?
(srfi 35) procedure (message-condition? obj ) ⟹ boolean?
(srfi 35) procedure (condition-message (condition message-condition?) ) ⟹ *
This condition type could be defined by
(define-condition-type &message &condition
message-condition?
(message condition-message))
It carries a message further describing the nature of the condition to humans.
&serious ⟹ condition-type?
(srfi 35) procedure (serious-condition? obj ) ⟹ boolean?
This condition type could be defined by
(define-condition-type &serious &condition
serious-condition?)
This type describes conditions serious enough that they cannot safely be ignored. This condition type is primarily intended as a supertype of other condition types.
&error ⟹ condition-type?
(srfi 35) procedure (error? obj ) ⟹ boolean?
This condition type could be defined by
(define-condition-type &error &serious
error?)
This condition describes errors, typically caused by something that has gone wrong in the interaction of the program with the external world or the user.
library (srfi 36)
&i/o-error ⟹ condition-type?
(srfi 36) procedure (i/o-error? obj ) ⟹ boolean?
(define-condition-type &i/o-error &error
i/o-error?)
This is a supertype for a set of more specific I/O errors.
&i/o-port-error ⟹ condition-type?
(srfi 36) procedure (i/o-port-error? obj ) ⟹ boolean?
(srfi 36) procedure (i/o-error-port (err i/o-port-error?) ) ⟹ port?
(define-condition-type &i/o-port-error &i/o-error
i/o-port-error?
(port i/o-error-port))
This condition type specifies an I/O error that occurred during an operation on a port. Condition objects belonging to this type must specify a port in the port field.
&i/o-read-error ⟹ condition-type?
(srfi 36) procedure (i/o-read-error? obj ) ⟹ boolean?
(define-condition-type &i/o-read-error &i/o-port-error
i/o-read-error?)
This condition type specifies a read error that occurred during an operation on a port.
&i/o-write-error ⟹ condition-type?
(srfi 36) procedure (i/o-write-error? obj ) ⟹ boolean?
(define-condition-type &i/o-write-error &i/o-port-error
i/o-write-error?)
This condition type specifies a write error that occurred during an operation on a port.
&i/o-closed-error ⟹ condition-type?
(srfi 36) procedure (i/o-closed-error? obj ) ⟹ boolean?
(define-condition-type &i/o-closed-error &i/o-port-error
i/o-closed-error?)
A condition of this type specifies that an operation tried to operate on a closed port under the assumption that it is open.
&i/o-filename-error ⟹ condition-type?
(srfi 36) procedure (i/o-filename-error? obj ) ⟹ boolean?
(srfi 36) procedure (i/o-error-filename (err i/o-filename-error?) ) ⟹ string?
(define-condition-type &i/o-filename-error &i/o-error
i/o-filename-error?
(filename i/o-error-filename))
This condition type specifies an I/O error that occurred during an operation on a named file. Condition objects belonging to this type must specify a file name in the filename field.
&i/o-malformed-filename-error ⟹ condition-type?
(srfi 36) procedure (i/o-malformed-filename-error? obj ) ⟹ boolean?
(define-condition-type &i/o-malformed-filename-error &i/o-filename-error
i/o-malformed-filename-error?)
This condition type indicates that a file name had an invalid format.
&i/o-file-protection-error ⟹ condition-type?
(srfi 36) procedure (i/o-file-protection-error? obj ) ⟹ boolean?
(define-condition-type &i/o-file-protection-error &i/o-filename-error
i/o-file-protection-error?)
A condition of this type specifies that an operation tried to operate on a named file with insufficient access rights.
&i/o-file-is-read-only-error ⟹ condition-type?
(srfi 36) procedure (i/o-file-is-read-only-error? obj ) ⟹ boolean?
(define-condition-type &i/o-file-is-read-only-error &i/o-file-protection-error
i/o-file-is-read-only-error?)
A condition of this type specifies that an operation tried to operate on a named read-only file under the assumption that it is writeable.
&i/o-file-already-exists-error ⟹ condition-type?
(srfi 36) procedure (i/o-file-already-exists-error? obj ) ⟹ boolean?
(define-condition-type &i/o-file-already-exists-error &i/o-filename-error
i/o-file-already-exists-error?)
A condition of this type specifies that an operation tried to operate on an existing named file under the assumption that it does not exist.
&i/o-no-such-file-error ⟹ condition-type?
(srfi 36) procedure (i/o-no-such-file-error? obj ) ⟹ boolean?
(define-condition-type &i/o-no-such-file-error &i/o-filename-error
i/o-no-such-file-error?)
A condition of this type specifies that an operation tried to operate on an non-existent named file under the assumption that it exists.
&read-error ⟹ condition-type?
(srfi 36) procedure (read-error? obj ) ⟹ boolean?
(srfi 36) procedure (read-error-line (err read-error?) ) ⟹ integer? / #f /
(srfi 36) procedure (read-error-column (err read-error?) ) ⟹ integer? / #f /
(srfi 36) procedure (read-error-position (err read-error?) ) ⟹ integer? / #f /
(srfi 36) procedure (read-error-span (err read-error?) ) ⟹ integer? / #f /
(define-condition-type &read-error &error
read-error?
(line read-error-line)
(column read-error-column)
(position read-error-position)
(span read-error-span))
A condition of this type specifies that a parse error happened during a read operation. The fields give more information about the nature of the error. However, a Scheme implementation is not obliged to actually provide any information in any of the fields: each field value may be #f in that case.
The field values that are not #f must contain the following kinds of information:
library (srfi 37)
(srfi 37) procedure (option (names list?) (required-arg? boolean?) (optional-arg? boolean?) (option-proc procedure?) ) ⟹ option
(option-proc (option option) (name (or char?string?)) (arg string?) seed ... ) ⟹ (values *...)
Return an option. NAMES is a list of short (character) and long (string) option names. REQUIRED-ARG? specifies if this options requires an option-argument (boolean). OPTIONAL-ARG? specifies if this option can accept an option-argument (boolean). OPTION-PROC is a procedure (following the option-processor prototype) used to process this option.
(srfi 37) procedure (option-names (option option) ) ⟹ list?
(srfi 37) procedure (option-required-arg? (option option) ) ⟹ boolean?
(srfi 37) procedure (option-optional-arg? (option option) ) ⟹ boolean?
(srfi 37) procedure (option-processor (option option) ) ⟹ procedure?
(return (option option) (name (or char?string?)) (arg string?) seed ... ) ⟹ (values *...)
Return the contents of corresponding fields of OPTION.
(srfi 37) procedure (args-fold (args list?) (options list?) (unrecognized-option-proc procedure?) (operand-proc procedure?) seed ... ) ⟹ (values *...)
(unrecognized-option-proc (option option) (name (or char?string?)) (arg string?) seed ... ) ⟹ (values *...)
(operand-proc (operand string?) seed ... ) ⟹ (values *...)
Parse argument strings left-to-right, calling the appropriate processors in-order (for the parsed known options, unknown options, and operands), passing the seed values from one processor to the next and returning the final seeds values as results. ARGS is a list of strings. OPTIONS is a list of options. UNRECOGNIZED-OPTION-PROC is a procedure (following the option-processor prototype) for unrecognized options. NOTE: args-fold will create temporary options as necessary for the UNRECOGNIZED-OPTION-PROC. OPERAND-PROC is a procedure (following the operand-processor prototype) for operands.
library (srfi 38)
library (srfi 39)
(srfi 39) procedure (make-parameter obj ) ⟹ procedure?
(srfi 39) 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.
(srfi 39) 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 (srfi 41)
stream-null ⟹ stream-null?
Stream-null is a promise that, when forced, is a single object, distinguishable from all other objects, that represents the null stream. Stream-null is immutable and unique.
(srfi 41) syntax (stream-cons () ((_ obj stream) stream-pair? ) )
stream ⟹ stream?
Stream-cons is a macro that accepts an object and a stream and creates a newly-allocated stream containing a promise that, when forced, is a stream-pair with the object in its stream-car and the stream in its stream-cdr. Stream-cons must be syntactic, not procedural, because neither object nor stream is evaluated when stream-cons is called. Since stream is not evaluated, when the stream-pair is created, it is not an error to call stream-cons with a stream that is not of type stream; however, doing so will cause an error later when the stream-cdr of the stream-pair is accessed. Once created, a stream-pair is immutable; there is no stream-set-car! or stream-set-cdr! that modifies an existing stream-pair. There is no dotted-pair or improper stream as with lists.
(srfi 41) procedure (stream? obj ) ⟹ boolean?
Stream? is a procedure that takes an object and returns #t if the object is a stream and #f otherwise. If object is a stream, stream? does not force its promise. If (stream? obj) is #t, then one of (stream-null? obj) and (stream-pair? obj) will be #t and the other will be #f; if (stream? obj) is #f, both (stream-null? obj) and (stream-pair? obj) will be #f.
(srfi 41) procedure (stream-null? obj ) ⟹ boolean?
Stream-null? is a procedure that takes an object and returns #t if the object is the distinguished null stream and #f otherwise. If object is a stream, stream-null? must force its promise in order to distinguish stream-null from stream-pair.
(srfi 41) procedure (stream-pair? obj ) ⟹ boolean?
Stream-pair? is a procedure that takes an object and returns #t if the object is a stream-pair constructed by stream-cons and #f otherwise. If object is a stream, stream-pair? must force its promise in order to distinguish stream-null from stream-pair.
(srfi 41) procedure (stream-car (stream stream-pair?) ) ⟹ *
Stream-car is a procedure that takes a stream and returns the object stored in the stream-car of the stream. Stream-car signals an error if the object passed to it is not a stream-pair. Calling stream-car causes the object stored there to be evaluated if it has not yet been; the object’s value is cached in case it is needed again.
(srfi 41) procedure (stream-cdr (stream stream-pair?) ) ⟹ stream?
Stream-car is a procedure that takes a stream and returns the object stored in the stream-car of the stream. Stream-car signals an error if the object passed to it is not a stream-pair. Calling stream-car causes the object stored there to be evaluated if it has not yet been; the object’s value is cached in case it is needed again.
(srfi 41) syntax (stream-lambda () ((_ formals body) procedure? ) )
(variable1 ...) variable (variable1 ... variable_n . variable_n+1)
Stream-lambda creates a procedure that returns a promise to evaluate the body of the procedure. The last body expression to be evaluated must yield a stream. As with normal lambda, args may be a single variable name, in which case all the formal arguments are collected into a single list, or a list of variable names, which may be null if there are no arguments, proper if there are an exact number of arguments, or dotted if a fixed number of arguments is to be followed by zero or more arguments collected into a list. Body must contain at least one expression, and may contain internal definitions preceding any expressions to be evaluated.
(srfi 41) syntax (define-stream () ((_ (variable parameter1 ...) body)) ((_ (variable parameter1 ... . parameter) body)) )
Define-stream creates a procedure that returns a stream, and may appear anywhere a normal define may appear, including as an internal definition, and may have internal definitions of its own, including other define-streams. The defined procedure takes arguments in the same way as stream-lambda. Define-stream is syntactic sugar on stream-lambda; see also stream-let, which is also a sugaring of stream-lambda.
(srfi 41) procedure (list->stream (list-of-objects list?) ) ⟹ stream?
[α] → {α}
List->stream takes a list of objects and returns a newly-allocated stream containing in its elements the objects in the list. Since the objects are given in a list, they are evaluated when list->stream is called, before the stream is created. If the list of objects is null, as in (list->stream '()), the null stream is returned. See also stream.
(srfi 41) procedure (port->stream ) ⟹ stream?
(srfi 41) procedure (port->stream (port input-port?) ) ⟹ stream?
port → {char}
Port->stream takes a port and returns a newly-allocated stream containing in its elements the characters on the port. If port is not given it defaults to the current input port. The returned stream has finite length and is terminated by stream-null.
(srfi 41) syntax (stream () ((_ object ...) stream? ) )
Stream is syntax that takes zero or more objects and creates a newly-allocated stream containing in its elements the objects, in order. Since stream is syntactic, the objects are evaluated when they are accessed, not when the stream is created. If no objects are given, as in (stream), the null stream is returned. See also list->stream.
(srfi 41) procedure (stream->list (stream stream?) ) ⟹ list?
(srfi 41) procedure (stream->list (n integer?) (stream stream?) ) ⟹ list?
nat × {α} → [α]
Stream->list takes a natural number n and a stream and returns a newly-allocated list containing in its elements the first n items in the stream. If the stream has less than n items all the items in the stream will be included in the returned list. If n is not given it defaults to infinity, which means that unless stream is finite stream->list will never return.
(srfi 41) procedure (stream-append (stream stream?) ... ) ⟹ stream?
{α} ... → {α}
Stream-append returns a newly-allocated stream containing in its elements those elements contained in its input streams, in order of input. If any of the input streams is infinite, no elements of any of the succeeding input streams will appear in the output stream; thus, if x is infinite, (stream-append x y) ≡ x. See also stream-concat.
(srfi 41) procedure (stream-concat (stream-of-streams stream?) ) ⟹ stream?
{{α}} ... → {α}
Stream-concat takes a stream consisting of one or more streams and returns a newly-allocated stream containing all the elements of the input streams. If any of the streams in the input stream is infinite, any remaining streams in the input stream will never appear in the output stream. See also stream-append.
(srfi 41) procedure (stream-constant object ... ) ⟹ stream?
α ... → {α}
Stream-constant takes one or more objects and returns a newly-allocated stream containing in its elements the objects, repeating the objects in succession forever.
(srfi 41) procedure (stream-drop (n integer?) (stream stream?) ) ⟹ stream?
nat × {α} → {α}
Stream-drop returns the suffix of the input stream that starts at the next element after the first n elements. The output stream shares structure with the input stream; thus, promises forced in one instance of the stream are also forced in the other instance of the stream. If the input stream has less than n elements, stream-drop returns the null stream. See also stream-take.
(srfi 41) procedure (stream-drop-while (pred? procedure?) (stream stream?) ) ⟹ stream?
(pred? obj ) ⟹ boolean?
(α → boolean) × {α} → {α}
Stream-drop-while returns the suffix of the input stream that starts at the first element x for which (pred? x) is #f. The output stream shares structure with the input stream. See also stream-take-while.
(srfi 41) procedure (stream-filter (pred? procedure?) (stream stream?) ) ⟹ stream?
(pred? obj ) ⟹ boolean?
(α → boolean) × {α} → {α}
Stream-filter returns a newly-allocated stream that contains only those elements x of the input stream for which (pred? x) is non-#f.
(srfi 41) procedure (stream-fold (proc procedure?) base (stream stream?) ) ⟹ *
(proc base element ) ⟹ *
(α × β → α) × α × {β} → α
Stream-fold applies a binary procedure to base and the first element of stream to compute a new base, then applies the procedure to the new base and the next element of stream to compute a succeeding base, and so on, accumulating a value that is finally returned as the value of stream-fold when the end of the stream is reached. Stream must be finite, or stream-fold will enter an infinite loop. See also stream-scan, which is similar to stream-fold, but useful for infinite streams. For readers familiar with other functional languages, this is a left-fold; there is no corresponding right-fold, since right-fold relies on finite streams that are fully-evaluated, at which time they may as well be converted to a list.
(srfi 41) procedure (stream-for-each (proc procedure?) (stream1 stream?) ... ) ⟹ undefined
(proc element1 ... ) ⟹ undefined
(α × β × ...) × {α} × {β} ...
Stream-for-each applies a procedure element-wise to corresponding elements of the input streams for its side-effects; it returns nothing. Stream-for-each stops as soon as any of its input streams is exhausted.
(srfi 41) procedure (stream-from (from number?) ) ⟹ stream?
(srfi 41) procedure (stream-from (from number?) (step number?) ) ⟹ stream?
number × number → {number}
Stream-from creates a newly-allocated stream that contains first as its first element and increments each succeeding element by step. If step is not given it defaults to 1. First and step may be of any numeric type. Stream-from is frequently useful as a generator in stream-of expressions. See also stream-range for a similar procedure that creates finite streams.
(srfi 41) procedure (stream-iterate (proc procedure?) base ) ⟹ stream?
(proc element ) ⟹ *
(α → α) × α → {α}
Stream-iterate creates a newly-allocated stream containing base in its first element and applies proc to each element in turn to determine the succeeding element. See also stream-unfold and stream-unfolds.
(srfi 41) procedure (stream-length (stream stream?) ) ⟹ integer?
{α} → nat
Stream-length takes an input stream and returns the number of elements in the stream; it does not evaluate its elements. Stream-length may only be used on finite streams; it enters an infinite loop with infinite streams.
(srfi 41) syntax (stream-let () ((_ tag ((var expr) ...) body)) )
Stream-let creates a local scope that binds each variable to the value of its corresponding expression. It additionally binds tag to a procedure which takes the bound variables as arguments and body as its defining expressions, binding the tag with stream-lambda. Tag is in scope within body, and may be called recursively. When the expanded expression defined by the stream-let is evaluated, stream-let evaluates the expressions in its body in an environment containing the newly-bound variables, returning the value of the last expression evaluated, which must yield a stream.
Stream-let provides syntactic sugar on stream-lambda, in the same manner as normal let provides syntactic sugar on normal lambda. However, unlike normal let, the tag is required, not optional, because unnamed stream-let is meaningless.
(srfi 41) procedure (stream-map (proc procedure?) (stream1 stream?) ... ) ⟹ stream?
(proc element1 ... ) ⟹ *
(α × β ... → ω) × {α} × {β} ... → {ω}
Stream-map applies a procedure element-wise to corresponding elements of the input streams, returning a newly-allocated stream containing elements that are the results of those procedure applications. The output stream has as many elements as the minimum-length input stream, and may be infinite.
(srfi 41) syntax (stream-match (_ ) ((_ stream clause ...)) )
() (pat0 pat1 ...) (pat0 pat1 ... . pat_rest) pat
identifier _
stream ⟹ stream?
Stream-match provides the syntax of pattern-matching for streams. The input stream is an expression that evaluates to a stream. Clauses are of the form (pattern [fender] expr), consisting of a pattern that matches a stream of a particular shape, an optional fender that must succeed if the pattern is to match, and an expression that is evaluated if the pattern matches. There are four types of patterns:
* () — Matches the null stream.
* (pat0 pat1 ...) — Matches a finite stream with length exactly equal to the number of pattern elements.
* (pat0 pat1 ... . patrest) — Matches an infinite stream, or a finite stream with length at least as great as the number of pattern elements before the literal dot.
* pat — Matches an entire stream. Should always appear last in the list of clauses; it’s not an error to appear elsewhere, but subsequent clauses could never match.
Each pattern element pati may be either:
* An identifier — Matches any stream element. Additionally, the value of the stream element is bound to the variable named by the identifier, which is in scope in the fender and expression of the corresponding clause. Each identifier in a single pattern must be unique.
* A literal underscore — Matches any stream element, but creates no bindings.
The patterns are tested in order, left-to-right, until a matching pattern is found; if fender is present, it must evaluate as non-#f for the match to be successful. Pattern variables are bound in the corresponding fender and expression. Once the matching pattern is found, the corresponding expression is evaluated and returned as the result of the match. An error is signaled if no pattern matches the input stream.
(srfi 41) syntax (stream-of (in is ) ((_ expr clause ...) stream? ) )
(var in stream-expr) (var is expr) (pred? expr)
Stream-of provides the syntax of stream comprehensions, which generate streams by means of looping expressions. The result is a stream of objects of the type returned by expr. There are four types of clauses:
* (var in stream-expr) — Loop over the elements of stream-expr, in order from the start of the stream, binding each element of the stream in turn to var. Stream-from and stream-range are frequently useful as generators for stream-expr.
* (var is expr) — Bind var to the value obtained by evaluating expr.
* (pred? expr) — Include in the output stream only those elements x for which (pred? x) is non-#f.
The scope of variables bound in the stream comprehension is the clauses to the right of the binding clause (but not the binding clause itself) plus the result expression.
When two or more generators are present, the loops are processed as if they are nested from left to right; that is, the rightmost generator varies fastest. A consequence of this is that only the first generator may be infinite and all subsequent generators must be finite. If no generators are present, the result of a stream comprehension is a stream containing the result expression; thus, (stream-of 1) produces a finite stream containing only the element 1.
(srfi 41) procedure (stream-range (first real?) (past real?) ) ⟹ stream?
(srfi 41) procedure (stream-range (first real?) (past real?) (step real?) ) ⟹ stream?
number × number × number → {number}
Stream-range creates a newly-allocated stream that contains first as its first element and increments each succeeding element by step. The stream is finite and ends before past, which is not an element of the stream. If step is not given it defaults to 1 if first is less than past and -1 otherwise. First, past and step may be of any numeric type. Stream-range is frequently useful as a generator in stream-of expressions. See also stream-from for a similar procedure that creates infinite streams.
Successive elements of the stream are calculated by adding step to first, so if any of first, past or step are inexact, the length of the output stream may differ from (ceiling (- (/ (- past first) step) 1).
(srfi 41) procedure (stream-ref (stream stream?) (n integer?) ) ⟹ *
{α} × nat → α
Stream-ref returns the nth element of stream, counting from zero. An error is signaled if n is greater than or equal to the length of stream.
(srfi 41) procedure (stream-reverse (stream stream?) ) ⟹ stream?
{α} → {α}
Stream-reverse returns a newly-allocated stream containing the elements of the input stream but in reverse order. Stream-reverse may only be used with finite streams; it enters an infinite loop with infinite streams. Stream-reverse does not force evaluation of the elements of the stream.
(srfi 41) procedure (stream-scan (proc procedure?) base (stream stream?) ) ⟹ stream?
(proc base element ) ⟹ *
(α × β → α) × α × {β} → {α}
Stream-scan accumulates the partial folds of an input stream into a newly-allocated output stream. The output stream is the base followed by (stream-fold proc base (stream-take i stream)) for each of the first i elements of stream.
(srfi 41) procedure (stream-take (n integer?) (stream stream?) ) ⟹ stream?
nat × {α} → {α}
Stream-take takes a non-negative integer n and a stream and returns a newly-allocated stream containing the first n elements of the input stream. If the input stream has less than n elements, so does the output stream. See also stream-drop.
(srfi 41) procedure (stream-take-while (pred? procedure?) (stream stream?) ) ⟹ stream?
(pred? obj ) ⟹ boolean?
(α → boolean) × {α} → {α}
Stream-take-while takes a predicate and a stream and returns a newly-allocated stream containing those elements x that form the maximal prefix of the input stream for which (pred? x) is non-#f. See also stream-drop-while.
(srfi 41) procedure (stream-unfold (map procedure?) (pred? procedure?) (gen procedure?) base ) ⟹ stream?
(map base ) ⟹ *
(pred? base ) ⟹ boolean?
(gen base ) ⟹ *
(α → β) × (α → boolean) × (α → α) × α → {β}
Stream-unfold is the fundamental recursive stream constructor. It constructs a stream by repeatedly applying gen to successive values of base, in the manner of stream-iterate, then applying map to each of the values so generated, appending each of the mapped values to the output stream as long as (pred? base) is non-#f. See also stream-iterate and stream-unfolds.
(srfi 41) procedure (stream-unfolds (proc procedure?) seed ) ⟹ (values stream?...)
(proc seed ) ⟹ (values list? / #f / *...)
(α → (values α × β ...)) × α → (values {β} ...)
Stream-unfolds returns n newly-allocated streams containing those elements produced by successive calls to the generator proc, which takes the current seed as its argument and returns n+1 values
(proc seed → seed result0 ... resultn-1
where the returned seed is the input seed to the next call to the generator and resulti indicates how to produce the next element of the ith result stream:
* (value) — value is the next car of the result stream
* #f — no value produced by this iteration of the generator proc for the result stream
* () — the end of the result stream
It may require multiple calls of proc to produce the next element of any particular result stream. See also stream-iterate and stream-unfold.
(srfi 41) procedure (stream-zip (stream stream?) ... ) ⟹ stream?
{α} × {β} × ... → {[α β ...]}
Stream-zip takes one or more input streams and returns a newly-allocated stream in which each element is a list (not a stream) of the corresponding elements of the input streams. The output stream is as long as the shortest input stream, if any of the input streams is finite, or is infinite if all the input streams are infinite.
A common use of stream-zip is to add an index to a stream, as in (stream-finds eql? obj strm), which returns all the zero-based indices in strm at which obj appears; (stream-find eql? obj strm) returns the first such index, or #f if obj is not in strm.
library (srfi 42)
(srfi 42) syntax (do-ec (if not and or begin nested ) ((_ qualifier ... command)) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
Evaluates the <command> exactly once for each binding in the sequence defined by the qualifiers. If there are no qualifiers <command> is evaluated exactly once. The expression is evaluated for its side-effects only. The result of the comprehension is unspecified.
(srfi 42) syntax (list-ec (if not and or begin nested ) ((_ qualifier ... expression) list? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
The list of values obtained by evaluating <expression> once for each binding in the sequence defined by the qualifiers. If there are no qualifiers the result is the list with the value of <expression>.
(srfi 42) syntax (append-ec (if not and or begin nested ) ((_ qualifier ... expression) list? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
expression ⟹ list?
The list obtained by appending all values of <expression>, which must all be lists. Think of it as (apply append (list-ec <qualifier>* <expression>)).
(srfi 42) syntax (string-ec (if not and or begin nested ) ((_ qualifier ... expression) string? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
expression ⟹ char?
The string of all values of <expression>. Think of it as (list->string (list-ec <qualifier>* <expression>)).
(srfi 42) syntax (string-append-ec (if not and or begin nested ) ((_ qualifier ... expression) string? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
expression ⟹ string?
The string obtained by appending all values of <expression>, which must all be strings. Think of it as (apply string-append (list-ec <qualifier>* <expression>)).
(srfi 42) syntax (vector-ec (if not and or begin nested ) ((_ qualifier ... expression) vector? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
The vector of all values of <expression>. Think of it as (list->vector (list-ec <qualifier>* <expression>)).
(srfi 42) syntax (vector-of-length-ec (if not and or begin nested ) ((_ k qualifier ... expression) vector? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
k ⟹ integer?
The vector of all values of <expression>, of which there must be exactly <k>. This comprehension behaves like vector-ec but can be implemented more efficiently.
(srfi 42) syntax (sum-ec (if not and or begin nested ) ((_ qualifier ... expression) number? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
expression ⟹ number?
The sum of all values of <expression>. Think of it as (apply + (list-ec <qualifier>* <expression>)).
(srfi 42) syntax (product-ec (if not and or begin nested ) ((_ qualifier ... expression) number? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
expression ⟹ number?
The product of all values of <expression>. Think of it as (apply * (list-ec <qualifier>* <expression>)).
(srfi 42) syntax (min-ec (if not and or begin nested ) ((_ qualifier ... expression) number? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
expression ⟹ number?
The minimum of all values of <expression>.
(srfi 42) syntax (max-ec (if not and or begin nested ) ((_ qualifier ... expression) number? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
expression ⟹ number?
The maximum of all values of <expression>.
(srfi 42) syntax (any?-ec (if not and or begin nested ) ((_ qualifier ... test) boolean? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
Tests whether any value of <test> in the sequence of bindings specified by the qualifiers is non-#f. If this is the case, #t is returned, otherwise #f. If there are no bindings in the sequence specified by the qualifiers at all then the result is #f. The enumeration of values stops after the first non-#f encountered.
(srfi 42) syntax (every?-ec (if not and or begin nested ) ((_ qualifier ... test) boolean? ) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
Tests whether all values of <test> are non-#f. If this is the case, #t is returned, otherwise #f. If the sequence is empty the result is #t. Enumeration stops after the first #f.
(srfi 42) syntax (first-ec (if not and or begin nested ) ((_ default qualifier ... expression)) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
The first value of <expression> in the sequence of bindings specified by the qualifiers. Before enumeration, the result is initialized with the value of <default>; so this will be the result if the sequence is empty. Enumeration is terminated in first-ec when the first value has been computed.
(srfi 42) syntax (last-ec (if not and or begin nested ) ((_ default qualifier ... expression)) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
The last value of <expression> in the sequence of bindings specified by the qualifiers. Before enumeration, the result is initialized with the value of <default>; so this will be the result if the sequence is empty.
(srfi 42) syntax (fold-ec (if not and or begin nested ) ((_ x0 qualifier ... expression f2)) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
f2 ⟹ procedure?
Reduces the sequence x[0], x[1], ..., x[n-1] of values obtained by evaluating <expression> once for each binding as specified by <qualifier>*. The arguments <x0>, <f2>, and <f1>, all syntactically equivalent to <expression>, specify the reduction process.
The reduction process for fold-ec is defined as follows. A reduction variable x is initialized to the value of <x0>, and for each k in {0, ..., n-1} the command (set! x (<f2> x[k] x)) is evaluated. Finally, x is returned as the value of the comprehension.
As the order of the arguments suggests, <x0> is evaluated outside the scope of the qualifiers, whereas the reduction expressions involving <f1> and <f2> are inside the scope of the qualifiers (so they may depend on any variable introduced by the qualifiers). Note that <f2> is evaluated repeatedly, with any side-effect or overhead this might have.
(srfi 42) syntax (fold3-ec (if not and or begin nested ) ((_ x0 qualifier ... expression f1 f2)) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
generator ⟹ generator-macro
f1 ⟹ procedure?
f2 ⟹ procedure?
Reduces the sequence x[0], x[1], ..., x[n-1] of values obtained by evaluating <expression> once for each binding as specified by <qualifier>*. The arguments <x0>, <f2>, and <f1>, all syntactically equivalent to <expression>, specify the reduction process.
The reduction process for fold3-ec is defined as follows. If and only if n = 0, i.e. the sequence is empty, then <x0> is evaluated and returned as the value of the comprehension. Otherwise, a reduction variable x is initialized to the value of (<f1> x[0]), and for each k in {1, ..., n-1} the command (set! x (<f2> x[k] x)) is evaluated. Finally, x is returned as the value of the comprehension.
As the order of the arguments suggests, <x0> is evaluated outside the scope of the qualifiers, whereas the reduction expressions involving <f1> and <f2> are inside the scope of the qualifiers (so they may depend on any variable introduced by the qualifiers). Note that <f2> is evaluated repeatedly, with any side-effect or overhead this might have.
(srfi 42) syntax (: (index ) ((_ var arg1 arg2 ...) generator-macro ) ((_ var1 (index var2) arg1 arg2 ...) generator-macro ) )
First the expressions <arg1> <arg>* are evaluated into a[1] a[2] ... a[n] and then a global dispatch procedure is used to dispatch on the number and types of the arguments and run the resulting generator.
Initially (after loading the SRFI), the following cases are recognized:
:list if for all i in {1..n}: (list? a[i]).
:string if for all i in {1..n}: (string? a[i]).
:vector if for all i in {1..n}: (vector? a[i]).
:range if n in {1..3} and for all i in {1..n}: (integer? a[i]) and (exact? a[i]).
:real-range if n in {1..3} and for all i in {1..n}: (real? a[i]).
:char-range if n = 2 and for all i in {1, 2}: (char? a[i]).
:port if n in {1,2} and (input-port? a[1]) and (procedure? a[2]).
(srfi 42) procedure (:-dispatch-ref ) ⟹ procedure?
The current dispatcher used by `:`.
(srfi 42) procedure (:-dispatch-set! (d procedure?) ) ⟹ undefined
Install dispatched to be used with `:`.
(srfi 42) procedure (make-initial-:-dispatch ) ⟹ procedure?
Get a copy of initial dispatcher for `:`.
(srfi 42) syntax (:list (index ) ((_ var arg1 arg2 ...) generator-macro ) ((_ var1 (index var2) arg1 arg2 ...) generator-macro ) )
arg1 ⟹ list?
arg2 ⟹ list?
Run through one or more lists. First all expressions in <arg1> <arg>* are evaluated and then all elements of the resulting values are enumerated from left to right.
(srfi 42) syntax (:string (index ) ((_ var arg1 arg2 ...) generator-macro ) ((_ var1 (index var2) arg1 arg2 ...) generator-macro ) )
arg1 ⟹ string?
arg2 ⟹ string?
Run through one or more strings. First all expressions in <arg1> <arg>* are evaluated and then all elements of the resulting values are enumerated from left to right.
(srfi 42) syntax (:vector (index ) ((_ var arg1 arg2 ...) generator-macro ) ((_ var1 (index var2) arg1 arg2 ...) generator-macro ) )
arg1 ⟹ vector?
arg2 ⟹ vector?
Run through one or more vectors. First all expressions in <arg1> <arg>* are evaluated and then all elements of the resulting values are enumerated from left to right.
(srfi 42) syntax (:integers (index ) ((_ var) generator-macro ) ((_ var1 (index var2)) generator-macro ) )
Runs through the sequence 0, 1, 2, ... of non-negative integers. This is most useful in combination with :parallel, :while, and :until or with a non-local exit in the body of the comprehension.
(srfi 42) syntax (:range (index ) ((_ var stop) generator-macro ) ((_ var1 (index var2) stop) generator-macro ) ((_ var start stop) generator-macro ) ((_ var1 (index var2) start stop) generator-macro ) ((_ var start stop step) generator-macro ) ((_ var1 (index var2) start stop step) generator-macro ) )
start ⟹ integer?
stop ⟹ integer?
step ⟹ integer?
Runs through a range of exact rational numbers.
The form (:range <vars> <stop>) evaluates the expression <stop>, which must result in an exact integer n, and runs through the finite sequence 0, 1, 2, ..., n-1. If n is zero or negative the sequence is empty.
The form (:range <vars> <start> <stop>) evaluates the expressions <start> and <stop>, which must result in exact integers a and b, and runs through the finite sequence a, a+1, a+2, ..., b-1. If b is less or equal a then the sequence is empty.
The form (:range <vars> <start> <stop> <step>) first evaluates the expressions <start>, <stop>, and <step>, which must result in exact integers a, b, and s such that s is unequal to zero. Then the sequence a, a + s, a + 2 s, ..., a + (n-1) s is enumerated where n = ceil((b-a)/s). In other words, the sequence starts at a, increments by s, and stops when the next value would reach or cross b. If n is zero or negative the sequence is empty.
(srfi 42) syntax (:real-range (index ) ((_ var stop) generator-macro ) ((_ var1 (index var2) stop) generator-macro ) ((_ var start stop) generator-macro ) ((_ var1 (index var2) start stop) generator-macro ) ((_ var start stop step) generator-macro ) ((_ var1 (index var2) start stop step) generator-macro ) )
start ⟹ real?
stop ⟹ real?
step ⟹ real?
Runs through a range of real numbers using an explicit index variable. This form of range enumeration avoids accumulation of rounding errors and is the one to use if any of the numbers defining the range is inexact, not an integer, or a bignum of large magnitude.
Providing default value 0 for <start> and 1 for <step>, the generator first evaluates <start>, <stop>, and <step>, which must result in reals a, b, and s such that n = (b-a)/s is also representable as a real. Then the sequence 0, 1, 2, ... is enumerated while the current value i is less than n, and the variable in <vars> is bound to the value a + i s. If any of the values a, b, or s is non-exact then all values in the sequence are non-exact.
(srfi 42) syntax (:char-range (index ) ((_ var min max) generator-macro ) ((_ var1 (index var2) min max) generator-macro ) )
min ⟹ char?
max ⟹ char?
Runs through a range of characters. First <min> and <max> are evaluated, which must result in two characters a and b. Then the sequence of characters a, a+1, a+2, ..., b is enumerated in the order defined by char<=? in the sense of [R5RS, 6.3.4.]. If b is smaller than a then the sequence is empty. (Note that b is included in the sequence.)
(srfi 42) syntax (:port (index ) ((_ var port) generator-macro ) ((_ var1 (index var2) port) generator-macro ) ((_ var port read-proc) generator-macro ) ((_ var1 (index var2) port read-proc) generator-macro ) )
port ⟹ input-port?
read-proc ⟹ procedure?
Reads from the port until the eof-object is read. Providing the default read for <read-proc>, the generator first evaluates <port> and <read-proc>, which must result in an input port p and a procedure r. Then the variable is run through the sequence obtained by (r p) while the result does not satisfy eof-object?.
(srfi 42) syntax (:dispatched (index ) ((_ var dispatch arg1 arg2 ...) generator-macro ) ((_ var1 (index var2) dispatch arg1 arg2 ...) generator-macro ) )
dispatch ⟹ procedure?
Runs the variables through a sequence defined by <dispatch> and <arg1> <arg>*. The purpose of :dispatched is implementing dispatched generators, in particular the predefined dispatching generator :.
The working of :dispatched is as follows. First <dispatch> and <arg1> <arg>* are evaluated, resulting in a procedure d (the 'dispatcher') and the values a[1] a[2] ... a[n]. Then (d (list a[1] a[2] ... a[n] )) is evaluated, resulting in a value g. If g is not a procedure then the dispatcher did not recognize the argument list and an error is raised. Otherwise the 'generator procedure' g is used to run <vars> through a sequence of values. The sequence defined by g is obtained by repeated evaluation of (g empty) until the result is empty. In other words, g indicates the end of the sequence by returning its only argument, for which the caller has provided an object distinct from anything g can produce.
(srfi 42) syntax (:generator-proc () ((_ generator-macro) procedure? ) )
Constructs a generator procedure from a typed generator. Let (g var arg1 arg ...) be an instance of the <generator> syntax, for example an application-specific typed generator, with a single variable var and no index variable. Then
(:generator-proc (g arg1 arg ...)) => g
where the generator procedure g runs through the list (list-ec (g var arg1 arg ...) var).
(srfi 42) procedure (dispatch-union (d1 procedure?) (d2 procedure?) ) ⟹ procedure?
The new dispatcher d recognizes the union of the cases recognized by the dispatchers d1 and d2. The new dispatcher always tries both component dispatchers and raises an error in case of conflict. The identification returned by (d) is the concatenation of the component identifications (d1) and (d2), enclosed in lists if necessary.
(srfi 42) syntax (:do (let ) ((_ (lb ...) ne1? (ls ...)) generator-macro ) ((_ (let (ob ...) oc ...) (lb ...) ne1? (let (ib ...) ic ...) ne2? (ls ...))) )
Defines a generator in terms of a named-let, optionally decorated with inner and outer lets. This generator is for defining other generators. (In fact, the reference implementation transforms any other generator into an instance of fully decorated :do.) The generator is a compromise between expressive power (more flexible loops) and fixed structure (necessary for merging and modifying generators). In the fully decorated form, the syntactic variables <ob> (outer binding), <oc> (outer command), <lb> (loop binding), <ne1?> (not-end1?), <ib> (inner binding), <ic> (inner command), <ne2?> (not-end2?), and <ls> (loop step) define the following loop skeleton:
(let (<ob>*)
<oc>*
(let loop (<lb>*)
(if <ne1?>
(let (<ib>*)
<ic>*
payload
(if <ne2?>
(loop <ls>*)))))),
where <oc>* and <ic>* are syntactically equivalent to <command>*, i.e. they do not begin with a <definition>. The latter requirement allows the code generator to produce more efficient code for special cases by removing empty let-expressions altogether.
(srfi 42) syntax (:let (index ) ((_ var expression) generator-macro ) ((_ var1 (index var2) expression) generator-macro ) )
Runs through the sequence consisting of the value of <expression>, only. This is the same as (:list <vars> (list <expression>)). If an index variable is specified, its value is 0. The :let-generator can be used to introduce an intermediate variable depending on outer generators.
(srfi 42) syntax (:parallel () ((_ generator ...) generator-macro ) )
generator ⟹ generator-macro
Runs several generators in parallel. This means that the next binding in the sequence is obtained by advancing each generator in <generator>* by one step. The parallel generator terminates when any of its component generators terminates. The generators share a common scope for the variables they introduce. This implies that the names of the variables introduced by the various generators must be distinct.
(srfi 42) syntax (:while () ((_ generator expression) generator-macro ) )
generator ⟹ generator-macro
Runs <generator> while <expression> evaluates to non-#f. The guarding expression is included in the scope of the variables introduced by the generator.
Note the distinction between the filter if and the modified generator expressed by :while.
(srfi 42) syntax (:until () ((_ generator expression) generator-macro ) )
generator ⟹ generator-macro
Runs <generator> until after <expression> has evaluated to non-#f. The guarding expression is included in the scope of the variables introduced by the generator.
Note the distinction between :while, stopping at a certain condition, and :until, stopping after a certain condition has occurred. The latter implies that the binding that has triggered termination has been processed by the comprehension.
library (srfi 43)
(srfi 43) procedure (make-vector (k integer?) ) ⟹ vector?
(srfi 43) procedure (make-vector (k integer?) fill ) ⟹ vector?
Creates and returns a vector of size size, optionally filling it with fill. The default value of fill is unspecified.
(srfi 43) procedure (vector x ... ) ⟹ vector?
Creates and returns a vector whose elements are x ...
(srfi 43) procedure (vector-unfold (f procedure?) (length integer?) initial-seed ... ) ⟹ vector?
(f (index integer?) seed ... ) ⟹ (values **...)
The fundamental vector constructor. Creates a vector whose length is length and iterates across each index k between 0 and length, applying f at each iteration to the current index and current seeds, in that order, to receive n + 1 values: first, the element to put in the kth slot of the new vector and n new seeds for the next iteration. It is an error for the number of seeds to vary between iterations.
(srfi 43) procedure (vector-unfold-right (f procedure?) (length integer?) initial-seed ... ) ⟹ vector?
(f (index integer?) seed ... ) ⟹ (values **...)
Like vector-unfold, but it uses f to generate elements from right-to-left, rather than left-to-right.
(srfi 43) procedure (vector-copy (vec vector?) ) ⟹ vector?
(srfi 43) procedure (vector-copy (vec vector?) (start integer?) ) ⟹ vector?
(srfi 43) procedure (vector-copy (vec vector?) (start integer?) (end integer?) ) ⟹ vector?
(srfi 43) procedure (vector-copy (vec vector?) (start integer?) (end integer?) fill ) ⟹ vector?
Allocates a new vector whose length is end - start and fills it with elements from vec, taking elements from vec starting at index start and stopping at index end. start defaults to 0 and end defaults to the value of (vector-length vec). If end extends beyond the length of vec, the slots in the new vector that obviously cannot be filled by elements from vec are filled with fill, whose default value is unspecified.
(srfi 43) procedure (vector-reverse-copy (vec vector?) ) ⟹ vector?
(srfi 43) procedure (vector-reverse-copy (vec vector?) (start integer?) ) ⟹ vector?
(srfi 43) procedure (vector-reverse-copy (vec vector?) (start integer?) (end integer?) ) ⟹ vector?
Like vector-copy, but it copies the elements in the reverse order from vec.
(srfi 43) procedure (vector-append (vec vector?) ... ) ⟹ vector?
Returns a newly allocated vector that contains all elements in order from the subsequent locations in vec ...
(srfi 43) procedure (vector-concatenate (list-of-vectors list?) ... ) ⟹ vector?
list-of-vectors ⟹ (list (v vector?) )
Appends each vector in list-of-vectors. This is equivalent to: (apply vector-append list-of-vectors) however, it may be implemented better.
(srfi 43) procedure (vector? obj ) ⟹ boolean?
Disjoint type predicate for vectors: this returns #t if x is a vector, and #f if otherwise.
(srfi 43) procedure (vector-empty? (vec vector?) ) ⟹ boolean?
Returns #t if vec is empty, i.e. its length is 0, and #f if not.
(srfi 43) procedure (vector= (elt=? procedure?) (vec vector?) ... ) ⟹ boolean?
(elt=? a b ) ⟹ boolean?
Vector structure comparator, generalized across user-specified element comparators. Vectors a and b are considered equal by vector= iff their lengths are the same, and for each respective elements Ea and Eb, (elt=? Ea Eb) returns a true value. Elt=? is always applied to two arguments. Element comparison must be consistent with eq; that is, if (eq? Ea Eb) results in a true value, then (elt=? Ea Eb) must also result in a true value. This may be exploited to avoid unnecessary element comparisons. (The reference implementation does, but it does not consider the situation where elt=? is in fact itself eq? to avoid yet more unnecessary comparisons.)
If there are only zero or one vector arguments, #t is automatically returned. The dynamic order in which comparisons of elements and of vectors are performed is left completely unspecified; do not rely on a particular order.
(srfi 43) procedure (vector-ref (vec vector?) (i integer?) ) ⟹ *
Vector element dereferencing: returns the value that the location in vec at i is mapped to in the store. Indexing is based on zero. I must be within the range [0, (vector-length vec)).
(srfi 43) procedure (vector-length (vec vector?) ) ⟹ integer?
Returns the length of vec, the number of locations reachable from vec. (The careful word 'reachable' is used to allow for 'vector slices,' whereby vec refers to a larger vector that contains more locations that are unreachable from vec. This SRFI does not define vector slices, but later SRFIs may.)
(srfi 43) procedure (vector-fold (kons procedure?) knil (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(kons (index integer?) state obj1 obj2 ... ) ⟹ *
The fundamental vector iterator. Kons is iterated over each index in all of the vectors, stopping at the end of the shortest; kons is applied as (kons i state (vector-ref vec1 i) (vector-ref vec2 i) ···) where state is the current state value — the current state value begins with knil, and becomes whatever kons returned at the respective iteration —, and i is the current index. The iteration is strictly left-to-right.
(srfi 43) procedure (vector-fold-right (kons procedure?) knil (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(kons (index integer?) state obj1 obj2 ... ) ⟹ *
Similar to vector-fold, but it iterates right to left instead of left to right.
(srfi 43) procedure (vector-map (f procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ vector?
(proc (index integer?) obj ... ) ⟹ *
Constructs a new vector of the shortest size of the vector arguments. Each element at index i of the new vector is mapped from the old vectors by (f i (vector-ref vec1 i) (vector-ref vec2 i) ···). The dynamic order of application of f is unspecified.
(srfi 43) procedure (vector-map! (f procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ undefined
(proc (index integer?) obj ... ) ⟹ *
Similar to vector-map, but rather than mapping the new elements into a new vector, the new mapped elements are destructively inserted into vec1. Again, the dynamic order of application of f unspecified, so it is dangerous for f to apply either vector-ref or vector-set! to vec1 in f.
(srfi 43) procedure (vector-for-each (f procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ undefined
(proc (index integer?) obj ... ) ⟹ undefined
Simple vector iterator: applies f to each index in the range [0, length), where length is the length of the smallest vector argument passed, and the respective list of parallel elements from vec1 vec2 ··· at that index. In contrast with vector-map, f is reliably applied to each subsequent elements, starting at index 0, in the vectors.
(srfi 43) procedure (vector-count (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer?
(pred? (index integer?) obj1 obj2 ... ) ⟹ *
Counts the number of parallel elements in the vectors that satisfy pred?, which is applied, for each index i in the range [0, length) — where length is the length of the smallest vector argument —, to i and each parallel element in the vectors at that index, in order.
(srfi 43) procedure (vector-index (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Finds & returns the index of the first elements in vec1 vec2 ... that satisfy pred?. If no matching element is found by the end of the shortest vector, #f is returned.
(srfi 43) procedure (vector-index-right (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Like vector-index, but it searches right-to-left, rather than left-to-right, and all of the vectors must have the same length.
(srfi 43) procedure (vector-skip (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Finds & returns the index of the first elements in vec1 vec2 ... that do not satisfy pred?. If all the values in the vectors satisfy pred? until the end of the shortest vector, this returns #f.
(srfi 43) procedure (vector-skip-right (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Like vector-skip, but it searches for a non-matching element right-to-left, rather than left-to-right, and all of the vectors must have the same length.
(srfi 43) procedure (vector-binary-search (vec vector?) value (cmp procedure?) ) ⟹ integer? / #f /
(cmp a b ) ⟹ integer?
Similar to vector-index and vector-index-right, but instead of searching left to right or right to left, this performs a binary search. cmp should be a procedure of two arguments and return a negative integer, which indicates that its first argument is less than its second, zero, which indicates that they are equal, or a positive integer, which indicates that the first argument is greater than the second argument.
(srfi 43) procedure (vector-any (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(pred? obj1 obj2 ... ) ⟹ *
Finds the first set of elements in parallel from vec1 vec2 ... for which pred? returns a true value. If such a parallel set of elements exists, vector-any returns the value that pred? returned for that set of elements. The iteration is strictly left-to-right.
(srfi 43) procedure (vector-every (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(pred? obj1 obj2 ... ) ⟹ *
If, for every index i between 0 and the length of the shortest vector argument, the set of elements (vector-ref vec1 i) (vector-ref vec2 i) ··· satisfies pred?, vector-every returns the value that pred? returned for the last set of elements, at the last index of the shortest vector. The iteration is strictly left-to-right.
(srfi 43) procedure (vector-set! (vector vector?) (i integer?) obj ) ⟹ undefined
Assigns the contents of the location at i in vec to value.
(srfi 43) procedure (vector-swap! (vector vector?) (i integer?) (j integer?) ) ⟹ undefined
Swaps or exchanges the values of the locations in vec at i & j.
(srfi 43) procedure (vector-fill! (vec vector?) fill ) ⟹ undefined
(srfi 43) procedure (vector-fill! (vec vector?) fill (start integer?) ) ⟹ undefined
(srfi 43) procedure (vector-fill! (vec vector?) fill (start integer?) (end integer?) ) ⟹ undefined
Assigns the value of every location in vec between start, which defaults to 0 and end, which defaults to the length of vec, to fill.
(srfi 43) procedure (vector-reverse! (vec vector?) ) ⟹ undefined
(srfi 43) procedure (vector-reverse! (vec vector?) (start integer?) ) ⟹ undefined
(srfi 43) procedure (vector-reverse! (vec vector?) (start integer?) (end integer?) ) ⟹ undefined
Destructively reverses the contents of the sequence of locations in vec between start and end. Start defaults to 0 and end defaults to the length of vec. Note that this does not deeply reverse.
(srfi 43) procedure (vector-copy! (target vector?) (tstart integer?) (source vector?) ) ⟹ undefined
(srfi 43) procedure (vector-copy! (target vector?) (tstart integer?) (source vector?) (sstart integer?) ) ⟹ undefined
(srfi 43) procedure (vector-copy! (target vector?) (tstart integer?) (source vector?) (sstart integer?) (send integer?) ) ⟹ undefined
Copies a block of elements from source to target, both of which must be vectors, starting in target at tstart and starting in source at sstart, ending when send - sstart elements have been copied. It is an error for target to have a length less than tstart + (send - sstart). Sstart defaults to 0 and send defaults to the length of source.
(srfi 43) procedure (vector-reverse-copy! (target vector?) (tstart integer?) (source vector?) ) ⟹ undefined
(srfi 43) procedure (vector-reverse-copy! (target vector?) (tstart integer?) (source vector?) (sstart integer?) ) ⟹ undefined
(srfi 43) procedure (vector-reverse-copy! (target vector?) (tstart integer?) (source vector?) (sstart integer?) (send integer?) ) ⟹ undefined
Like vector-copy!, but this copies the elements in the reverse order. It is an error if target and source are identical vectors and the target & source ranges overlap; however, if tstart = sstart, vector-reverse-copy! behaves as (vector-reverse! target tstart send) would.
(srfi 43) procedure (vector->list (vec vector?) ) ⟹ list?
(srfi 43) procedure (vector->list (vec vector?) (start integer?) ) ⟹ list?
(srfi 43) procedure (vector->list (vec vector?) (start integer?) (end integer?) ) ⟹ list?
Creates a list containing the elements in vec between start, which defaults to 0, and end, which defaults to the length of vec.
(srfi 43) procedure (reverse-vector->list (vec vector?) ) ⟹ list?
(srfi 43) procedure (reverse-vector->list (vec vector?) (start integer?) ) ⟹ list?
(srfi 43) procedure (reverse-vector->list (vec vector?) (start integer?) (end integer?) ) ⟹ list?
Like vector->list, but the resulting list contains the elements in reverse between the the specified range.
(srfi 43) procedure (list->vector (list list?) ) ⟹ vector?
Creates a vector of elements from proper-list.
(srfi 43) procedure (reverse-list->vector (list list?) ) ⟹ vector?
Like list->vector, but the resulting list contains the elements in reverse of proper-list.
library (srfi 45)
(srfi 45) syntax (delay () ((_ expression) promise? ) )
Takes an expression of arbitrary type a and returns a promise of type (Promise a) which at some point in the future may be asked (by the force procedure) to evaluate the expression and deliver the resulting value.
(srfi 45) syntax (lazy () ((_ expression) promise? ) )
expression ⟹ promise?
Takes an expression of type (Promise a) and returns a promise of type (Promise a) which at some point in the future may be asked (by the force procedure) to evaluate the expression and deliver the resulting promise.
(srfi 45) procedure (force (expression promise?) ) ⟹ *
Takes an argument of type (Promise a) and returns a value of type a as follows: If a value of type a has been computed for the promise, this value is returned. Otherwise, the promise is first evaluated, then overwritten by the obtained promise or value, and then force is again applied (iteratively) to the promise.
(srfi 45) procedure (eager expression ) ⟹ promise?
Takes an argument of type a and returns a value of type Promise a. As opposed to delay, the argument is evaluated eagerly.
library (srfi 46)
(srfi 46) 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
Syntax-rules syntax is extended so that there is an extra possible token before the literal identifier list:
(syntax-rules [<ellipsis-identifier>] (<literal-identifier> ...)
(<pattern> <template>)
...)
Ellipsis-identifier specifies the token used for ellipsis. It defaults to the usual R5RS1 ellipsis identifier, ..., but it can be specified to be any identifier, such as :::. This identifier's specification is considered to be a binding whose scope is the rules of the transformer. The macro system implementation must make the hygienic arrangements described in R5RS's section 4.3 to preserve the lexical scope of these bindings.
The syntax-rules pattern language is also extended to allow 'tail patterns.' The following clauses are added to <pattern>:
(<pattern> ... <ellipsis> <pattern> ...)
#(<pattern> ... <ellipsis> <pattern> ...)
And the following clauses are added to the semantics of syntax-rules' pattern matching:
library (srfi 47)
(srfi 47) procedure (array? obj ) ⟹ boolean?
Returns #t if the obj is an array, and #f if not.
Note: Arrays are not disjoint from other Scheme types. Strings and vectors also satisfy array?.
(srfi 47) procedure (equal? obj1 obj2 ) ⟹ boolean?
`Equal?' recursively compares the contents of pairs, vectors, strings, and arrays, 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.
(srfi 47) procedure (make-array (prototype array?) (k1 integer?) ... ) ⟹ array?
Creates and returns an array of type prototype with dimensions k1, k2, ... and filled with elements from prototype. prototype must be an array, vector, or string. The implementation-dependent type of the returned array will be the same as the type of prototype. except if that would be a vector or string with more than one dimension, in which case some variety of array will be returned.
If the prototype has no elements, then the initial contents of the returned array are unspecified. Otherwise, the returned array will be filled with the element at the origin of prototype.
(srfi 47) procedure (ac64 ) ⟹ array?
(srfi 47) procedure (ac64 (z complex?) ) ⟹ array?
Returns a high-precision complex uniform-array prototype.
(srfi 47) procedure (ac32 ) ⟹ array?
(srfi 47) procedure (ac32 (z complex?) ) ⟹ array?
Returns a complex uniform-array prototype.
(srfi 47) procedure (ar64 ) ⟹ array?
(srfi 47) procedure (ar64 (x real?) ) ⟹ array?
Returns a high-precision real uniform-array prototype.
(srfi 47) procedure (ar32 ) ⟹ array?
(srfi 47) procedure (ar32 (x real?) ) ⟹ array?
Returns a real uniform-array prototype.
(srfi 47) procedure (as64 ) ⟹ array?
(srfi 47) procedure (as64 (n integer?) ) ⟹ array?
Returns an exact signed integer uniform-array prototype with at least 64 bits of precision.
(srfi 47) procedure (as32 ) ⟹ array?
(srfi 47) procedure (as32 (n integer?) ) ⟹ array?
Returns an exact signed integer uniform-array prototype with at least 32 bits of precision.
(srfi 47) procedure (as16 ) ⟹ array?
(srfi 47) procedure (as16 (n integer?) ) ⟹ array?
Returns an exact signed integer uniform-array prototype with at least 16 bits of precision.
(srfi 47) procedure (as8 ) ⟹ array?
(srfi 47) procedure (as8 (n integer?) ) ⟹ array?
Returns an exact signed integer uniform-array prototype with at least 8 bits of precision.
(srfi 47) procedure (au64 ) ⟹ array?
(srfi 47) procedure (au64 (n integer?) ) ⟹ array?
Returns an exact non-negative integer uniform-array prototype with at least 64 bits of precision.
(srfi 47) procedure (au32 ) ⟹ array?
(srfi 47) procedure (au32 (n integer?) ) ⟹ array?
Returns an exact non-negative integer uniform-array prototype with at least 32 bits of precision.
(srfi 47) procedure (au16 ) ⟹ array?
(srfi 47) procedure (au16 (n integer?) ) ⟹ array?
Returns an exact non-negative integer uniform-array prototype with at least 16 bits of precision.
(srfi 47) procedure (au8 ) ⟹ array?
(srfi 47) procedure (au8 (n integer?) ) ⟹ array?
Returns an exact non-negative integer uniform-array prototype with at least 8 bits of precision.
(srfi 47) procedure (at1 ) ⟹ array?
(srfi 47) procedure (at1 (b boolean?) ) ⟹ array?
Returns a boolean uniform-array prototype.
(srfi 47) procedure (array-rank obj ) ⟹ integer?
Returns the number of dimensions of obj. If obj is not an array, 0 is returned.
(srfi 47) procedure (array-dimnesions (array array?) ) ⟹ list?
return ⟹ (list integer? )
Returns a list of dimensions.
(srfi 47) procedure (array-in-bounds? (array array?) (index1 integer?) ... ) ⟹ boolean?
Returns #t if its arguments would be acceptable to array-ref.
(srfi 47) procedure (array-ref (array array?) (index1 integer?) ... ) ⟹ *
Returns the (index1, index2, ...) element of array.
(srfi 47) procedure (array-set! (array array?) obj (index1 integer?) ... ) ⟹ undefined
Stores obj in the (index1, index2, ...) element of array. The value returned by array-set! is unspecified.
library (srfi 48)
(srfi 48) procedure (format (format-string string?) obj ... ) ⟹ string?
(srfi 48) procedure (format (port #f) (format-string string?) obj ... ) ⟹ string?
(srfi 48) procedure (format (port output-port?) (format-string string?) obj ... ) ⟹ undefined
Accepts a format template (a Scheme String), and processes it, replacing any format directives in order with one or more characters, the characters themselves dependent on the semantics of the format directive encountered. Each directive may consume one obj. It is an error if fewer or more obj values are provided than format directives that require them.
When a port is specified it must be either an output port or a boolean. If an output-port is specified, the formatted output is output into that port. If the port argument is #t, output is to the current-output-port. If the port is #f or no port is specified, the output is returned as a string. If the port is specified and is #t or an output-port, the result of the format function is unspecified.
It is unspecified which encoding is used (e.g. ASCII, EBCDIC, UNICODE). A given implementation must specify which encoding is used. The implementation may or may not allow the encoding to be selected or changed.
It is an error if an format directive consumes an obj argument and that argument does not confirm to a required type as noted in the table below.
It is permissible, but highly discouraged, to implement pretty-print as (define pretty-print write).
An format directive is a two character sequence in the string where the first character is a tilde '~'. Directive characters are case-independent, i.e. upper and lower case characters are interpreted the same. Each directive code's meaning is described in the following table:
DIRECTIVE MNEMONIC ACTION CONSUMES?
~a Any (display obj) for humans yes
~s Slashified (write obj) for parsers yes
~w WriteCircular (write-with-shared-structure obj) like ~s, but handles recursive structures yes
~d Decimal the obj is a number which is output in decimal radix yes
~x heXadecimal the obj is a number which is output in hexdecimal radix yes
~o Octal the obj is a number which is output in octal radix yes
~b Binary the obj is a number which is output in binary radix yes
~c Character the single charater obj is output by write-char yes
~y Yuppify the list obj is pretty-printed to the output yes
~? Indirection the obj is another format-string and the following obj is a list of arguments; format is called recursively yes
~K Indirection the same as ~? for backward compatability with some existing implementations yes
~[w[,d]]F Fixed ~w,dF outputs a number with width w and d digits after the decimal; ~wF outputs a string or number with width w. yes
~~ Tilde output a tilde no
~t Tab output a tab character no
~% Newline output a newline character no
~& Freshline output a newline character if it is known that the previous output was not a newline no
~_ Space a single space character is output no
~h Help outputs one line of call synopsis, one line of comment, and one line of synopsis for each format directive, starting with the directive (e.g. "~t") no
The ~F, fixed format, directive requires some elucidation.
~wF is useful for strings or numbers. Where the string (or number->string of the number) has fewer characters than the integer width w, the string is padded on the left with space characters.
~w,dF is typically used only on numbers. For strings, the d specifier is ignored. For numbers, the integer d specifies the number of decimal digits after the decimal place. Both w and d must be zero or positive.
If d is specified, the number is processed as if added to 0.0, i.e. it is converted to an inexact value.
(format "~8,2F" 1/3) => " 0.33"
If no d is specified, the number is not coerced to inexact.
(format "~6F" 32) => " 32"
Digits are padded to the right with zeros
(format "~8,2F" 32) => " 32.00"
If the number it too large to fit in the width specified, a string longer than the width is returned
(format "~1,2F" 4321) => "4321.00"
If the number is complex, d is applied to both real and imaginal parts
(format "~1,2F" (sqrt -3.9)) => "0.00+1.97i"
For very large or very small numbers, the point where exponential notation is used is implementation defined.
(format "~8F" 32e5) => " 3.2e6" or "3200000.0"
library (srfi 51)
(srfi 51) procedure (rest-values (rest-list list?) ) ⟹ list?
(srfi 51) procedure (rest-values caller (rest-list list?) ) ⟹ list?
(srfi 51) procedure (rest-values (rest-list list?) args-number-limit ) ⟹ list?
(srfi 51) procedure (rest-values caller (rest-list list?) args-number-limit default ... ) ⟹ list?
1. When the <args-number-limit> is + or a positive integer, each <default> should be a list that contains default value(s), or a pair whose car is a default value and cdr is a predicate procedure.
2. When the <args-number-limit> is - or a negative integer, each <default> is any scheme expression.
3. When the <args-number-limit> is a boolean, each <default> is the same as 1.
1. (first mode of operation)
Rest-values checks whether each element of the <rest-list> is a member of the corresponding <default> list, or satisfies the predicate procedure of the corresponding <default> pair, and then returns the checked element(s). If the element doesn't pass, rest-values signals an error. when there are no more elements in the <rest-list>, then rest-values additionally returns the car values of the remaining <default>s. On the other hand, when the number of elements of the <rest-list> are more than the number of the <default>s, the supernumerary elements are additionally returned if the <args-number-limit> is +, or its value is not less than the number of elements of the <rest-list>.
2. (second mode of operation)
This is the same as the first except that rest-values does not check each element of the <rest-list>, and it uses - instead of +, and an absolute value instead of a simple value as the value of <args-number-limit>.
3. (third mode of operation)
Rest-values checks whether any element of the <default> list is a member of the <rest-list>, or any element of the <rest-list> satisfies the predicate procedure of the <default> pair, and then returns the checked element. If the <default> doesn't pass, rest-values returns the car value of the <default>. when any elements of the <rest-list> are remained after the above processing, rest-values either signals an error if the <args-number-limit> is #t, or returns the remaining elements of the <rest-list> if the <args-number-limit> is #f.
(srfi 51) syntax (arg-and () ((_ variable expr ...) boolean? ) ((_ caller variable expr ...) boolean? ) )
(srfi 51) syntax (arg-ands () ((_ (variable expr ...) ...) boolean? ) ((_ (caller variable expr ...) ...) boolean? ) ((_ common-caller (variable expr ...) ...) boolean? ) ((_ common-caller (caller variable expr ...) ...) boolean? ) )
(srfi 51) syntax (err-and () ((_ caller expression ...)) )
(srfi 51) syntax (err-ands () ((_ (caller expression ...) ...)) )
(srfi 51) syntax (arg-or () ((_ variable expr ...) boolean? ) ((_ caller variable expr ...) boolean? ) )
(srfi 51) syntax (arg-ors () ((_ (variable expr ...) ...) boolean? ) ((_ (caller variable expr ...) ...) boolean? ) ((_ common-caller (variable expr ...) ...) boolean? ) ((_ common-caller (caller variable expr ...) ...) boolean? ) )
(srfi 51) syntax (err-or () ((_ caller expression ...)) )
(srfi 51) syntax (err-ors () ((_ (caller expression ...) ...)) )
Each <variable> should be an argument of a procedure.
The <caller>, <expr>, and <expression> are any scheme expression, but the <expr> should contain the corresponding <variable>.
Arg-and, arg-ands, err-and, and err-ands are the same as "and" except that these signal an error in case "and" returns a false value.
Arg-or, arg-ors, err-or, and err-ors are the same as "or" except that these signal an error in case "or" returns a true value.
library (srfi 54)
(srfi 54) procedure (CAT object formatting-specifier ... ) ⟹ string?
Each formatting-specifier should match one of following:
<suffix%>: effective only for the number type of <object>.
<suffix$>: effective for all types except the number type of <object>.
<suffix*>: effective for all types of <object>.
<object> is any Scheme object.
<exactness> is a symbol: exact or inexact.
<radix> is a symbol: binary, octal, decimal, or hexadecimal. Each radix sign except decimal is prefixed to the resulting string. The default value is decimal. If <sign> is a symbol that takes the form of 'sign, and <object> is a positive number without a positive sign, the positive sign is prefixed to the resulting string.
<precision> is an inexact integer whose absolute value specifies the number of decimal digits after a decimal point. If <precision> is a non-negative integer, an exact sign is prefixed to the resulting string as needed.
<separator> is a list whose first element is a character serving as a separator and second element is a positive exact integer. If the integer is n, the resulting string is separated in every n-characters of the resulting string. When the integer is omitted, the default value is 3.
<writer> is a procedure of two arguments; <object> and a string port. It writes <object> to the string port. The default value of <writer> is varied according to the type of <object>. When <object> is a self-evaluating constant, it becomes equivalent to DISPLAY procedure, otherwise, it becomes WRITE procedure. If you want any objects to be displayed in your own way, you have to define your own <writer>. Otherwise, they are displayed simply in their evaluated forms.
<pipe> is a list which is composed of one or more procedures. Each procedure takes at least one string argument and returns a string. One procedure connects with another as a pipe.
<take> is a list whose elements are two exact integers; n and m, and the absolute values of n and m are N and M, respectively. First, the resulting string takes from the left n-characters, if it is non-negative, or all the characters but N-characters, if negative. Second, it takes from the right m-characters, if it is non-negative, or all the characters but M-characters, if negative. Then, it concatenates two set of characters taken. The second element can be omitted. If omitted, the default value is 0.
<converter> is a pair whose car value is a predicate procedure that checks whether <object> satisfies it, and cdr value is a procedure that takes the <object> as an argument and returns a string. When <object> satisfies the predicate procedure, all optional arguments are ineffective except <width>, <char>, <port>, and <string>.
<width> is an exact integer whose absolute value specifies the width of the resulting string. When the resulting string has fewer characters than the absolute value of <width>, it is placed rightmost with the rest being padded with <char>s, if <width> is positive, or it is placed leftmost with the rest being padded with <char>s, if <width> is negative. On the other hand, when the resulting string has more characters than the absolute value of <width>, the <width> is ignored. The default value is 0.
<char> is a padding character. The default value is #\space.
<port> is an output port or a boolean. If an output port is specified, the resulting string and <string>s are output into that port and simultaneously returned as a string. If <port> is #t, the output port is current output port. If <port> is #f, the output is only returned as a string. The default value is #f.
<string> is a string that is appended to the resulting string.
The order of all optional arguments does not matter. The CAT procedure processes optional arguments in the following order; <exactness>, <radix>, <precision>, <separator>, <sign> for the number type of <object>, or in the following order; <writer>, <pipe>, <take> for all other types.
library (srfi 59)
(srfi 59) procedure (program-vicinity ) ⟹ vicinity
Returns the vicinity of the currently loading Scheme code. For an interpreter this would be the directory containing source code. For a compiled system (with multiple files) this would be the directory where the object or executable files are. If no file is currently loading, then the result is undefined. Warning: program-vicinity can return incorrect values if your program escapes back into a load continuation.
(srfi 59) procedure (library-vicinity ) ⟹ vicinity
Returns the vicinity of the shared Scheme library.
(srfi 59) procedure (implementation-vicinity ) ⟹ vicinity
Returns the vicinity of the underlying Scheme implementation. This vicinity will likely contain startup code and messages and a compiler.
(srfi 59) procedure (user-vicinity ) ⟹ vicinity
Returns the vicinity of the current directory of the user. On most systems this is `""' (the empty string).
(srfi 59) procedure (home-vicinity ) ⟹ vicinity
Returns the vicinity of the user's HOME directory, the directory which typically contains files which customize a computer environment for a user. If scheme is running without a user (eg. a daemon) or if this concept is meaningless for the platform, then home-vicinity returns #f.
(srfi 59) procedure (in-vicinity (vicinity vicinity) (filename string?) ) ⟹ string?
Returns a filename suitable for use by load, open-input-file, open-output-file, etc. The returned filename is filename in vicinity. in-vicinity should allow filename to override vicinity when filename is an absolute pathname and vicinity is equal to the value of (user-vicinity). The behavior of in-vicinity when filename is absolute and vicinity is not equal to the value of (user-vicinity) is unspecified. For most systems in-vicinity can be string-append.
(srfi 59) procedure (sub-vicinity (vicinity vicinity) (name string?) ) ⟹ vicinity
Returns the vicinity of vicinity restricted to name. This is used for large systems where names of files in subsystems could conflict. On systems with directory structure sub-vicinity will return a pathname of the subdirectory name of vicinity.
(srfi 59) procedure (make-vicinity (dir-path string?) ) ⟹ vicinity
Returns dirpath as a vicinity for use as first argument to in-vicinity.
(srfi 59) procedure (pathname->vicinity (path string?) ) ⟹ vicinity
Returns the vicinity containing path.
(srfi 59) procedure (vicinity:suffix? (chr char?) ) ⟹ boolean?
Returns the `#t' if chr is a vicinity suffix character; and #f otherwise. Typical vicinity suffixes are `/', `:', and `\'.
library (srfi 60)
(srfi 60) procedure (logand (n1 integer?) ... ) ⟹ integer?
(srfi 60) procedure (bitwise-and (n1 integer?) ... ) ⟹ integer?
Returns the integer which is the bit-wise AND of the integer arguments.
(srfi 60) procedure (logior (n1 integer?) ... ) ⟹ integer?
(srfi 60) procedure (bitwise-ior (n1 integer?) ... ) ⟹ integer?
Returns the integer which is the bit-wise OR of the integer arguments.
(srfi 60) procedure (logxor (n1 integer?) ... ) ⟹ integer?
(srfi 60) procedure (bitwise-xor (n1 integer?) ... ) ⟹ integer?
Returns the integer which is the bit-wise XOR of the integer arguments.
(srfi 60) procedure (lognot (n integer?) ) ⟹ integer?
(srfi 60) procedure (bitwise-not (n integer?) ) ⟹ integer?
Returns the integer which is the one's-complement of the integer argument.
(srfi 60) procedure (bitwise-if (mask integer?) (n0 integer?) (n1 integer?) ) ⟹ integer?
(srfi 60) procedure (bitwise-merge (mask integer?) (n0 integer?) (n1 integer?) ) ⟹ integer?
Returns an integer composed of some bits from integer n0 and some from integer n1. A bit of the result is taken from n0 if the corresponding bit of integer mask is 1 and from n1 if that bit of mask is 0.
(srfi 60) procedure (logtest (j integer?) (k integer?) ) ⟹ boolean?
(srfi 60) procedure (any-bits-set? (j integer?) (k integer?) ) ⟹ boolean?
(logtest j k) == (not (zero? (logand j k)))
(srfi 60) procedure (logcount (n integer?) ) ⟹ integer?
(srfi 60) procedure (bit-count (n integer?) ) ⟹ integer?
Returns the number of bits in integer n. If integer is positive, the 1-bits in its binary representation are counted. If negative, the 0-bits in its two's-complement binary representation are counted. If 0, 0 is returned.
(srfi 60) procedure (integer-length (n integer?) ) ⟹ integer?
Returns the number of bits neccessary to represent n.
(srfi 60) procedure (log2-binary-factors (n integer?) ) ⟹ integer?
(srfi 60) procedure (first-set-bit (n integer?) ) ⟹ integer?
Returns the number of factors of two of integer n. This value is also the bit-index of the least-significant `1' bit in n.
(srfi 60) procedure (logbit? (index integer?) (n integer?) ) ⟹ boolean?
(srfi 60) procedure (bit-set? (index integer?) (n integer?) ) ⟹ boolean?
(logbit? index n) == (logtest (expt 2 index) n)
(srfi 60) procedure (copy-bit (index integer?) (from integer?) (bit boolean?) ) ⟹ integer?
Returns an integer the same as from except in the indexth bit, which is 1 if bit is #t and 0 if bit is #f.
(srfi 60) procedure (bit-field (n integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns the integer composed of the start (inclusive) through end (exclusive) bits of n. The startth bit becomes the 0-th bit in the result.
(srfi 60) procedure (copy-bit-field (to integer?) (from integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns an integer the same as to except possibly in the start (inclusive) through end (exclusive) bits, which are the same as those of from. The 0-th bit of from becomes the startth bit of the result.
(srfi 60) procedure (ash (n integer?) (count integer?) ) ⟹ integer?
(srfi 60) procedure (arithmetic-shift (n integer?) (count integer?) ) ⟹ integer?
Returns an integer equivalent to (inexact->exact (floor (* n (expt 2 count)))).
(srfi 60) procedure (rotate-bit-field (n integer?) (count integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns n with the bit-field from start to end cyclically permuted by count bits towards high-order.
(srfi 60) procedure (reverse-bit-field (n integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns n with the order of bits start to end reversed.
(srfi 60) procedure (integer->list (k integer?) ) ⟹ list?
(srfi 60) procedure (integer->list (k integer?) (len integer?) ) ⟹ list?
integer->list returns a list of len booleans corresponding to each bit of the non-negative integer k. #t is coded for each 1; #f for 0. The len argument defaults to (integer-length k).
(srfi 60) procedure (list->integer (list list?) ) ⟹ integer?
list->integer returns an integer formed from the booleans in the list list, which must be a list of booleans. A 1 bit is coded for each #t; a 0 bit for #f.
(srfi 60) procedure (booleans->integer (bool1 boolean?) ... ) ⟹ integer?
Returns the integer coded by the bool1 ... arguments.
library (srfi 61)
(srfi 61) syntax (cond (else => ) ((_ clause1 clause2 ...)) )
(test expression1 ...) (test => receiver) (test guard => receiver) (else expression1 expression2 ...)
guard ⟹ procedure?
receiver ⟹ procedure?
The <cond clause> production in the formal syntax of Scheme as written by R5RS in section 7.1.3 is extended with a new option:
<cond clause> --->
...
| (<generator> <guard> => <receiver>)
where <generator>, <guard>, & <receiver> are all <expression>s.
Clauses of this form have the following semantics: <generator> is evaluated. It may return arbitrarily many values. <Guard> is applied to an argument list containing the values in order that <generator> returned. If <guard> returns a true value for that argument list, <receiver> is applied with an equivalent argument list. If <guard> returns a false value, however, the clause is abandoned and the next one is tried.
library (srfi 63)
(srfi 63) procedure (array? obj ) ⟹ boolean?
Returns #t if the obj is an array, and #f if not.
Note: Arrays are not disjoint from other Scheme types. Vectors and possibly strings also satisfy array?.
(srfi 63) procedure (equal? obj1 obj2 ) ⟹ boolean?
Returns #t if obj1 and obj2 have the same rank and dimensions and the corresponding elements of obj1 and obj2 are equal?.
equal? recursively compares the contents of pairs, vectors, strings, and arrays, 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.
(srfi 63) procedure (array-rank obj ) ⟹ integer?
Returns the number of dimensions of obj. If obj is not an array, 0 is returned.
(srfi 63) procedure (array-dimnesions (array array?) ) ⟹ list?
return ⟹ (list integer? )
Returns a list of dimensions.
(srfi 63) procedure (make-array (prototype array?) (k1 integer?) ... ) ⟹ array?
Creates and returns an array of type prototype with dimensions k1, ... and filled with elements from prototype. prototype must be an array, vector, or string. The implementation-dependent type of the returned array will be the same as the type of prototype; except if that would be a vector or string with rank not equal to one, in which case some variety of array will be returned.
If the prototype has no elements, then the initial contents of the returned array are unspecified. Otherwise, the returned array will be filled with the element at the origin of prototype.
(srfi 63) procedure (list->array (rank integer?) (proto array?) (list list?) ) ⟹ array?
list must be a rank-nested list consisting of all the elements, in row-major order, of the array to be created.
(srfi 63) procedure (array->list (array array?) ) ⟹ *
Returns a rank-nested list consisting of all the elements, in row-major order, of array. In the case of a rank-0 array, array->list returns the single element.
(srfi 63) procedure (vector->array (vect vector?) (proto array?) (dim1 integer?) ... ) ⟹ array?
vect must be a vector of length equal to the product of exact nonnegative integers dim1, ....
vector->array returns an array of type proto consisting of all the elements, in row-major order, of vect. In the case of a rank-0 array, vect has a single element.
(srfi 63) procedure (array->vector (array array?) ) ⟹ vector?
Returns a new vector consisting of all the elements of array in row-major order.
(srfi 63) procedure (array-in-bounds? (array array?) (index1 integer?) ... ) ⟹ boolean?
Returns #t if its arguments would be acceptable to array-ref.
(srfi 63) procedure (array-ref (array array?) (index1 integer?) ... ) ⟹ *
Returns the (k1, ...) element of array.
(srfi 63) procedure (array-set! (array array?) obj (index1 integer?) ... ) ⟹ undefined
Stores obj in the (k1, ...) element of array. The value returned by array-set! is unspecified.
These functions return a prototypical uniform-array enclosing the optional argument (which must be of the correct type). If the uniform-array type is supported by the implementation, then it is returned; defaulting to the next larger precision type; resorting finally to vector.
(srfi 63) procedure (A:floC128b ) ⟹ array?
(srfi 63) procedure (A:floC128b (z complex?) ) ⟹ array?
Returns an inexact 128.bit flonum complex uniform-array prototype.
(srfi 63) procedure (A:floC64b ) ⟹ array?
(srfi 63) procedure (A:floC64b (z complex?) ) ⟹ array?
Returns an inexact 64.bit flonum complex uniform-array prototype.
(srfi 63) procedure (A:floC32b ) ⟹ array?
(srfi 63) procedure (A:floC32b (z complex?) ) ⟹ array?
Returns an inexact 32.bit flonum complex uniform-array prototype.
(srfi 63) procedure (A:floC16b ) ⟹ array?
(srfi 63) procedure (A:floC16b (z complex?) ) ⟹ array?
Returns an inexact 16.bit flonum complex uniform-array prototype.
(srfi 63) procedure (A:floR128b ) ⟹ array?
(srfi 63) procedure (A:floR128b (z real?) ) ⟹ array?
Returns an inexact 128.bit flonum real uniform-array prototype.
(srfi 63) procedure (A:floR64b ) ⟹ array?
(srfi 63) procedure (A:floR64b (z real?) ) ⟹ array?
Returns an inexact 64.bit flonum real uniform-array prototype.
(srfi 63) procedure (A:floR32b ) ⟹ array?
(srfi 63) procedure (A:floR32b (z real?) ) ⟹ array?
Returns an inexact 32.bit flonum real uniform-array prototype.
(srfi 63) procedure (A:floR16b ) ⟹ array?
(srfi 63) procedure (A:floR16b (z real?) ) ⟹ array?
Returns an inexact 16.bit flonum real uniform-array prototype.
(srfi 63) procedure (A:floQ128d ) ⟹ array?
(srfi 63) procedure (A:floQ128d (z real?) ) ⟹ array?
Returns an exact 128.bit decimal flonum rational uniform-array prototype.
(srfi 63) procedure (A:floQ64d ) ⟹ array?
(srfi 63) procedure (A:floQ64d (z real?) ) ⟹ array?
Returns an exact 64.bit decimal flonum rational uniform-array prototype.
(srfi 63) procedure (A:floQ32d ) ⟹ array?
(srfi 63) procedure (A:floQ32d (z real?) ) ⟹ array?
Returns an exact 32.bit decimal flonum rational uniform-array prototype.
(srfi 63) procedure (A:fixZ64b ) ⟹ array?
(srfi 63) procedure (A:fixZ64b (z integer?) ) ⟹ array?
Returns an exact binary fixnum uniform-array prototype with at least 64 bits of precision.
(srfi 63) procedure (A:fixZ32b ) ⟹ array?
(srfi 63) procedure (A:fixZ32b (z integer?) ) ⟹ array?
Returns an exact binary fixnum uniform-array prototype with at least 32 bits of precision.
(srfi 63) procedure (A:fixZ16b ) ⟹ array?
(srfi 63) procedure (A:fixZ16b (z integer?) ) ⟹ array?
Returns an exact binary fixnum uniform-array prototype with at least 16 bits of precision.
(srfi 63) procedure (A:fixZ8b ) ⟹ array?
(srfi 63) procedure (A:fixZ8b (z integer?) ) ⟹ array?
Returns an exact binary fixnum uniform-array prototype with at least 8 bits of precision.
(srfi 63) procedure (A:fixN64b ) ⟹ array?
(srfi 63) procedure (A:fixN64b (z integer?) ) ⟹ array?
Returns an exact non-negative binary fixnum uniform-array prototype with at least 64 bits of precision.
(srfi 63) procedure (A:fixN32b ) ⟹ array?
(srfi 63) procedure (A:fixN32b (z integer?) ) ⟹ array?
Returns an exact non-negative binary fixnum uniform-array prototype with at least 32 bits of precision.
(srfi 63) procedure (A:fixN16b ) ⟹ array?
(srfi 63) procedure (A:fixN16b (z integer?) ) ⟹ array?
Returns an exact non-negative binary fixnum uniform-array prototype with at least 16 bits of precision.
(srfi 63) procedure (A:fixN8b ) ⟹ array?
(srfi 63) procedure (A:fixN8b (z integer?) ) ⟹ array?
Returns an exact non-negative binary fixnum uniform-array prototype with at least 8 bits of precision.
(srfi 63) procedure (A:bool ) ⟹ array?
(srfi 63) procedure (A:bool (b boolean?) ) ⟹ array?
Returns a boolean uniform-array prototype.
library (srfi 64)
(srfi 64) syntax (test-assert () ((_ expression)) ((_ test-name expression)) )
test-name ⟹ string?
This evaluates the expression. The test passes if the result is true; if the result is false, a test failure is reported. The test also fails if an exception is raised, assuming the implementation has a way to catch exceptions. How the failure is reported depends on the test runner environment. The test-name is a string that names the test case. (Though the test-name is a string literal in the examples, it is an expression. It is evaluated only once.) It is used when reporting errors, and also when skipping tests, as described below. It is an error to invoke test-assert if there is no current test runner.
(srfi 64) syntax (test-eqv () ((_ expected test-expr)) ((_ test-name expected test-expr)) )
test-name ⟹ string?
This is equivalent to:
(test-assert [test-name] (eqv? expected test-expr))
(srfi 64) syntax (test-equal () ((_ expected test-expr)) ((_ test-name expected test-expr)) )
test-name ⟹ string?
This is equivalent to:
(test-assert [test-name] (equal? expected test-expr))
(srfi 64) syntax (test-eq () ((_ expected test-expr)) ((_ test-name expected test-expr)) )
test-name ⟹ string?
This is equivalent to:
(test-assert [test-name] (eq? expected test-expr))
(srfi 64) syntax (test-approximate () ((_ expected test-expr error)) ((_ test-name expected test-expr error)) )
test-name ⟹ string?
This is equivalent to (except that each argument is only evaluated once):
(test-assert [test-name]
(and (>= test-expr (- expected error))
(<= test-expr (+ expected error))))
(srfi 64) syntax (test-error () ((_ test-expr)) ((_ error-type test-expr)) ((_ test-name error-type test-expr)) )
test-name ⟹ string?
Evaluating test-expr is expected to signal an error. The kind of error is indicated by error-type. If the error-type is left out, or it is #t, it means "some kind of unspecified error should be signaled". This specification leaves it implementation-defined (or for a future specification) what form test-error may take, though all implementations must allow #t. Some implementations may support SRFI-35's conditions, but these are only standardized for SRFI-36's I/O conditions, which are seldom useful in test suites.
(srfi 64) syntax (test-read-eval-string () ((_ string)) )
string ⟹ string?
This function parses string (using read) and evaluates the result. The result of evaluation is returned from test-read-eval-string. An error is signalled if there are unread characters after the read is done.
(srfi 64) syntax (test-begin () ((_ suite-name)) ((_ suite-name count)) )
A test-begin enters a new test group. The suite-name becomes the current test group name, and is added to the end of the test group path. Portable test suites should use a sting literal for suite-name; the effect of expressions or other kinds of literals is unspecified.
(srfi 64) syntax (test-end () ((_)) ((_ suite-name)) )
A test-end leaves the current test group. An error is reported if the suite-name does not match the current test group name.
Additionally, if the matching test-begin installed a new test-runner, then the test-end will de-install it, after reporting the accumulated test results in an implementation-defined manner.
(srfi 64) syntax (test-group () ((_ suite-name decl-or-expr ...)) )
Equivalent to:
(if (not (test-to-skip% suite-name))
(dynamic-wind
(lambda () (test-begin suite-name))
(lambda () decl-or-expr ...)
(lambda () (test-end suite-name))))
This is usually equivalent to executing the decl-or-exprs within the named test group. However, the entire group is skipped if it matched an active test-skip (see later). Also, the test-end is executed in case of an exception.
(srfi 64) syntax (test-group-with-cleanup () ((_ suite-name decl-or-expr ... cleanup-form)) )
Execute each of the decl-or-expr forms in order (as in a <body>), and then execute the cleanup-form. The latter should be executed even if one of a decl-or-expr forms raises an exception (assuming the implementation has a way to catch exceptions).
(srfi 64) procedure (test-match-name (name string?) ) ⟹ procedure?
(return (runner test-runner?) ) ⟹ boolean?
The resulting specifier matches if the current test name (as returned by test-runner-test-name) is equals? to name.
(srfi 64) procedure (test-match-nth (n integer?) ) ⟹ procedure?
(srfi 64) procedure (test-match-nth (n integer?) (count integer?) ) ⟹ procedure?
(return (runner test-runner?) ) ⟹ boolean?
This evaluates to a stateful predicate: A counter keeps track of how many times it has been called. The predicate matches the n'th time it is called (where 1 is the first time), and the next (- count 1) times, where count defaults to 1.
(srfi 64) procedure (test-match-any (specifier procedure?) ... ) ⟹ procedure?
(specifier (runner test-runner?) ) ⟹ boolean?
(return (runner test-runner?) ) ⟹ boolean?
The resulting specifier matches if any specifier matches. Each specifier is applied, in order, so side-effects from a later specifier happen even if an earlier specifier is true.
(srfi 64) procedure (test-match-all (specifier procedure?) ... ) ⟹ procedure?
(specifier (runner test-runner?) ) ⟹ boolean?
(return (runner test-runner?) ) ⟹ boolean?
The resulting specifier matches if each specifier matches. Each specifier is applied, in order, so side-effects from a later specifier happen even if an earlier specifier is false.
count (i.e. an integer)
Convenience short-hand for: (test-match-nth 1 count).
name (i.e. a string)
Convenience short-hand for (test-match-name name).
(srfi 64) procedure (test-skip (specifier (or procedure?integer?string?)) ) ⟹ undefined
(specifier (runner test-runner?) ) ⟹ boolean?
Evaluating test-skip adds the resulting specifier to the set of currently active skip-specifiers. Before each test (or test-group) the set of active skip-specifiers are applied to the active test-runner. If any specifier matches, then the test is skipped.
For convenience, if the specifier is a string that is syntactic sugar for (test-match-name specifier).
(srfi 64) procedure (test-expect-fail (specifier (or procedure?integer?string?)) ) ⟹ undefined
(specifier (runner test-runner?) ) ⟹ boolean?
Matching tests (where matching is defined as in test-skip) are expected to fail. This only affects test reporting, not test execution.
(srfi 64) procedure (test-runner? obj ) ⟹ boolean?
True iff value is a test-runner object.
(srfi 64) procedure (test-runner-current ) ⟹ test-runner?
(srfi 64) procedure (test-runner-current (runner test-runner?) ) ⟹ undefined
Get or set the current test-runner. If an implementation supports parameter objects (as in SRFI-39), then test-runner-current can be a parameter object. Alternatively, test-runner-current may be implemented as a macro or function that uses a fluid or thread-local variable, or a plain global variable.
(srfi 64) procedure (test-runner-get ) ⟹ test-runner?
Same as (test-runner-current), buth throws an exception if there is no current test-runner.
(srfi 64) procedure (test-runner-simple ) ⟹ test-runner?
Creates a new simple test-runner, that prints errors and a summary on the standard output port.
(srfi 64) procedure (test-runner-null ) ⟹ test-runner?
Creates a new test-runner, that does nothing with the test results. This is mainly meant for extending when writing a custom runner.
Implementations may provide other test-runners, perhaps a (test-runner-gui).
(srfi 64) procedure (test-runner-create ) ⟹ test-runner?
Create a new test-runner. Equivalent to ((test-runner-factory))
(srfi 64) procedure (test-runner-factory ) ⟹ procedure?
(srfi 64) procedure (test-runner-factory (factory procedure?) ) ⟹ undefined
(factory ) ⟹ test-runner?
Get or set the current test-runner factory. A factory is a zero-argument function that creates a new test-runner. The default value is test-runner-simple, but implementations may provide a way to override the default. As with test-runner-current, this may be a parameter object, or use a per-thread, fluid, or global variable.
(srfi 64) procedure (test-apply (specifier (or integer?string?procedure?)) ... procedure ) ⟹ undefined
(procedure ) ⟹ *
(specifier (runner test-runner?) ) ⟹ boolean?
Calls procedure with no arguments using the specified runner as the current test-runner. If runner is omitted, then (test-runner-current) is used. (If there is no current runner, one is created as in test-begin.) If one or more specifiers are listed then only tests matching the specifiers are executed. A specifier has the same form as one used for test-skip. A test is executed if it matches any of the specifiers in the test-apply and does not match any active test-skip specifiers.
(srfi 64) syntax (test-with-runner () ((_ runner decl-or-expr ...)) )
runner ⟹ test-runner?
Executes each decl-or-expr in order in a context where the current test-runner is runner.
(srfi 64) procedure (test-result-kind ) ⟹ #f / symbol? /
(srfi 64) procedure (test-result-kind (runner test-runner?) ) ⟹ #f / symbol? /
Return one of the following result codes from the most recent tests:
'pass The test passed, as expected.
'fail The test failed (and was not expected to).
'xfail The test failed and was expected to.
'xpass The test passed, but was expected to fail.
'skip The test was skipped.
Returns #f if no tests have been run yet. If we've started on a new test, but don't have a result yet, then the result kind is 'xfail is the test is expected to fail, 'skip is the test is supposed to be skipped, or #f otherwise.
(srfi 64) procedure (test-passed? ) ⟹ boolean?
(srfi 64) procedure (test-passed? (runner test-runner?) ) ⟹ boolean?
True if the value of (test-result-kind [runner]) is one of 'pass or 'xpass. This is a convenient shorthand that might be useful in a test suite to only run certain tests if the previous test passed.
(srfi 64) procedure (test-result-ref (runner test-runner?) (pname symbol?) ) ⟹ *
(srfi 64) procedure (test-result-ref (runner test-runner?) (pname symbol?) default ) ⟹ *
Returns the property value associated with the pname property name. If there is no value associated with 'pname return default, or #f if default isn't specified.
(srfi 64) procedure (test-result-set! (runner test-runner?) (pname symbol?) value ) ⟹ undefined
Sets the property value associated with the pname property name to value. Usually implementation code should call this function, but it may be useful for a custom test-runner to add extra properties.
(srfi 64) procedure (test-result-remove (runner test-runner?) (pname symbol?) ) ⟹ undefined
Remove the property with the name 'pname.
(srfi 64) procedure (test-result-clear (runner test-runner?) ) ⟹ undefined
Remove all result properties. The implementation automatically calls test-result-clear at the start of a test-assert and similar procedures.
(srfi 64) procedure (test-result-alist (runner test-runner?) ) ⟹ list?
Returns an association list of the current result properties. It is unspecified if the result shares state with the test-runner. The result should not be modified, on the other hand the result may be implicitly modified by future test-result-set! or test-result-remove calls. However, a test-result-clear does not modify the returned alist. Thus you can "archive" result objects from previous runs.
(srfi 64) procedure (test-runner-on-test-begin (runner test-runner?) ) ⟹ procedure?
(return (runner test-runner?) ) ⟹ undefined
(srfi 64) procedure (test-runner-on-test-begin! (runner test-runner?) (on-test-begin procedure?) ) ⟹ undefined
(on-test-begin (runner test-runner?) ) ⟹ undefined
The on-test-begin-function is called at the start of an individual testcase, before the test expression (and expected value) are evaluated.
(srfi 64) procedure (test-runner-on-test-end (runner test-runner?) ) ⟹ procedure?
(return (runner test-runner?) ) ⟹ undefined
(srfi 64) procedure (test-runner-on-test-end! (runner test-runner?) (on-test-end procedure?) ) ⟹ undefined
(on-test-end (runner test-runner?) ) ⟹ undefined
The on-test-end-function is called at the end of an individual testcase, when the result of the test is available.
(srfi 64) procedure (test-runner-on-group-begin (runner test-runner?) ) ⟹ procedure?
(return (runner test-runner?) (suite-name string?) (count integer?) ) ⟹ undefined
(srfi 64) procedure (test-runner-on-group-begin! (runner test-runner?) (on-group-begin procedure?) ) ⟹ undefined
(on-group-begin (runner test-runner?) (suite-name string?) (count integer?) ) ⟹ undefined
The on-group-begin-function is called by a test-begin, including at the start of a test-group. The suite-name is a Scheme string, and count is an integer or #f.
(srfi 64) procedure (test-runner-on-group-end (runner test-runner?) ) ⟹ procedure?
(return (runner test-runner?) ) ⟹ undefined
(srfi 64) procedure (test-runner-on-group-end! (runner test-runner?) (on-group-end procedure?) ) ⟹ undefined
(on-group-end (runner test-runner?) ) ⟹ undefined
The on-group-end-function is called by a test-end, including at the end of a test-group.
(srfi 64) procedure (test-runner-on-bad-count (runner test-runner?) ) ⟹ procedure?
(return (runner test-runner?) (actual-count integer?) (expected-count integer?) ) ⟹ undefined
(srfi 64) procedure (test-runner-on-bad-count! (runner test-runner?) (on-bad-count procedure?) ) ⟹ undefined
(on-bad-count (runner test-runner?) (actual-count integer?) (expected-count integer?) ) ⟹ undefined
Called from test-end (before the on-group-end-function is called) if an expected-count was specified by the matching test-begin and the expected-count does not match the actual-count of tests actually executed or skipped.
(srfi 64) procedure (test-runner-on-bad-end-name (runner test-runner?) ) ⟹ procedure?
(return (runner test-runner?) (begin-name string?) (end-name string?) ) ⟹ undefined
(srfi 64) procedure (test-runner-on-bad-end-name! (runner test-runner?) (on-bad-end-name procedure?) ) ⟹ procedure?
(on-bad-end-name (runner test-runner?) (begin-name string?) (end-name string?) ) ⟹ undefined
Called from test-end (before the on-group-end-function is called) if a suite-name was specified, and it did not that the name in the matching test-begin.
(srfi 64) procedure (test-runner-on-final (runner test-runner?) ) ⟹ procedure?
(return (runner test-runner?) ) ⟹ undefined
(srfi 64) procedure (test-runner-on-final! (runner test-runner?) (on-final procedure?) ) ⟹ undefined
(on-final (runner test-runner?) ) ⟹ undefined
The on-final-function takes one parameter (a test-runner) and typically displays a summary (count) of the tests. The on-final-function is called after called the on-group-end-function correspondiong to the outermost test-end. The default value is test-on-final-simple which writes to the standard output port the number of tests of the various kinds.
(srfi 64) procedure (test-on-test-begin-simple (runner test-runner?) ) ⟹ undefined
(srfi 64) procedure (test-on-test-end-simple (runner test-runner?) ) ⟹ undefined
(srfi 64) procedure (test-on-group-begin-simple (runner test-runner?) (suite-name string?) (count integer?) ) ⟹ undefined
(srfi 64) procedure (test-on-group-end-simple (runner test-runner?) ) ⟹ undefined
(srfi 64) procedure (test-on-bad-count-simple (runner test-runner?) (actual-count integer?) (expected-count integer?) ) ⟹ undefined
(srfi 64) procedure (test-on-bad-end-name-simple (runner test-runner?) (begin-name string?) (end-name string?) ) ⟹ undefined
The callback functions used by the default test-runner returned by test-runner-simple.
(srfi 64) procedure (test-runner-pass-count (runner test-runner?) ) ⟹ integer?
Returns the number of tests that passed, and were expected to pass.
(srfi 64) procedure (test-runner-fail-count (runner test-runner?) ) ⟹ integer?
Returns the number of tests that failed, but were expected to pass.
(srfi 64) procedure (test-runner-xpass-count (runner test-runner?) ) ⟹ integer?
Returns the number of tests that passed, but were expected to fail.
(srfi 64) procedure (test-runner-xfail-count (runner test-runner?) ) ⟹ integer?
Returns the number of tests that failed, and were expected to pass.
(srfi 64) procedure (test-runner-skip-count (runner test-runner?) ) ⟹ integer?
Returns the number of tests or test groups that were skipped.
(srfi 64) procedure (test-runner-test-name (runner test-runner?) ) ⟹ string?
Returns the name of the current test or test group, as a string. During execution of test-begin this is the name of the test group; during the execution of an actual test, this is the name of the test-case. If no name was specified, the name is the empty string.
(srfi 64) procedure (test-runner-group-path (runner test-runner?) ) ⟹ list?
A list of names of groups we're nested in, with the outermost group first.
(srfi 64) procedure (test-runner-group-stack (runner test-runner?) ) ⟹ list?
A list of names of groups we're nested in, with the outermost group last. (This is more efficient than test-runner-group-path, since it doesn't require any copying.)
(srfi 64) procedure (test-runner-aux-value (runner test-runner?) ) ⟹ *
(srfi 64) procedure (test-runner-aux-value! (runner test-runner?) on-test ) ⟹ *
Get or set the aux-value field of a test-runner. This field is not used by this API or the test-runner-simple test-runner, but may be used by custom test-runners to store extra state.
(srfi 64) procedure (test-runner-reset (runner test-runner?) ) ⟹ undefined
Resets the state of the runner to its initial state.
library (srfi 66)
(srfi 66) procedure (u8vector? obj ) ⟹ boolean?
Returns #t if obj is an octect vector, otherwise returns #f. Analogous to vector?.
(srfi 66) procedure (make-u8vector (size integer?) (size integer?) ) ⟹ u8vector?
Returns a newly allocated octet vector of k elements. Each element is initialized to fill. Fill must be an octet. Analogous to make-vector.
(srfi 66) procedure (u8vector (value integer?) ... ) ⟹ u8vector?
Returns a newly allocated octet vector whose elements contain the given arguments, which must all be octets. Analogous to vector.
(srfi 66) procedure (u8vector->list (vec u8vector?) ) ⟹ list?
u8vector->listreturns a newly allocated list of the elements of u8vector in the same order.Analogous to vector->list.
(srfi 66) procedure (list->u8vector (proper-list list?) ) ⟹ u8vector?
List->u8vector returns a newly allocated octet vector whose elements are the elements of list octets, which must all be octets. Analogous to list->vector.
(srfi 66) procedure (u8vector-length (vec u8vector?) ) ⟹ integer?
Returns the number of elements in u8vector as an exact integer. Analogous to vector-length.
(srfi 66) procedure (u8vector-ref (vec u8vector?) (i integer?) ) ⟹ integer?
k must be a valid index of u8vector. u8vector-ref returns the contents of element k of u8vector. Analogous to vector-ref.
(srfi 66) procedure (u8vector-set! (vec u8vector?) (i integer?) (value integer?) ) ⟹ undefined
k must be a valid index of u8vector. u8vector-set! stores octet in element k of u8vector. The number of return values and the return values are unspecified. However, the number of return values is such that it is accepted by a continuation created by begin. Analogous to vector-set!.
(srfi 66) procedure (u8vector=? (vec1 u8vector?) (vec2 u8vector?) ) ⟹ boolean?
Returns #t if u8vector-1 and u8vector-2 are equal---that is, if they have the same length and equal elements at all valid indices.
(srfi 66) procedure (u8vector-compare (vec1 u8vector?) (vec2 u8vector?) ) ⟹ integer?
Compares u8vector-1 and u8vector-2 and returns a value consistent with the vector ordering specified in SRFI 67, i.e. -1 if u8vector-1 is smaller than u8vector-2, 0 if they are equal, and 1 if u8vector-1 is greater than u8vector-2. Shorter vectors are always smaller than longer ones, and vectors of equal length are compared lexicographically.
(srfi 66) procedure (u8vector-copy! (source u8vector?) (source-start integer?) (target u8vector?) (target-start integer?) (n integer?) ) ⟹ undefined
Copies data from octet vector source to octet vector target. Source-start, target-start, and n must be non-negative exact integers that satisfy
0 <= source-start <= source-start + n <= (u8vector-length source)
0 <= target-start <= target-start + n <= (u8vector-length target)
This copies the octets from source at indices [source-start, source-start + n) to consecutive indices in target starting at target-index.
This must work even if the memory regions for the source and the target overlap, i.e., the octets at the target location after the copy must be equal to the octets at the source location before the copy.
The number of return values and the return values are unspecified. However, the number of return values is such that it is accepted by a continuation created by begin. Analogous to vector-ref.
(srfi 66) procedure (u8vector-copy (vec u8vector?) ) ⟹ u8vector?
Returns a newly allocated copy of octet vector u8vector.
library (srfi 67)
(srfi 67) procedure (boolean-compare (bool1 boolean?) (bool2 boolean?) ) ⟹ integer?
Compares two booleans, ordered by #f < #t.
(srfi 67) procedure (char-compare (char1 char?) (char2 char?) ) ⟹ integer?
(srfi 67) procedure (char-compare-ci (char1 char?) (char2 char?) ) ⟹ integer?
Compare characters as char<=? and char-ci<=? respectively. The suffix -ci means "case insensitive."
(srfi 67) procedure (string-compare (string1 string?) (string2 string?) ) ⟹ integer?
(srfi 67) procedure (string-compare-ci (string1 string?) (string2 string?) ) ⟹ integer?
Compare strings as string<= and string-ci<=?. The suffix -ci means "case insensitive."
(srfi 67) procedure (symbol-compare (symbol1 symbol?) (symbol2 symbol?) ) ⟹ integer?
Compares symbols as string<= on the names returned by symbol->string.
(srfi 67) procedure (integer-compare (integer1 integer?) (integer2 integer?) ) ⟹ integer?
(srfi 67) procedure (rational-compare (rational1 rational?) (rational2 rational?) ) ⟹ integer?
(srfi 67) procedure (real-compare (real1 real?) (real2 real?) ) ⟹ integer?
(srfi 67) procedure (complex-compare (complex1 complex?) (complex2 complex?) ) ⟹ integer?
(srfi 67) procedure (number-compare (number1 number?) (number2 number?) ) ⟹ integer?
Compare two numbers. It is an error if an argument is not of the type specified by the name of the procedure.
Complex numbers are ordered lexicographically on pairs (re, im). For objects representing real numbers sign(x - y) is computed. The ordering for values satisfying real? or complex? but not representing a real or complex number should be consistent with procedures = and < of R5RS , and apart from that it is unspecified.
Numerical compare procedures are compatible with the R5RS numerical tower in the following sense: If S is a subtype of the numerical type T and x, y can be represented both in S and in T, then compare-S and compare-T compute the same result.
(srfi 67) procedure (vector-compare (x vector?) (y vector?) ) ⟹ integer?
(srfi 67) procedure (vector-compare (compare procedure?) (x vector?) (y vector?) ) ⟹ integer?
(srfi 67) procedure (vector-compare x y (size procedure?) (ref procedure?) ) ⟹ integer?
(srfi 67) procedure (vector-compare (compare procedure?) x y (size procedure?) (ref procedure?) ) ⟹ integer?
(compare el1 el2 ) ⟹ integer?
(size seq ) ⟹ integer?
(ref seq index ) ⟹ *
(srfi 67) procedure (vector-compare-as-list (x vector?) (y vector?) ) ⟹ integer?
(srfi 67) procedure (vector-compare-as-list (compare procedure?) (x vector?) (y vector?) ) ⟹ integer?
(srfi 67) procedure (vector-compare-as-list x y (size procedure?) (ref procedure?) ) ⟹ integer?
(srfi 67) procedure (vector-compare-as-list (compare procedure?) x y (size procedure?) (ref procedure?) ) ⟹ integer?
(compare el1 el2 ) ⟹ integer?
(size seq ) ⟹ integer?
(ref seq index ) ⟹ *
(srfi 67) procedure (list-compare (x list?) (y list?) ) ⟹ integer?
(srfi 67) procedure (list-compare (compare procedure?) (x list?) (y list?) ) ⟹ integer?
(srfi 67) procedure (list-compare x y (empty? procedure?) (head procedure?) (tail procedure?) ) ⟹ integer?
(srfi 67) procedure (list-compare (compare procedure?) x y (empty? procedure?) (head procedure?) (tail procedure?) ) ⟹ integer?
(compare el1 el2 ) ⟹ integer?
(empty? seq ) ⟹ boolean?
(head seq ) ⟹ *
(tail seq ) ⟹ *
(srfi 67) procedure (list-compare-as-vector (x list?) (y list?) ) ⟹ integer?
(srfi 67) procedure (list-compare-as-vector (compare procedure?) (x list?) (y list?) ) ⟹ integer?
(srfi 67) procedure (list-compare-as-vector x y (empty? procedure?) (head procedure?) (tail procedure?) ) ⟹ integer?
(srfi 67) procedure (list-compare-as-vector (compare procedure?) x y (empty? procedure?) (head procedure?) (tail procedure?) ) ⟹ integer?
(compare el1 el2 ) ⟹ integer?
(empty? seq ) ⟹ boolean?
(head seq ) ⟹ *
(tail seq ) ⟹ *
Compare two sequences x and y, using compare for comparing elements. The result is an exact integer in { - 1, 0, 1}. If compare is not supplied, default-compare is used.
The procedure named access-compare-as-order accesses the objects like access and compares them with respect to the order given by order. The names type-compare are abbreviations for type-compare-as-type.
(srfi 67) procedure (pair-compare-car (compare procedure?) ) ⟹ procedure?
(compare x y ) ⟹ integer?
(return (p1 pair?) (p2 pair?) ) ⟹ integer?
(srfi 67) procedure (pair-compare-cdr (compare procedure?) ) ⟹ procedure?
(compare x y ) ⟹ integer?
(return (p1 pair?) (p2 pair?) ) ⟹ integer?
Construct a compare procedure on pairs which only uses the car (only the cdr, respectively), and ignores the other.
(srfi 67) procedure (pair-compare (compare-car procedure?) (compare-cdr procedure?) (pair1 pair?) (pair2 pair?) ) ⟹ integer?
(srfi 67) procedure (pair-compare obj1 obj2 ) ⟹ integer?
(srfi 67) procedure (pair-compare (compare procedure?) obj1 obj2 ) ⟹ integer?
(compare x y ) ⟹ integer?
The 4-ary form compares two pairs pair1 pair2 by comparing their cars using compare-car, and if the cars are equal the cdrs are compared using compare-cdr.
The 3-ary form compares two objects by type using the ordering of types
null < pair < neither-null-nor-pair.
Two objects of type neither-null-nor-pair are compared using compare. Two pairs are compared by using compare on the cars, and if the cars are equal by recursing on the cdrs.
The 2-ary form uses default-compare for compare.
(srfi 67) procedure (default-compare obj1 obj2 ) ⟹ integer?
compares its arguments by type using the ordering
null < pair < boolean < char < string < symbol < number < vector < other
Two objects of the same type type are compared as type-compare would, if there is such a procedure. The type null consists of the empty list '(). The effect of comparing two other objects or of comparing cyclic structures (made from lists or vectors) is unspecified. (Implementations are encouraged to add comparisons for other built-in types, e.g. records, regexps, etc.)
(srfi 67) syntax (refine-compare () ((_ compare-expression ...) integer? ) )
compare-expression ⟹ integer?
The arguments <compare-expression> ...are evaluated from left to right until a non-zero value is found (which then is the value) or until there are no more arguments to evaluate (in which case the value is 0). It is allowed that there are no arguments at all.
(srfi 67) syntax (select-compare (else ) ((_ x y (type? c1 ...) ...) integer? ) ((_ x y (type? c1 ...) ... (else c1 ...)) integer? ) )
c ⟹ integer?
type? ⟹ procedure?
Select-compare is a conditional for defining hierarchical extensions and refinements of compare procedures (refer to Section 5). It compares the values of <x1> and <x2> by trying the type tests in order, and applies an implict refine-compare on the consequences upon a match.
In more detail, evaluation proceeds as follows: First <x1> and <x2> are evaluated in unspecified order, resulting in values x1 and x2, respectively. Then the clauses are evaluated one by one, from left to right.
For clause (<type?> <c1> ...), first <type?> is evaluated resulting in a predicate procedure type? and then the expressions (type? x1) and (type? x2) are evaluated and interpreted as booleans. If both booleans are true then the overall value is (refine-compare <c1> ...). If only the first is true the result is -1, if only the second is true the result is 1, and if neither is true the next clause is considered. An else clause is treated as if both tests where true. If there are no clauses left, the result is 0.
Select-compare evaluates <x1> and <x2> exactly once, even in the absence of any clauses. Moreover, each <type?> is evaluated at most once and the resulting procedure type? is called at most twice.
(srfi 67) syntax (cond-compare (else ) ((_ x y ((t1 t2) c1 ...) ...) integer? ) ((_ x y ((t1 t2) c1 ...) ... (else c1 ...)) integer? ) )
t ⟹ boolean?
c ⟹ integer?
type? ⟹ procedure?
Cond-compare is another conditional for defining hierarchical extensions and refinements of compare procedures (refer to Section 5).
Evaluation proceeds as follows: The clauses are evaluated one by one, from left to right. For clause ((<t1> <t2>) <c1> ...), first <t1> and <t2> are evaluated and the results are interpreted as boolean values. If both booleans are true then the overall value is (refine-compare <c1> ...). If only the first is true the result is -1, if only the second is true the result is 1, and if neither is true the next clause is considered. An else clause is treated as if both booleans where true. If there are no clauses left (or there are no clauses to begin with), the result is 0.
Cond-compare evaluates each expression at most once.
(srfi 67) syntax (if3 () ((_ c less equal greater)) )
c ⟹ integer?
If3 is the 3-way conditional for comparisons. First <c> is evaluated, resulting in value c. The value c must be an exact integer in { - 1, 0, 1}, otherwise an error is signalled. If c = - 1 then the value of the if3-expression is obtained by evaluating <less>. If c = 0 then <equal> is evaluated. If c = 1 then <greater> is evaluated.
(srfi 67) syntax (if=? () ((_ c consequent)) ((_ c consequent alternate)) )
c ⟹ integer?
(srfi 67) syntax (if<? () ((_ c consequent)) ((_ c consequent alternate)) )
c ⟹ integer?
(srfi 67) syntax (if>? () ((_ c consequent)) ((_ c consequent alternate)) )
c ⟹ integer?
(srfi 67) syntax (if<=? () ((_ c consequent)) ((_ c consequent alternate)) )
c ⟹ integer?
(srfi 67) syntax (if>=? () ((_ c consequent)) ((_ c consequent alternate)) )
c ⟹ integer?
(srfi 67) syntax (if-not=? () ((_ c consequent)) ((_ c consequent alternate)) )
c ⟹ integer?
These six macros are 2-way conditionals for comparisons. First <c> is evaluated, resulting in value c. The value c must be an exact integer in { - 1, 0, 1}, otherwise an error is signalled. Then, depending on the value of c and the name of the macro, either <consequence> or <alternate> is evaluated, and the resulting value is the value of the conditional expression.
The branch is chosen according to the following table:
<consequent> <alternate>
if=? c = 0 c: { - 1, 1}
if<? c = -1 c: {0, 1}
if>? c = 1 c: { - 1, 0}
if<=? c: { - 1, 0} c = 1
if>=? c: {0, 1} c = -1
if-not=? c: { - 1, 1} c = 0
Note: The macros if<=? etc. are the preferred way of 2-way branching based on the result of a comparison.
(srfi 67) procedure (=? ) ⟹ procedure?
(srfi 67) procedure (=? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (=? x y ) ⟹ boolean?
(srfi 67) procedure (=? (compare procedure?) x y ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (<? ) ⟹ procedure?
(srfi 67) procedure (<? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (<? x y ) ⟹ boolean?
(srfi 67) procedure (<? (compare procedure?) x y ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (>? ) ⟹ procedure?
(srfi 67) procedure (>? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (>? x y ) ⟹ boolean?
(srfi 67) procedure (>? (compare procedure?) x y ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (<=? ) ⟹ procedure?
(srfi 67) procedure (<=? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (<=? x y ) ⟹ boolean?
(srfi 67) procedure (<=? (compare procedure?) x y ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (>=? ) ⟹ procedure?
(srfi 67) procedure (>=? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (>=? x y ) ⟹ boolean?
(srfi 67) procedure (>=? (compare procedure?) x y ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (not=? ) ⟹ procedure?
(srfi 67) procedure (not=? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (not=? x y ) ⟹ boolean?
(srfi 67) procedure (not=? (compare procedure?) x y ) ⟹ boolean?
(compare x y ) ⟹ integer?
If the values x and y are given, test if x and y are in the relation specified by the name of the procedure rel?, with respect to compare procedure compare; otherwise construct a predicate procedure.
In the forms (rel? [ compare ] x y), the result is a boolean (either #t or #f) depending on (compare x y) and the test rel? as specified for if<? etc. If compare is not supplied, default-compare is used.
In the form (rel? [ compare ]), the predicate procedure (lambda (x y) (rel? compare x y)) is constructed. Again, if compare is not supplied, default-compare is used.
(srfi 67) procedure (</<? ) ⟹ procedure?
(srfi 67) procedure (</<? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (</<? x y z ) ⟹ boolean?
(srfi 67) procedure (</<? (compare procedure?) x y z ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (</<=? ) ⟹ procedure?
(srfi 67) procedure (</<=? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (</<=? x y z ) ⟹ boolean?
(srfi 67) procedure (</<=? (compare procedure?) x y z ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (<=/<? ) ⟹ procedure?
(srfi 67) procedure (<=/<? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (<=/<? x y z ) ⟹ boolean?
(srfi 67) procedure (<=/<? (compare procedure?) x y z ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (<=/<=? ) ⟹ procedure?
(srfi 67) procedure (<=/<=? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (<=/<=? x y z ) ⟹ boolean?
(srfi 67) procedure (<=/<=? (compare procedure?) x y z ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (>/>? ) ⟹ procedure?
(srfi 67) procedure (>/>? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (>/>? x y z ) ⟹ boolean?
(srfi 67) procedure (>/>? (compare procedure?) x y z ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (>/>=? ) ⟹ procedure?
(srfi 67) procedure (>/>=? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (>/>=? x y z ) ⟹ boolean?
(srfi 67) procedure (>/>=? (compare procedure?) x y z ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (>=/>? ) ⟹ procedure?
(srfi 67) procedure (>=/>? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (>=/>? x y z ) ⟹ boolean?
(srfi 67) procedure (>=/>? (compare procedure?) x y z ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (>=/>=? ) ⟹ procedure?
(srfi 67) procedure (>=/>=? (compare procedure?) ) ⟹ procedure?
(srfi 67) procedure (>=/>=? x y z ) ⟹ boolean?
(srfi 67) procedure (>=/>=? (compare procedure?) x y z ) ⟹ boolean?
(compare x y ) ⟹ integer?
Test if x, y, and z form a chain with the two relations specified by the name of the procedure rel1/rel2?, with respect to the compare procedure compare.
If compare is not provided, default-compare is used. If x y z are not provided, a predicate procedure of three arguments is constructed. The order in which the values are compared is unspecified, but each value is compared at least once.
(srfi 67) procedure (chain=? (compare procedure?) x1 ... ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (chain<? (compare procedure?) x1 ... ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (chain>? (compare procedure?) x1 ... ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (chain<=? (compare procedure?) x1 ... ) ⟹ boolean?
(compare x y ) ⟹ integer?
(srfi 67) procedure (chain>=? (compare procedure?) x1 ... ) ⟹ boolean?
(compare x y ) ⟹ integer?
Test if the values x1 ...(zero or more values) form a chain with respect to the relation specified by the name of the procedure, and with respect to the compare procedure compare. The result is a boolean (either #t or #f.) The order in which the values are compared is unspecified, but each value is compared at least once (even if there is just one.)
A sequence of values x1, ..., xn forms a chain with respect to the relation rel? if (rel? compare xi xj) for all 1 <= i < j <= n. In particular, this is the case for n: {0,1}.
Since the relations = , <, >, <=, and >= are transitive, it is sufficient to test (rel? compare xi xi+1) for 1 < i < n.
(srfi 67) procedure (pairwise-not=? (compare procedure?) x1 ... ) ⟹ boolean?
(compare x y ) ⟹ integer?
Tests if the values x1 ...(zero or more values) are pairwise unequal with respect to the compare procedure compare. The result is a boolean (either #t or #f). The order in which the values are compared is unspecified, but each value is compared at least once (even if there is just one).
The values x1, ..., xn are pairwise unequal if (not=? compare xi xj) for all i != j. In particular, this is the case for n: {0,1}.
Since compare defines a total ordering on the values, the property can be checked in time O(n log n), and implementations are required to do this. (For example by first sorting and then comparing adjacent elements).
(srfi 67) procedure (min-compare (compare procedure?) x1 x2 ... ) ⟹ *
(compare x y ) ⟹ integer?
(srfi 67) procedure (max-compare (compare procedure?) x1 x2 ... ) ⟹ *
(compare x y ) ⟹ integer?
A minimum or maximum of the values x1 x2 ...(one or more values) with respect to the compare procedure compare.
The result is the first value that is minimal (maximal, respectively). The order in which the values are compared is unspecified, but each value is compared at least once (even if there is just one value).
(srfi 67) procedure (kth-largest (compare procedure?) (k integer?) x1 x2 ... ) ⟹ *
(compare x y ) ⟹ integer?
The k-th largest element of values x0 x1 ...(one or more values) with respect to the compare procedure compare.
More precisely, (kth-largest compare k x0 ... xn-1) returns the (modulo k n)-th element of the unique sequence obtained by stably sorting (x0 ··· xn-1). (Recall that a sorting algorithm is stable if it does not permute items with equal key, i.e. equivalent w.r.t. compare).
The argument k is an exact integer, and n >= 1. The order in which the values xi are compared is unspecified, but each value is compared at least once (even if there is just one value).
(srfi 67) procedure (compare-by< (lt-pred procedure?) ) ⟹ procedure?
(srfi 67) procedure (compare-by< (lt-pred procedure?) x y ) ⟹ integer?
(lt-pred x y ) ⟹ boolean?
(srfi 67) procedure (compare-by> (gt-pred procedure?) ) ⟹ procedure?
(srfi 67) procedure (compare-by> (gt-pred procedure?) x y ) ⟹ integer?
(gt-pred x y ) ⟹ boolean?
(srfi 67) procedure (compare-by<= (le-pred procedure?) ) ⟹ procedure?
(srfi 67) procedure (compare-by<= (le-pred procedure?) x y ) ⟹ integer?
(le-pred x y ) ⟹ boolean?
(srfi 67) procedure (compare-by>= (ge-pred procedure?) ) ⟹ procedure?
(srfi 67) procedure (compare-by>= (ge-pred procedure?) x y ) ⟹ integer?
(ge-pred x y ) ⟹ boolean?
(srfi 67) procedure (compare-by=/< (eq-pred procedure?) (lt-pred procedure?) ) ⟹ procedure?
(srfi 67) procedure (compare-by=/< (eq-pred procedure?) (lt-pred procedure?) x y ) ⟹ integer?
(eq-pred x y ) ⟹ boolean?
(lt-pred x y ) ⟹ boolean?
(srfi 67) procedure (compare-by=/> (eq-pred procedure?) (gt-pred procedure?) ) ⟹ procedure?
(eq-pred x y ) ⟹ boolean?
(gt-pred x y ) ⟹ boolean?
(return x y ) ⟹ integer?
(srfi 67) procedure (compare-by=/< (eq-pred procedure?) (gt-pred procedure?) x y ) ⟹ integer?
(eq-pred x y ) ⟹ boolean?
(gt-pred x y ) ⟹ boolean?
If optional arguments x and y are present then these are compared with respect to the total order defined by the predicate(s) given; the result is in { -1, 0, 1 }. If x and y are not present then a procedure comparing its two arguments using the predicate(s) given is constructed and returned.
The predicate procedures mean the following: (lt-pred x y) tests if x < y, le-pred tests for <=, gt-pred for >, ge-pred for >=, and eq-pred tests if x and y are equivalent. The result returned by a predicate procedure is interpreted as a Scheme truth value (i.e. #f is false and non-#f is true).
The purpose of the procedures compare-bypredicate(s) is to define a compare procedure from an order predicate, and possibly an additional equivalence predicate. If an equivalence predicate eq-pred is given, it is called before the order predicate because the equivalence may be coarser than the total ordering, and it may also be cheaper.
(srfi 67) procedure (debug-compare (compare procedure?) ) ⟹ procedure?
(compare x y ) ⟹ integer?
(return x y ) ⟹ integer?
Constructs a compare procedure equivalent to compare but with debugging code wrapped around the calls to compare. The debugging code signals an error if it detects a violation of the axioms of a compare function. For this it is assumed that compare has no side-effects.
More specifically, (debug-compare compare) evaluates to a compare procedure compare1 which checks reflexivity, antisymmetry, and transitivity of compare based on the arguments on which compare1 is called:
The procedure compare1 checks reflexivity on any value passed to compare, antisymmetry on any pair of values on which compare is called, and transitivity on triples where two of the arguments are from the current call to compare1 and the third is a pseudo-random selection from the two arguments of the previous call to compare1.
library (srfi 69)
(srfi 69) procedure (make-hash-table (equality-predicate procedure?) arg ... ) ⟹ hash-table?
(srfi 69) procedure (make-hash-table (equality-predicate procedure?) (hash-function procedure?) arg ... ) ⟹ hash-table?
(equality-predicate a b ) ⟹ boolean?
(hash-function obj ) ⟹ integer?
Create a new hash table with no associations. equal? is a predicate that should accept two keys and return a boolean telling whether they denote the same key value; it defaults to equal?.
hash is a hash function, and defaults to an appropriate hash function for the given equal? predicate (see section Hashing). However, an acceptable default is not guaranteed to be given for any equivalence predicate coarser than equal?, except for string-ci=?.[1] The function hash must be acceptable for equal?, so if you use coarser equivalence than equal? other than string-ci=?, you must always provide the function hash yourself.
[1] An equivalence predicate c1 is coarser than a equivalence predicate c2 iff there exist values x and y such that (and (c1 x y) (not (c2 x y))).
(srfi 69) procedure (hash-table? obj ) ⟹ boolean?
A predicate to test whether a given object obj is a hash table. The hash table type should be disjoint from all other types, if possible.
(srfi 69) procedure (alist->hash-table (alist list?) (comparator comparator?) arg ... ) ⟹ hash-table?
alist ⟹ (alist key : value )
Takes an "association list" alist and creates a hash table hash-table which maps the car of every element in alist to the cdr of corresponding elements in alist. equal?, hash, and args are interpreted as in make-hash-table. If some key occurs multiple times in alist, the value in the first association will take precedence over later ones. (Note: the choice of using cdr (instead of cadr) for values tries to strike balance between the two approaches: using cadr would render this procedure unusable for cdr alists, but not vice versa.)
(srfi 69) procedure (hash-table-equivalence-function (hash-table hash-table?) ) ⟹ procedure?
(return a b ) ⟹ boolean?
Returns the equivalence predicate used for keys of hash-table.
(srfi 69) procedure (hash-table-hash-function (hash-table hash-table?) ) ⟹ procedure?
(return obj ) ⟹ integer?
Returns the hash function used for keys of hash-table.
(srfi 69) procedure (hash-table-ref (hash-table hash-table?) key ) ⟹ *
(srfi 69) procedure (hash-table-ref (hash-table hash-table?) key (failure procedure?) ) ⟹ *
(failure ) ⟹ *
This procedure returns the value associated to key in hash-table. If no value is associated to key and thunk is given, it is called with no arguments and its value is returned; if thunk is not given, an error is signalled. Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table. (Note: this rules out implementation by association lists or fixed-length hash tables.)
(srfi 69) procedure (hash-table-ref/default (hash-table hash-table?) key default ) ⟹ *
Evaluates to the same value as (hash-table-ref hash-table key (lambda () default)). Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table. (Note: this rules out implementation by association lists or fixed-length hash tables.)
(srfi 69) procedure (hash-table-set! (hash-table hash-table?) key1 value1 ... ) ⟹ undefined
This procedure sets the value associated to key in hash-table. The previous association (if any) is removed. Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table. (Note: this rules out implementation by association lists or fixed-length hash tables.)
(srfi 69) procedure (hash-table-delete! (hash-table hash-table?) key ... ) ⟹ undefined
This procedure removes any association to key in hash-table. It is not an error if no association for that key exists; in this case, nothing is done. Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table. (Note: this rules out implementation by association lists or fixed-length hash tables.)
(srfi 69) procedure (hash-table-exists? (hash-table hash-table?) key ) ⟹ boolean?
This predicate tells whether there is any association to key in hash-table. Given a good hash function, this operation should have an (amortised) complexity of O(1) with respect to the number of associations in hash-table. (Note: this rules out implementation by association lists or fixed-length hash tables.)
(srfi 69) procedure (hash-table-update! (hash-table hash-table?) key (updater procedure?) ) ⟹ undefined
(srfi 69) procedure (hash-table-update! (hash-table hash-table?) key (updater procedure?) (failure procedure?) ) ⟹ undefined
(updater value ) ⟹ *
(failure ) ⟹ *
Semantically equivalent to, but may be implemented more efficiently than, the following code:
(hash-table-set! hash-table key
(updater (hash-table-ref hash-table key thunk)))
(srfi 69) procedure (hash-table-update!/default (hash-table hash-table?) key (updater procedure?) default ) ⟹ undefined
(updater value ) ⟹ *
(failure ) ⟹ *
Behaves as if it evaluates to (hash-table-update! hash-table key updater (lambda () default))
(srfi 69) procedure (hash-table-size (hash-table hash-table?) ) ⟹ integer?
Returns the number of associations in hash-table. This operation must have a complexity of O(1) with respect to the number of associations in hash-table.
(srfi 69) procedure (hash-table-keys (hash-table hash-table?) ) ⟹ list?
Returns a list of keys in hash-table. The order of the keys is unspecified.
(srfi 69) procedure (hash-table-values (hash-table hash-table?) ) ⟹ list?
Returns a list of values in hash-table. The order of the values is unspecified, and is not guaranteed to match the order of keys in the result of hash-table-keys.
(srfi 69) procedure (hash-table-walk (hash-table hash-table?) (proc procedure?) ) ⟹ undefined
(proc key value ) ⟹ undefined
proc should be a function taking two arguments, a key and a value. This procedure calls proc for each association in hash-table, giving the key of the association as key and the value of the association as value. The results of proc are discarded. The order in which proc is called for the different associations is unspecified.
(Note: in some implementations, there is a procedure called hash-table-map which does the same as this procedure. However, in other implementations, hash-table-map does something else. In no implementation that I know of, hash-table-map does a real functorial map that lifts an ordinary function to the domain of hash tables. Because of these reasons, hash-table-map is left outside this SRFI.)
(srfi 69) procedure (hash-table-fold (hash-table hash-table?) (f procedure?) seed ) ⟹ *
(f key value state ) ⟹ *
This procedure calls f for every association in hash-table with three arguments: the key of the association key, the value of the association value, and an "accumulated value", val. val is init-value for the first invocation of f, and for subsequent invocations of f, the return value of the previous invocation of f. The value final-value returned by hash-table-fold is the return value of the last invocation of f. The order in which f is called for different associations is unspecified.
(srfi 69) procedure (hash-table->alist (hash-table hash-table?) ) ⟹ list?
return ⟹ (alist key : value )
Returns an association list such that the car of each element in alist is a key in hash-table and the corresponding cdr of each element in alist is the value associated to the key in hash-table. The order of the elements is unspecified.
(srfi 69) procedure (hash-table-copy (hash-table hash-table?) ) ⟹ hash-table?
Returns a new hash table with the same equivalence predicate, hash function and mappings as in hash-table.
(srfi 69) procedure (hash-table-merge! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Adds all mappings in hash-table2 into hash-table1 and returns the resulting hash table. This function may modify hash-table1 destructively.
(srfi 69) procedure (hash obj ) ⟹ integer?
(srfi 69) procedure (hash obj arg ) ⟹ integer?
Produces a hash value for object in the range ( 0, bound (. If bound is not given, the implementation is free to choose any bound, given that the default bound is greater than the size of any imaginable hash table in a normal application. (This is so that the implementation may choose some very big value in fixnum range for the default bound.) This hash function is acceptable for equal?.
(srfi 69) procedure (string-hash (str string?) ) ⟹ integer?
(srfi 69) procedure (string-hash (str string?) arg ) ⟹ integer?
The same as hash, except that the argument string must be a string.
(srfi 69) procedure (string-ci-hash (str string?) ) ⟹ integer?
(srfi 69) procedure (string-ci-hash (str string?) arg ) ⟹ integer?
The same as string-hash, except that the case of characters in string does not affect the hash value produced.
(srfi 69) procedure (hash-by-identity obj ) ⟹ integer?
(srfi 69) procedure (hash-by-identity obj arg ) ⟹ integer?
The same as hash, except that this function is only guaranteed to be acceptable for eq?. The reason for providing this function is that it might be implemented significantly more efficiently than hash. Implementations are encouraged to provide this function as a builtin.
library (srfi 70)
(srfi 70) procedure (exact-floor (x real?) ) ⟹ integer?
(srfi 70) procedure (exact-ceiling (x real?) ) ⟹ integer?
(srfi 70) procedure (exact-truncate (x real?) ) ⟹ integer?
(srfi 70) procedure (exact-round (x real?) ) ⟹ integer?
These procedures are the compositions of `inexact->exact' with `floor', `ceiling', `truncate', and `round'.
library (srfi 71)
(srfi 71) syntax (let (values ) ((_ (binding-spec ...) body)) ((_ name (binding-spec ...) body)) )
(var1 var2 ... expression) ((values var ...) expression) ((values var ... . var-rest) expression)
(srfi 71) syntax (let* (values ) ((_ (binding-spec ...) body)) )
(var1 var2 ... expression) ((values var ...) expression) ((values var ... . var-rest) expression)
(srfi 71) syntax (letrec (values ) ((_ (binding-spec ...) body)) )
(var1 var2 ... expression) ((values var ...) expression) ((values var ... . var-rest) expression)
The syntax of Scheme (R5RS, Section 7.1.3.) is extended by replacing the existing production:
<binding spec> --> (<variable> <expression>)
by the three new productions
<binding spec> --> ((values <variable>*) <expression>)
<binding spec> --> ((values <variable>* . <variable>) <expression>)
<binding spec> --> (<variable>+ <expression>)
The form (<variable>+ <expression>) is just an abbreviation for ((values <variable>+) <expression>), and it includes the original <binding spec> of R5RS.
The first two forms are evaluated as follows: The variables are bound and the expression is evaluated according to the enclosing construct (either let, let*, or letrec.) However, the expression may deliver any number of values to its continuation, which stores these values into the variables specified, possibly allocating a rest list in case of the . <variable> form.
The number of values delivered by the expression must match the number of values expected by the binding specification. Otherwise an error is raised, as call-with-values would. This implies in particular, that each binding of a named let involves exactly one value, because this binding can also be an argument to a lambda-expression.
(srfi 71) procedure (uncons (pair pair?) ) ⟹ (values **)
(srfi 71) procedure (uncons-2 (lst list?) ) ⟹ (values ***)
(srfi 71) procedure (uncons-3 (lst list?) ) ⟹ (values ****)
(srfi 71) procedure (uncons-4 (lst list?) ) ⟹ (values *****)
(srfi 71) procedure (uncons-cons (alist list?) ) ⟹ (values ***)
(srfi 71) procedure (unlist (lst list?) ) ⟹ (values *...)
(srfi 71) procedure (unvector (vec vector?) ) ⟹ (values *...)
The following procedures, specified in terms of standard procedures, are added to the set of standard procedures:
(define (uncons pair)
(values (car pair) (cdr pair)))
(define (uncons-2 list)
(values (car list) (cadr list) (cddr list)))
(define (uncons-3 list)
(values (car list) (cadr list) (caddr list) (cdddr list)))
(define (uncons-4 list)
(values (car list) (cadr list) (caddr list) (cadddr list) (cddddr list)))
(define (uncons-cons alist)
(values (caar alist) (cdar alist) (cdr alist)))
(define (unlist list)
(apply values list))
(define (unvector vector)
(apply values (vector->list vector)))
These procedures decompose the standard concrete data structures (pair, list, vector) and deliver the components as values. It is an error if the argument cannot be decomposed as expected. Note that the procedures are not necessarily implemented by the definition given above.
The preferred way of decomposing a list into the first two elements and the rest list is (let ((x1 x2 x3+ (uncons-2 x))) body), and similar for three or four elements and a rest. This is not equivalent to (let (((values x1 x2 . x3+) (unlist x))) body) because the latter binds x3+ to a newly allocated copy of (cddr x).
(srfi 71) syntax (values->list () ((_ expression) list? ) )
(srfi 71) syntax (values->vector () ((_ expression) vector? ) )
These operation receive all values (if any) delivered by their argument expression and return a newly allocated list (vector, resp.) of these values. Note that values->list is not the same as list (the procedure returning the list of its arguments).
library (srfi 74)
(srfi 74) syntax (endianness (big little native ) ((_ big) endianness ) ((_ little) endianness ) ((_ native) endianness ) )
(endianness big) and (endianness little) evaluate to two distinct and unique objects representing an endianness. The native endianness evaluates to the endianness of the underlying machine architecture, and must be eq? to either (endianness big) or (endianness little).
(srfi 74) procedure (blob? obj ) ⟹ boolean?
Returns #t if obj is a blob, otherwise returns #f.
(srfi 74) procedure (make-blob (octet-count integer?) ) ⟹ blob?
Returns a newly allocated blob of k octets, all of them 0.
(srfi 74) procedure (blob-length (blob blob?) ) ⟹ integer?
Returns the number of octets in blob as an exact integer.
(srfi 74) procedure (blob-u8-ref (blob blob?) (k integer?) ) ⟹ integer?
Blob-u8-ref returns the octet at index k of blob.
(srfi 74) procedure (blob-s8-ref (blob blob?) (k integer?) ) ⟹ integer?
Blob-s8-ref returns the exact integer corresponding to the two's complement representation at index k of blob.
(srfi 74) procedure (blob-u8-set! (blob blob?) (k integer?) (octet integer?) ) ⟹ undefined
Blob-u8-set! stores octet in element k of blob.
(srfi 74) procedure (blob-s8-set! (blob blob?) (k integer?) (byte integer?) ) ⟹ undefined
Blob-u8-set! stores the two's complement representation of byte in element k of blob.
(srfi 74) procedure (blob-uint-ref (size integer?) (endianness endianness) (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-sint-ref (size integer?) (endianness endianness) (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-uint-set! (size integer?) (endianness endianness) (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-sint-set! (size integer?) (endianness endianness) (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
Size must be a positive exact integer. K must be a valid index of blob; so must the indices {k, ..., k + size - 1}. Endianness must be an endianness object.
Blob-uint-ref retrieves the exact integer corresponding to the unsigned representation of size size and specified by endianness at indices {k, ..., k + size - 1}.
Blob-sint-ref retrieves the exact integer corresponding to the two's complement representation of size size and specified by endianness at indices {k, ..., k + size - 1}.
For blob-uint-set!, n must be an exact integer in the interval [0, (256^size)-1]. Blob-uint-set! stores the unsigned representation of size size and specified by endianness into the blob at indices {k, ..., k + size - 1}.
For blob-uint-set!, n must be an exact integer in the interval [-256^(size-1), (256^(size-1))-1]. Blob-sint-set! stores the two's complement representation of size size and specified by endianness into the blob at indices {k, ..., k + size - 1}.
(srfi 74) procedure (blob-u16-ref (endianness endianness) (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-s16-ref (endianness endianness) (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-u16-native-ref (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-s16-native-ref (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-u16-set! (endianness endianness) (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-s16-set! (endianness endianness) (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-u16-native-set! (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-s16-native-set! (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
K must be a valid index of blob; so must the index k+ 1. Endianness must be an endianness object.
These retrieve and set two-octet representations of numbers at indices k and k+1, according to the endianness specified by endianness. The procedures with u16 in their names deal with the unsigned representation, those with s16 with the two's complement representation.
The procedures with native in their names employ the native endianness, and only work at aligned indices: k must be a multiple of 2. It is an error to use them at non-aligned indices.
(srfi 74) procedure (blob-u32-ref (endianness endianness) (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-s32-ref (endianness endianness) (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-u32-native-ref (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-s32-native-ref (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-u32-set! (endianness endianness) (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-s32-set! (endianness endianness) (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-u32-native-set! (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-s32-native-set! (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
K must be a valid index of blob; so must the indices {k, ..., k+ 3}. Endianness must be an endianness object.
These retrieve and set four-octet representations of numbers at indices {k, ..., k+ 3}, according to the endianness specified by endianness. The procedures with u32 in their names deal with the unsigned representation, those with s32 with the two's complement representation.
The procedures with native in their names employ the native endianness, and only work at aligned indices: k must be a multiple of 4. It is an error to use them at non-aligned indices.
(srfi 74) procedure (blob-u64-ref (endianness endianness) (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-s64-ref (endianness endianness) (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-u64-native-ref (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-s64-native-ref (blob blob?) (k integer?) ) ⟹ integer?
(srfi 74) procedure (blob-u64-set! (endianness endianness) (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-s64-set! (endianness endianness) (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-u64-native-set! (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
(srfi 74) procedure (blob-s64-native-set! (blob blob?) (k integer?) (value integer?) ) ⟹ undefined
K must be a valid index of blob; so must the indices {k, ..., k+ 7}. Endianness must be an endianness object.
These retrieve and set eight-octet representations of numbers at indices {k, ..., k+ 7}, according to the endianness specified by endianness. The procedures with u64 in their names deal with the unsigned representation, those with s64 with the two's complement representation.
The procedures with native in their names employ the native endianness, and only work at aligned indices: k must be a multiple of 8. It is an error to use them at non-aligned indices.
(srfi 74) procedure (blob=? (blob1 blob?) (blob2 blob?) ) ⟹ boolean?
Returns #t if blob-1 and blob-2 are equal---that is, if they have the same length and equal octets at all valid indices.
(srfi 74) procedure (blob-copy! (source blob?) (source-start integer?) (target blob?) (target-start integer?) (n integer?) ) ⟹ boolean?
Copies data from blob source to blob target. Source-start, target-start, and n must be non-negative exact integers that satisfy
0 <= source-start <= source-start + n <= (blob-length source)
0 <= target-start <= target-start + n <= (blob-length target)
This copies the octets from source at indices [source-start, source-start + n) to consecutive indices in target starting at target-index.
This must work even if the memory regions for the source and the target overlap, i.e., the octets at the target location after the copy must be equal to the octets at the source location before the copy.
The return values are unspecified.
(srfi 74) procedure (blob-copy (blob blob?) ) ⟹ blob?
Returns a newly allocated copy of blob blob.
(srfi 74) procedure (blob->u8-list (blob blob?) ) ⟹ list?
blob->u8-list returns a newly allocated list of the octets of blob in the same order.
(srfi 74) procedure (u8-list->blob (octets list?) ) ⟹ blob?
u8-list->blob returns a newly allocated blob whose elements are the elements of list octets, which must all be octets, in the same order. Analogous to list->vector.
(srfi 74) procedure (blob->uint-list (size integer?) (endianness endianness) (blob blob?) ) ⟹ list?
(srfi 74) procedure (blob->sint-list (size integer?) (endianness endianness) (blob blob?) ) ⟹ list?
(srfi 74) procedure (uint-list->blob (size integer?) (endianness endianness) (list list?) ) ⟹ blob?
(srfi 74) procedure (sint-list->blob (size integer?) (endianness endianness) (list list?) ) ⟹ blob?
Size must be a positive exact integer. Endianness must be an endianness object.
These convert between lists of integers and their consecutive representations according to size and endianness in blobs in the same way as blob->u8-list, blob->s8-list, u8-list->blob, and s8-list->blob do for one-octet representations.
library (srfi 78)
(srfi 78) syntax (check (=> ) ((_ expr (=> equal) expected)) ((_ expr => expected)) )
equal ⟹ procedure?
Evaluates <expr> and compares the value to the value of <expected> using the predicate <equal>, which is equal? when omitted. Then a report is printed according to the current mode setting (see below) and the outcome is recorded in a global state to be used in check-report. The precise order of evaluation is that first <equal> and <expected> are evaluated (in unspecified order) and then <expr> is evaluated.
(srfi 78) syntax (check-ec (=> ) ((_ qualifier ... expr (=> equal) expected (argument ...))) ((_ qualifier ... expr => expected (argument ...))) ((_ qualifier ... expr (=> equal) expected)) ((_ qualifier ... expr => expected)) )
generator (if test) (not test) (and test ...) (or test ...) (begin command ... expression) (nested qualifier ...)
equal ⟹ procedure?
generator ⟹ generator-macro
An eager comprehension for executing a parametric sequence of checks.
Enumerates the sequence of bindings specified by <qualifier>*. For each binding evaluates <equal> and <expected> in unspecified order. Then evalues <expr> and compares the value obtained to the value of <expected> using the value of <equal> as predicate, which is equal? when omitted. The comprehension stops after the first failed check, if there is any. Then a report is printed according to the current mode setting (see below) and the outcome is recorded in a global state to be used in check-report. The entire check-ec counts as a single check.
In case the check fails <argument>* is used for constructing an informative message with the argument values. Use <argument>* to list the relevant free variables of <expr> (see examples) that you want to have printed.
A <qualifier> is any qualifier of an eager comprehension as specified in SRFI 42
(srfi 78) procedure (check-report ) ⟹ undefined
Prints a summary and the first failed check, if there is any, depending on the current mode settings.
(srfi 78) procedure (check-set-mode! (mode symbol?) ) ⟹ undefined
Sets the current mode to mode, which must be a symbol in '(off summary report-failed report), default is 'report. Note that you can change the mode at any time, and that check, check-ec and check-report use the current value.
The mode symbols have the following meaning:
off: do not execute any of the checks,
summary: print only summary in (check-report) and nothing else,
report-failed: report failed checks when they happen, and in summary,
report: report every example executed.
(srfi 78) procedure (check-reset! ) ⟹ undefined
Resets the global state (counters of correct/failed examples) to the state immediately after loading the module for the first time, i.e. no checks have been executed.
(srfi 78) procedure (check-passed? (expected-total-count integer?) ) ⟹ boolean?
#t if there were no failed checks and expected-total-count correct checks, #f otherwise.
Rationale: This procedure can be used in automatized tests by terminating a test program with the statement (exit (if (check-passed? n) 0 1)).
library (srfi 87)
(srfi 87) 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 equivalent (in the sense of `eqv?'; see section see section 6.1 Equivalence predicates) 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. 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 <Key> and the value(s) returned by this procedure is(are) returned by the `case' expression.
library (srfi 88)
(srfi 88) procedure (keyword? obj ) ⟹ boolean?
Returns #t if obj is a keyword object, otherwise returns #f.
(srfi 88) procedure (keyword->string (keyword keyword?) ) ⟹ string?
Returns the name of keyword as a string. It is an error to apply mutation procedures like string-set! to strings returned by this procedure.
(srfi 88) procedure (string->keyword (string string?) ) ⟹ keyword?
Returns the keyword object whose name is string.
library (srfi 95)
(srfi 95) procedure (sorted? (sequence vector?) (less? procedure?) ) ⟹ boolean?
(srfi 95) procedure (sorted? (sequence vector?) (less? procedure?) (key procedure?) ) ⟹ boolean?
(srfi 95) procedure (sorted? (sequence list?) (less? procedure?) ) ⟹ boolean?
(srfi 95) procedure (sorted? (sequence list?) (less? procedure?) (key procedure?) ) ⟹ boolean?
(srfi 95) procedure (sorted? (sequence string?) (less? procedure?) ) ⟹ boolean?
(srfi 95) procedure (sorted? (sequence string?) (less? procedure?) (key procedure?) ) ⟹ boolean?
(less? x y ) ⟹ boolean?
(key obj ) ⟹ *
Returns #t when the sequence argument is in non-decreasing order according to less? (that is, there is no adjacent pair ... x y ... for which (less? y x)).
Returns #f when the sequence contains at least one out-of-order pair. It is an error if the sequence is not a list or array (including vectors and strings).
(srfi 95) procedure (merge (lst1 list?) (lst2 list?) (less? procedure?) ) ⟹ list?
(srfi 95) procedure (merge (lst1 list?) (lst2 list?) (less? procedure?) (key procedure?) ) ⟹ list?
(less? x y ) ⟹ boolean?
(key obj ) ⟹ *
Merges two sorted lists, returning a freshly allocated list as its result.
(srfi 95) procedure (merge! (lst1 list?) (lst2 list?) (less? procedure?) ) ⟹ list?
(srfi 95) procedure (merge! (lst1 list?) (lst2 list?) (less? procedure?) (key procedure?) ) ⟹ list?
(less? x y ) ⟹ boolean?
(key obj ) ⟹ *
Merges two sorted lists, re-using the pairs of list1 and list2 to build the result. The result will be either list1 or list2.
(srfi 95) procedure (sort (sequence vector?) (less? procedure?) ) ⟹ vector?
(srfi 95) procedure (sort (sequence vector?) (less? procedure?) (key procedure?) ) ⟹ vector?
(srfi 95) procedure (sort (sequence list?) (less? procedure?) ) ⟹ list?
(srfi 95) procedure (sort (sequence list?) (less? procedure?) (key procedure?) ) ⟹ list?
(srfi 95) procedure (sort (sequence string?) (less? procedure?) ) ⟹ string?
(srfi 95) procedure (sort (sequence string?) (less? procedure?) (key procedure?) ) ⟹ string?
(less? x y ) ⟹ boolean?
(key obj ) ⟹ *
Accepts a list or array (including vectors and strings) for sequence; and returns a completely new sequence which is sorted according to less?. The returned sequence is the same type as the argument sequence.
(srfi 95) procedure (sort! (sequence vector?) (less? procedure?) ) ⟹ vector?
(srfi 95) procedure (sort! (sequence vector?) (less? procedure?) (key procedure?) ) ⟹ vector?
(srfi 95) procedure (sort! (sequence list?) (less? procedure?) ) ⟹ list?
(srfi 95) procedure (sort! (sequence list?) (less? procedure?) (key procedure?) ) ⟹ list?
(srfi 95) procedure (sort! (sequence string?) (less? procedure?) ) ⟹ string?
(srfi 95) procedure (sort! (sequence string?) (less? procedure?) (key procedure?) ) ⟹ string?
(less? x y ) ⟹ boolean?
(key obj ) ⟹ *
Returns list, array, vector, or string sequence which has been mutated to order its elements according to less?.
library (srfi 98)
(srfi 98) procedure (getenv (name string?) ) ⟹ string / #f /
Returns the value of the named environment variable as a string, or #f if the named environment variable is not found.
(srfi 98) procedure (getenv ) ⟹ list?
return ⟹ (alist (key string?) : (value string?) )
Returns names and values of all the environment variables as an a-list.
library (srfi 99)
(srfi 99) procedure (make-rtd (name symbol?) (fieldspecs vector?) ) ⟹ rtd?
(srfi 99) procedure (make-rtd (name symbol?) (fieldspecs vector?) (parent (or rtd?#f)) ) ⟹ rtd?
name is a symbol, which matters only to the rtd-name procedure of the inspection layer. fieldspecs is a vector of field specifiers, where each field specifier is one of
The optional parent is an rtd or #f. It is an error for any of the symbols in fieldspecs to name more than one of the fields specified by fieldspecs, but the field names in fieldspecs may shadow field names in the parent record-type.
Implementations may wish to extend this procedure to support the non-generative, sealed, and/or opaque features of the R6RS. The recommended way to support those features is to allow any combination of the following arguments to follow the optional parent argument:
The recommendation above is not binding on implementations of SRFI 99. There are other ways to realize sealed, opaque, or non-generative rtds.
Returns an R6RS-compatible record-type descriptor.
(srfi 99) procedure (rtd? obj ) ⟹ boolean?
Equivalent to the record-type-descriptor? procedure of the R6RS.
(srfi 99) procedure (rtd-constructor (rtd rtd?) ) ⟹ procedure?
(srfi 99) procedure (rtd-constructor (rtd rtd?) (fieldspec vector?) ) ⟹ procedure?
(return fieldvalue ... ) ⟹ record?
rtd is a record-type descriptor, and fieldspecs is an optional vector of symbols.
If no fieldspecs argument is supplied, then rtd-constructor returns a procedure that expects one argument for each field of the record-type described by rtd and returns an instance of that record-type with its fields initialized to the corresponding arguments. Arguments that correspond to the fields of the record-type's parent (if any) come first.
If fieldspecs is supplied, then rtd-constructor returns a procedure that expects one argument for each element of fieldspecs and returns an instance of the record-type described by rtd with the named fields initialized to the corresponding arguments.
It is an error if some symbol occurs more than once in fieldspecs. Fields of a derived record-type shadow fields of the same name in its parent; the fieldspecs argument cannot be used to initialize a shadowed field.
(srfi 99) procedure (rtd-predicate (rtd rtd?) ) ⟹ procedure?
(return obj ) ⟹ boolean?
Equivalent to the record-predicate procedure of the R6RS.
(srfi 99) procedure (rtd-accessor (rtd rtd?) (field symbol?) ) ⟹ procedure?
(return (rec record?) ) ⟹ *
field is a symbol that names a field of the record-type described by the record-type descriptor rtd. Returns a unary procedure that accepts instances of rtd (or any record-type that inherits from rtd) and returns the current value of the named field.
Fields in derived record-types shadow fields of the same name in a parent record-type.
(srfi 99) procedure (rtd-mutator (rtd rtd?) (field symbol?) ) ⟹ procedure?
(return (rec record?) value ) ⟹ undefined
field is a symbol that names a field of the record-type described by the record-type descriptor rtd. Returns a binary procedure that accepts instances of rtd (or any record-type that inherits from rtd) and a new value to be stored into the named field, performs that side effect, and returns an unspecified value.
Fields in derived record-types shadow fields of the same name in a parent record-type.
library (srfi 99)
(srfi 99) procedure (record? obj ) ⟹ boolean?
Equivalent to its R6RS namesake.
(srfi 99) procedure (record-rtd (rec record?) ) ⟹ rtd?
Equivalent to its R6RS namesake.
(srfi 99) procedure (rtd-name (rtd rtd?) ) ⟹ symbol?
Equivalent to the record-type-name procedure of the R6RS.
(srfi 99) procedure (rtd-parent (rtd rtd?) ) ⟹ #f / rtd? /
Equivalent to the record-type-parent procedure of the R6RS.
(srfi 99) procedure (rtd-field-names (rtd rtd?) ) ⟹ vector?
Equivalent to the record-type-field-names procedure of the R6RS. (That is, it returns a vector of the symbols that name the fields of the record-type represented by rtd, excluding the fields of parent record-types.)
(srfi 99) procedure (rtd-all-field-names (rtd rtd?) ) ⟹ vector?
Returns a vector of the symbols that name the fields of the record-type represented by rtd, including the fields of its parent record-types, if any. The fields of parent record-types come before the fields of its children, with each subsequence in the same order as in the vectors that would be returned by calling rtd-field-names on rtd and on all its ancestral record-type descriptors.
(srfi 99) procedure (rtd-field-mutable? (rtd rtd?) (field symbol?) ) ⟹ boolean?
rtd is a record-type descriptor, and field is a symbol naming a field of the record-type described by rtd. Returns #t if the named field is mutable; otherwise returns #f.
library (srfi 99)
(srfi 99) syntax (define-record-type () ((_ type-spec constructor predicate field ...)) )
type-name (type-name parent)
#f #t constructor-name (constructor-name field-name ...)
#f #t predicate-name
field-name (field-name) (field-name accessor-name) (field-name accessor-name modifier-name)
parent ⟹ rtd?
The semantics of a record type definition is the same as in SRFI 9: the record type definition macro-expands into a cluster of definitions that
An ERR5RS record type definition extends SRFI 9 with the following additional options:
- the field is immutable;
- the name of its accessor is the type name followed by a hyphen (-) followed by the field name.
- the field is mutable;
- the name of its accessor is the type name followed by a hyphen (-) followed by the field name;
- the name of its mutator is the type name followed by a hyphen (-) followed by the field name followed by -set!.
library (srfi 99 records procedural)
(srfi 99 records procedural) procedure (make-rtd (name symbol?) (fieldspecs vector?) ) ⟹ rtd?
(srfi 99 records procedural) procedure (make-rtd (name symbol?) (fieldspecs vector?) (parent (or rtd?#f)) ) ⟹ rtd?
name is a symbol, which matters only to the rtd-name procedure of the inspection layer. fieldspecs is a vector of field specifiers, where each field specifier is one of
The optional parent is an rtd or #f. It is an error for any of the symbols in fieldspecs to name more than one of the fields specified by fieldspecs, but the field names in fieldspecs may shadow field names in the parent record-type.
Implementations may wish to extend this procedure to support the non-generative, sealed, and/or opaque features of the R6RS. The recommended way to support those features is to allow any combination of the following arguments to follow the optional parent argument:
The recommendation above is not binding on implementations of SRFI 99. There are other ways to realize sealed, opaque, or non-generative rtds.
Returns an R6RS-compatible record-type descriptor.
(srfi 99 records procedural) procedure (rtd? obj ) ⟹ boolean?
Equivalent to the record-type-descriptor? procedure of the R6RS.
(srfi 99 records procedural) procedure (rtd-constructor (rtd rtd?) ) ⟹ procedure?
(srfi 99 records procedural) procedure (rtd-constructor (rtd rtd?) (fieldspec vector?) ) ⟹ procedure?
(return fieldvalue ... ) ⟹ record?
rtd is a record-type descriptor, and fieldspecs is an optional vector of symbols.
If no fieldspecs argument is supplied, then rtd-constructor returns a procedure that expects one argument for each field of the record-type described by rtd and returns an instance of that record-type with its fields initialized to the corresponding arguments. Arguments that correspond to the fields of the record-type's parent (if any) come first.
If fieldspecs is supplied, then rtd-constructor returns a procedure that expects one argument for each element of fieldspecs and returns an instance of the record-type described by rtd with the named fields initialized to the corresponding arguments.
It is an error if some symbol occurs more than once in fieldspecs. Fields of a derived record-type shadow fields of the same name in its parent; the fieldspecs argument cannot be used to initialize a shadowed field.
(srfi 99 records procedural) procedure (rtd-predicate (rtd rtd?) ) ⟹ procedure?
(return obj ) ⟹ boolean?
Equivalent to the record-predicate procedure of the R6RS.
(srfi 99 records procedural) procedure (rtd-accessor (rtd rtd?) (field symbol?) ) ⟹ procedure?
(return (rec record?) ) ⟹ *
field is a symbol that names a field of the record-type described by the record-type descriptor rtd. Returns a unary procedure that accepts instances of rtd (or any record-type that inherits from rtd) and returns the current value of the named field.
Fields in derived record-types shadow fields of the same name in a parent record-type.
(srfi 99 records procedural) procedure (rtd-mutator (rtd rtd?) (field symbol?) ) ⟹ procedure?
(return (rec record?) value ) ⟹ undefined
field is a symbol that names a field of the record-type described by the record-type descriptor rtd. Returns a binary procedure that accepts instances of rtd (or any record-type that inherits from rtd) and a new value to be stored into the named field, performs that side effect, and returns an unspecified value.
Fields in derived record-types shadow fields of the same name in a parent record-type.
library (srfi 99 records inspection)
(srfi 99 records inspection) procedure (record? obj ) ⟹ boolean?
Equivalent to its R6RS namesake.
(srfi 99 records inspection) procedure (record-rtd (rec record?) ) ⟹ rtd?
Equivalent to its R6RS namesake.
(srfi 99 records inspection) procedure (rtd-name (rtd rtd?) ) ⟹ symbol?
Equivalent to the record-type-name procedure of the R6RS.
(srfi 99 records inspection) procedure (rtd-parent (rtd rtd?) ) ⟹ #f / rtd? /
Equivalent to the record-type-parent procedure of the R6RS.
(srfi 99 records inspection) procedure (rtd-field-names (rtd rtd?) ) ⟹ vector?
Equivalent to the record-type-field-names procedure of the R6RS. (That is, it returns a vector of the symbols that name the fields of the record-type represented by rtd, excluding the fields of parent record-types.)
(srfi 99 records inspection) procedure (rtd-all-field-names (rtd rtd?) ) ⟹ vector?
Returns a vector of the symbols that name the fields of the record-type represented by rtd, including the fields of its parent record-types, if any. The fields of parent record-types come before the fields of its children, with each subsequence in the same order as in the vectors that would be returned by calling rtd-field-names on rtd and on all its ancestral record-type descriptors.
(srfi 99 records inspection) procedure (rtd-field-mutable? (rtd rtd?) (field symbol?) ) ⟹ boolean?
rtd is a record-type descriptor, and field is a symbol naming a field of the record-type described by rtd. Returns #t if the named field is mutable; otherwise returns #f.
library (srfi 99 records syntactic)
(srfi 99 records syntactic) syntax (define-record-type () ((_ type-spec constructor predicate field ...)) )
type-name (type-name parent)
#f #t constructor-name (constructor-name field-name ...)
#f #t predicate-name
field-name (field-name) (field-name accessor-name) (field-name accessor-name modifier-name)
parent ⟹ rtd?
The semantics of a record type definition is the same as in SRFI 9: the record type definition macro-expands into a cluster of definitions that
An ERR5RS record type definition extends SRFI 9 with the following additional options:
- the field is immutable;
- the name of its accessor is the type name followed by a hyphen (-) followed by the field name.
- the field is mutable;
- the name of its accessor is the type name followed by a hyphen (-) followed by the field name;
- the name of its mutator is the type name followed by a hyphen (-) followed by the field name followed by -set!.
library (srfi 100)
(srfi 100) syntax (define-lambda-object () ((_ group-spec field-spec)) )
group (group parent-group ...)
group (group)
required-field... optional-field... automatic-field...
field (field)
(field default) ((field) default) ((quote field) default)
((unquote field) default) (((unquote field)) default) ((quote (unquote field)) default) ((quasiquote (unquote field)) default) ((unquote (unquote field)) default) (((unquote (unquote field))) default)
This SRFI introduces a macro, DEFINE-LAMBDA-OBJECT which defines a set of procedures, that is, a group, two constructors, and a predicate. The constructors also make a group of procedures, namely lambda objects. The macro extends DEFINE-RECORD-TYPE (SRFI 9) in being more general but much less general than DEFCLASS (CLOS). The macro has no explicit field accessors and mutators but parent groups, required fields, optional fields, automatic fields, read-write fields, read-only fields, inaccessible hidden fields, immutable virtual fields, and common sharing fields.
The name of <constructor> is generated by prefixing `make-' to the group name, or by prefixing `make-' and postfixing `-by-name' to the group name. The name of <predicate> is generated by adding a question mark (`?') to the end of the group name.
The <group> and <field> must be identifiers.
Each <default> is an <expression> that is evaluated in an environment that the values of all the previous <field>s are visible. There is one exception to this rule. The <default>s of <automatic common field>s are evaluated in the outer environment of the define-lambda-object form, and their values are visible as the <default>s of the other fields are evaluated.
The define-lambda-object form is a definition and can appear anywhere any other <definition> can appear. Each time define-lambda-object form is evaluated, a new group is created with distinct <group>, <constructor>, and <predicate> procedures.
The <group> is bound to a procedure of one argument. Like a gene, it has information on its <parent group>s, <constructor>s, <predicate>, and the number and properties of <field>s. And they are checked out whenever define-lambda-object form is evaluated. In case of inheritance, all the <field>s of <parent group>s must exist in the <field spec> of the child group, irrespectively of the order. Otherwise an error is signaled. In addition, the properties (mutability, sort of field, and default expression) of <field>s of unamendable groups must be preserved in contrast with those of amendable groups. Otherwise an error is signaled.
The <constructor> is bound to a procedure that takes at least as many arguments as the number of <required field>s. Whenever it is called, it returns an object of the <group>, namely a procedure, which has information on its own group and all that goes with it. Its first argument must be a symbol of the same name as <field>. Otherwise an error is signaled. The object becomes an accessor procedure of each <field> in case of one argument and a mutator procedure of each <field> in case of two arguments where the second argument is a new field value.
The names of <field>s are used to access the <field>s as symbols of the same names. So they must be distinct. Otherwise an error is signaled. The read-write fields can be modified, whereas any attempt to modify the values of the read-only fields via mutators signals an error. Note: The read-only fields are not immutable. Their values, for instance, can be modified by other fields whose values work like their mutators.
The <required field> is initialized to the first one of the remaining arguments. If there are no more remaining arguments, an error is signaled.
The initialization of the <optional field>s is done by two types of <constructor>s:
1. <make-`group-name'> constructor The initialization method of <optional field>s is the same as that of <required field>s except that the field is bound to the <default> instead of signaling an error if there are no more remaining arguments.
2. <make-`group-name'-by-name> constructor The name used at a call site for the corresponding <optional field> is a symbol of the same name as the <field>. The remaining arguments are sequentially interpreted as a series of pairs, where the first member of each pair is a field name and the second is the corresponding value. If there is no element for a particular field name, the field is initialized to the <default>.
The <automatic common field>s are initialized to each corresponding <default> that is evaluated at the time the define-lambda-object form is evaluated, and the values are shared with all the lambda objects that are maded by the constructors of the define-lambda-object form. The other <automatic field>s except <automatic virtual field>s are initialized to each corresponding <default> that is evaluated at the time the lambda object is made by a constructor. The <hidden field> is an externally nonexistent field, that is, the field is invisible outside of the define-lambda-object form but visible inside of it. On the contrary, the <virtual field> is an internally nonexistent field whose <default> is evaluated each time when the field is accessed.
The <predicate> is a predicate procedure that returns #t for objects constructed by <constructor> or <constructor>s for child groups and #f for everything else.
library (srfi 101)
(srfi 101) procedure (pair? obj ) ⟹ boolean?
Returns #t if obj is a pair, and otherwise returns #f.
(srfi 101) 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. This operation must take O(1) time.
(srfi 101) procedure (car (pair pair?) ) ⟹ *
Returns the contents of the car field of pair. This operation must take O(1) time.
(srfi 101) procedure (cdr (pair pair?) ) ⟹ *
Returns the contents of the cdr field of pair. This operation must take O(1) time.
(srfi 101) procedure (caar (pair pair?) ) ⟹ *
(srfi 101) procedure (cadr (pair pair?) ) ⟹ *
(srfi 101) procedure (cdar (pair pair?) ) ⟹ *
(srfi 101) procedure (cddr (pair pair?) ) ⟹ *
(srfi 101) procedure (caaar (pair pair?) ) ⟹ *
(srfi 101) procedure (caadr (pair pair?) ) ⟹ *
(srfi 101) procedure (cadar (pair pair?) ) ⟹ *
(srfi 101) procedure (caddr (pair pair?) ) ⟹ *
(srfi 101) procedure (cdaar (pair pair?) ) ⟹ *
(srfi 101) procedure (cdadr (pair pair?) ) ⟹ *
(srfi 101) procedure (cddar (pair pair?) ) ⟹ *
(srfi 101) procedure (cdddr (pair pair?) ) ⟹ *
(srfi 101) procedure (caaaar (pair pair?) ) ⟹ *
(srfi 101) procedure (caaadr (pair pair?) ) ⟹ *
(srfi 101) procedure (caadar (pair pair?) ) ⟹ *
(srfi 101) procedure (caaddr (pair pair?) ) ⟹ *
(srfi 101) procedure (cadaar (pair pair?) ) ⟹ *
(srfi 101) procedure (cadadr (pair pair?) ) ⟹ *
(srfi 101) procedure (caddar (pair pair?) ) ⟹ *
(srfi 101) procedure (cadddr (pair pair?) ) ⟹ *
(srfi 101) procedure (cdaaar (pair pair?) ) ⟹ *
(srfi 101) procedure (cdaadr (pair pair?) ) ⟹ *
(srfi 101) procedure (cdadar (pair pair?) ) ⟹ *
(srfi 101) procedure (cdaddr (pair pair?) ) ⟹ *
(srfi 101) procedure (cddaar (pair pair?) ) ⟹ *
(srfi 101) procedure (cddadr (pair pair?) ) ⟹ *
(srfi 101) procedure (cdddar (pair pair?) ) ⟹ *
(srfi 101) procedure (cddddr (pair pair?) ) ⟹ *
These procedures are compositions of car and cdr.
(srfi 101) procedure (null? obj ) ⟹ boolean?
Returns #t if obj is the empty list, #f otherwise.
(srfi 101) procedure (list? obj ) ⟹ boolean?
Returns #t if obj is a list, #f otherwise. By definition, all lists are chains of pairs that have finite length and are terminated by the empty list. This operation must take time bounded by O(log(n)), where n is the number of pairs in the chain forming the potential list.
(srfi 101) procedure (list obj ... ) ⟹ list?
Returns a newly allocated list of its arguments. This operation must take time bounded by O(n), where n is the number of arguments to list.
(srfi 101) procedure (make-list (k integer?) ) ⟹ list?
(srfi 101) 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 obj. Otherwise the initial contents of each element is unspecified. This operation must take time and space bounded by O(log(k)).
(srfi 101) procedure (length (list list?) ) ⟹ integer?
Returns the length of list. This operation must take time bounded by O(log(n)), where n is the length of the list.
(srfi 101) procedure (length<=? obj (k integer?) ) ⟹ boolean?
Returns true if obj is a chain of at least k pairs and false otherwise. This operation must take time bounded by O(log(min(k,n))), where n is the length of the chain of pairs.
(srfi 101) procedure (append (list list?) ... ) ⟹ list?
(srfi 101) procedure (append (list list?) ... obj ) ⟹ *
Returns a chain of pairs consisting of the elements of the first list followed by the elements of the other lists, with obj as the cdr of the final pair. An improper list results if obj is not a list. This operation must take time bounded by O(log(n)), where n is the total number of elements in the given lists.
(srfi 101) procedure (reverse (list list?) ) ⟹ list?
Returns a newly allocated list consisting of the element of list in reverse order. This operation must take time bounded by O(n) where n is the length of the list.
(srfi 101) procedure (list-tail (list list?) (k integer?) ) ⟹ list?
(srfi 101) procedure (list-tail obj (k integer?) ) ⟹ *
Obj should be a chain of pairs with a count of at least k. The list-tail procedure returns the object obtained by omitting the first k elements in obj. This operation must take time bounded by O(log(min(k,n))), where n is the length of the chain of pairs.
(srfi 101) procedure (list-ref (pair pair?) (k integer?) ) ⟹ *
Pair must be a chain of pairs whose count is at least k + 1. The list-ref procedure returns the kth element of pair. This operation must take time bounded by O(min(k,log(n))), where n is the length of the chain of pairs.
(srfi 101) procedure (list-set (pair pair?) (k integer?) obj ) ⟹ pair?
Pair must be a chain of pairs whose count is at least k + 1. The list-set procedure returns the chain of pairs obtained by replacing the kth element with obj. This operation must take time bounded by O(min(k,log(n))), where n is the length of the chain of pairs.
(srfi 101) procedure (list-ref/update (pair pair?) (k integer?) (proc procedure?) ) ⟹ (values *pair?)
(proc obj ) ⟹ *
Returns the same results as:
(values (list-ref pair k)
(list-set pair k (proc (list-ref pair k))))
but it may be implemented more efficiently.
(srfi 101) procedure (map (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ list?
(proc obj1 obj2 ... ) ⟹ *
The lists should all have the same length. Proc should 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. Proc is always called in the same dynamic environment as map itself. The order in which proc is applied to the elements of the lists is unspecified.
(srfi 101) procedure (for-each (proc procedure?) (list1 list?) (list2 list?) ... ) ⟹ undefined
(proc obj1 obj2 ... ) ⟹ undefined
The lists should all have the same length. Proc should accept as many arguments as there are lists.
The for-each procedure applies proc element-wise to the elements of the lists for its side effects, in order from the first element to the last. Proc is always called in the same dynamic environment as for-each itself. The return values of for-each are unspecified.
(srfi 101) procedure (random-access-list->linear-access-list (list list?) ) ⟹ list?
(srfi 101) procedure (linear-access-list->random-access-list (list list?) ) ⟹ list?
These procedures convert between (potentially) distinct representations of lists. To avoid confusion, parameters named ra-list range over lists represented with random-access lists, i.e. objects satisfying the list? predicate described above, while parameters named la-list range over lists represented with the more traditional linear-access lists, i.e. objects satisfying the list? predicate of R6RS. In systems that represent all lists as random-access lists, these conversions may simply be list identity procedures.
library (srfi 106)
(srfi 106) procedure (make-client-socket (node string?) (service string?) ) ⟹ socket?
(srfi 106) procedure (make-client-socket (node string?) (service string?) (ai-family address-family) ) ⟹ socket?
(srfi 106) procedure (make-client-socket (node string?) (service string?) (ai-family address-family) (ai-socktype socket-domain) ) ⟹ socket?
(srfi 106) procedure (make-client-socket (node string?) (service string?) (ai-family address-family) (ai-socktype socket-domain) (ai-flags address-info) ) ⟹ socket?
(srfi 106) procedure (make-client-socket (node string?) (service string?) (ai-family address-family) (ai-socktype socket-domain) (ai-flags address-info) (ai-protocol ip-protocol) ) ⟹ socket?
Returns a client socket connected to an Internet address. The Internet address is identified by node and service. node and service must be string. Example value of node: "localhost" "127.0.0.1" Example value of service: "http" "80". The optional parameter may specify the created socket's behaviour.
If the optional argument(s) is omitted, then following flags should be used as default.
ai-family
*af-inet*
ai-socktype
*sock-stream*
ai-flags
(socket-merge-flags *ai-v4mapped* *ai-addrconfig*)
ai-protocol
*ipproto-ip*
The created socket may not be closed automatically so it is users' responsibility to close it explicitly.
(srfi 106) procedure (make-server-socket (service string?) ) ⟹ socket?
(srfi 106) procedure (make-server-socket (service string?) (ai-family address-family) ) ⟹ socket?
(srfi 106) procedure (make-server-socket (service string?) (ai-family address-family) (ai-socktype socket-domain) ) ⟹ socket?
(srfi 106) procedure (make-server-socket (service string?) (ai-family address-family) (ai-socktype socket-domain) ) ⟹ socket?
(srfi 106) procedure (make-server-socket (service string?) (ai-family address-family) (ai-socktype socket-domain) (ai-protocol ip-protocol) ) ⟹ socket?
Returns a server socket waiting for connection. The description of node argument is the same as make-client-socket. The optional parameter may specify the created socket's behaviour.
If the optional argument(s) is omitted, then following flags should be used as default.
ai-family
*af-inet*
ai-socktype
*sock-stream*
ai-protocol
*ipproto-ip*
The created socket may not be closed automatically so it is users' responsibility to close it explicitly.
(srfi 106) procedure (socket? obj ) ⟹ boolean?
Returns #t if given object is socket object. Otherwise #f.
(srfi 106) procedure (socket-accept (socket socket?) ) ⟹ socket?
Wait for an incoming connection request, and returns a fresh connected client socket.
(srfi 106) procedure (socket-send (socket socket?) (bv bytevector?) ) ⟹ integer?
(srfi 106) procedure (socket-send (socket socket?) (bv bytevector?) (flags message-type) ) ⟹ integer?
Sends a binary data block to a socket and returns the sent data size. flags may specify the procedure's behaviour.
If the flags is omitted, the default value must be the result of following form;
(message-type none)
(srfi 106) procedure (socket-recv (socket socket?) (size integer?) ) ⟹ bytevector?
(srfi 106) procedure (socket-recv (socket socket?) (size integer?) (flags message-type) ) ⟹ bytevector?
Receives a binary data block from a socket. If zero length bytevector is returned, it means the peer connection is closed. flags may specify the procedure's behaviour.
If the flags is omitted, the default value must be the result of following form;
(message-type none)
(srfi 106) procedure (socket-shutdown (socket socket?) (how shutdown-method) ) ⟹ undefined
Shutdowns a socket.
(srfi 106) procedure (socket-close (socket socket?) ) ⟹ undefined
Closes a socket. The procedure should not shutdown the given socket. To shutdown a socket, socket-shutdown should be called explicitly.
(srfi 106) procedure (socket-input-port (socket socket?) ) ⟹ input-port?
(srfi 106) procedure (socket-output-port (socket socket?) ) ⟹ output-port?
Returns a fresh binary input and output port associated with a socket, respectively. The port should not close underlying socket when it's closing.
(srfi 106) procedure (call-with-socket (socket socket?) (proc procedure?) ) ⟹ *
(proc ) ⟹ *
Calls a given procedure with a given socket as an argument. If given proc returns then it returns the result of proc and socket will be automatically closed. If proc doesn't return then given socket won't be closed automatically. It's analogy of call-with-port.
(srfi 106) syntax (address-family () ((_ name) address-family ) )
Returns proper address family from given name.
Implementation must support at least following names and must have the described behaviour.
inet
Returns *af-inet*
inet6
Returns *af-inet6*
unspec
Returns *af-unspec*
Implementation may support more names such as unix or local or other names.
(srfi 106) syntax (address-info () ((_ names ...) address-info ) )
Returns merged address info flags from given names.
Implementation must support at least following names and must have the described behaviour.
canoname
Returns *ai-canonname*
numerichost
Returns *ai-numerichost*
v4mapped
Returns *ai-v4mapped*
all
Returns *ai-all*
addrconfig
Returns *ai-addrconfig*
Implementation may support more names.
(srfi 106) syntax (socket-domain () ((_ name) socket-domain ) )
Returns socket domain flags from given name.
Implementation must support at least following names and must have the described behaviour.
stream
Returns *sock-stream*
datagram
Returns *sock-dgram*
Implementation may support more names.
(srfi 106) syntax (ip-protocol () ((_ name) ip-protocol ) )
Returns ip-protocol flag from given name.
Implementation must support at least following names and must have the described behaviour.
ip
Returns *ipproto-ip*
tcp
Returns *ipproto-tcp*
udp
Returns *ipproto-udp*
Implementation may support more names.
(srfi 106) syntax (message-type () ((_ names ...) message-type ) )
Returns message type flag from given name. The flag can be used both socket-recv and socket-send.
Implementation must support at least following names and must have the described behaviour.
none
Returns no flag.
peek
Returns *msg-peek*
oob
Returns *msg-oob*
wait-all
Returns *msg-waitall*
Implementation may support more names.
(srfi 106) syntax (shutdown-method () ((_ names ...) shutdown-method ) )
Returns shutdown method flags from given names.
Implementation must support at least following names and must have the described behaviour.
read
Returns *shut-rd*
write
Returns *shut-wr*
If shutdown-method is given both read and write, then it must return *shut-rdwr*
(srfi 106) procedure (socket-merge-flags (flags address-info) ... ) ⟹ address-info
(srfi 106) procedure (socket-merge-flags (flags message-type) ... ) ⟹ message-type
(srfi 106) procedure (socket-merge-flags (flags shutdown-method) ... ) ⟹ shutdown-method
Merges given flags and returns a new flag.
(srfi 106) procedure (socket-purge-flags (base-flag address-info) (flags address-info) ... ) ⟹ address-info
(srfi 106) procedure (socket-purge-flags (base-flag message-type) (flags message-type) ... ) ⟹ message-type
(srfi 106) procedure (socket-purge-flags (base-flag shutdown-method) (flags shutdown-method) ... ) ⟹ shutdown-method
Removes flags from base-flag if exists and returns a new flag.
*af-inet* ⟹ address-family
Internet domain sockets for use with IPv4 addresses. This must behave the same as POSIX's AF_INET.
*af-inet6* ⟹ address-family
Internet domain sockets for use with IPv6 addresses. This must behave the same as POSIX's AF_INET6.
*af-unspec* ⟹ address-family
Unspecified. This must behave the same as POSIX's AF_UNSPEC.
*sock-stream* ⟹ socket-domain
Byte-stream socket. This must behave the same as POSIX's SOCK_STREAM.
*sock-dgram* ⟹ socket-domain
Datagram socket. This must behave the same as POSIX's SOCK_DGRAM.
*ai-canonname* ⟹ address-info
This must behave the same as POSIX's AI_CANONNAME.
*ai-numerichost* ⟹ address-info
This must behave the same as POSIX's AI_NUMERICHOST.
*ai-v4mapped* ⟹ address-info
This must behave the same as POSIX's AI_V4MAPPED.
*ai-all* ⟹ address-info
This must behave the same as POSIX's AI_ALL.
*ai-addrconfig* ⟹ address-info
This must behave the same as POSIX's AI_ADDRCONFIG.
*ipproto-ip* ⟹ ip-protocol
Internet protocol. This must behave the same as POSIX's IPPROTO_IP.
*ipproto-tcp* ⟹ ip-protocol
Transmission control protocol. This must behave the same as POSIX's IPPROTO_TCP.
*ipproto-udp* ⟹ ip-protocol
User datagram protocol. This must behave the same as POSIX's IPPROTO_UDP.
*msg-peek* ⟹ message-type
For socket-recv. Peeks at an incoming message. The data is treated as unread and the next socket-recv shall still return this data. This must behave the same as POSIX's MSG_PEEK.
*msg-oob* ⟹ message-type
For both socket-recv and socket-send. Requests/sends out-of-band data. This must behave the same as POSIX's MSG_OOB.
*msg-waitall* ⟹ message-type
For socket-recv. On sockets created with *sock-stream* flag, this requests the procedure block until the full amount of data ban be returned. This must behave the same as POSIX's MSG_WAITALL.
*shut-rd* ⟹ shutdown-method
Disables further receive operation. This must behave the same as POSIX's SHUT_RD.
*shut-wr* ⟹ shutdown-method
Disables further send operations. This must behave the same as POSIX's SHUT_WR.
*shut-rdwr* ⟹ shutdown-method
Disables further send and receive operations. This must behave the same as POSIX's SHUT_RDWR.
library (srfi 111)
(srfi 111) procedure (box value ) ⟹ box?
Constructor. Returns a newly allocated box initialized to value.
(srfi 111) procedure (box? object ) ⟹ boolean?
Predicate. Returns #t if object is a box, and #f otherwise.
(srfi 111) procedure (unbox (box box?) ) ⟹ *
Accessor. Returns the current value of box.
(srfi 111) procedure (set-box! (box box?) value ) ⟹ undefined
Mutator. Changes box to hold value.
library (srfi 112)
(srfi 112) procedure (implementation-name ) ⟹ string? / #f /
Returns the name of the Scheme implementation. This procedure corresponds roughly to Common Lisp's lisp-implementation-type function.
(srfi 112) procedure (implementation-version ) ⟹ string? / #f /
Returns the version of the Scheme implementation. This procedure corresponds roughly to Common Lisp's lisp-implementation-version function.
(srfi 112) procedure (cpu-architecture ) ⟹ string? / #f /
Returns the CPU architecture, real or virtual, on which this implementation is executing. This procedure corresponds roughly to Common Lisp's machine-type function. On Posix systems, the result may be derived from the machine field of the utsname structure.
(srfi 112) procedure (machine-name ) ⟹ string? / #f /
Returns a name for the particular machine on which the implementation is running. Possible values are the DNS or WINS host name, the DNS full name, an IP address in string form associated with the system, or a MAC address in string form associated with the system. This procedure corresponds roughly to Common Lisp's machine-instance function. On Posix systems, the result may be derived from the nodename field of the utsname structure.
(srfi 112) procedure (os-name ) ⟹ string? / #f /
Returns a name for the operating system, platform, or equivalent on which the implementation is running. This procedure corresponds roughly to Common Lisp's software-type function. On Posix systems, the result may be derived from the sysname field of the utsname structure.
(srfi 112) procedure (os-version ) ⟹ string? / #f /
Returns the version of the operating system, platform, or equivalent on which the implementation is running. This procedure corresponds roughly to Common Lisp's software-version function. On Posix systems, the result may be derived from the release and/or version fields of the utsname structure.
library (srfi 113)
(srfi 113) procedure (set (comparator comparator?) element ... ) ⟹ set?
Returns a newly allocated empty set. The comparator argument is a SRFI 114 comparator, which is used to control and distinguish the elements of the set. The elements are used to initialize the set.
(srfi 113) procedure (set-unfold (comparator comparator?) (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ set?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Create a newly allocated set as if by set using comparator. If the result of applying the predicate stop? to seed is true, return the set. Otherwise, apply the procedure mapper to seed. The value that mapper returns is added to the set. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
(srfi 113) procedure (set? obj ) ⟹ boolean?
Returns #t if obj is a set, and #f otherwise.
(srfi 113) procedure (set-contains? (set set?) element ) ⟹ boolean?
Returns #t if element is a member of set and #f otherwise.
(srfi 113) procedure (set-empty? (set set?) ) ⟹ boolean?
Returns #t if set has no elements and #f otherwise.
(srfi 113) procedure (set-disjoint? (set1 set?) (set2 set?) ) ⟹ boolean?
Returns #t if set1 and set2 have no elements in common and #f otherwise.
(srfi 113) procedure (set-member (set set?) element default ) ⟹ *
Returns the element of set that is equal, in the sense of set's equality predicate, to element. If element is not a member of set, default is returned.
(srfi 113) procedure (set-element-comparator (set set?) ) ⟹ comparator?
Returns the comparator used to compare the elements of set.
(srfi 113) procedure (set-adjoin (set set?) element ... ) ⟹ set?
The set-adjoin procedure returns a newly allocated set that uses the same comparator as set and contains all the values of set, and in addition each element unless it is already equal (in the sense of the comparator) to one of the existing or newly added members. It is an error to add an element to set that does not return #t when passed to the type test procedure of the comparator.
(srfi 113) procedure (set-adjoin! (set set?) element ... ) ⟹ set?
The set-adjoin! procedure is the same as set-adjoin, except that it is permitted to mutate and return the set argument rather than allocating a new set.
(srfi 113) procedure (set-replace (set set?) element ) ⟹ set?
The set-replace procedure returns a newly allocated set that uses the same comparator as set and contains all the values of set except as follows: If element is equal (in the sense of set's comparator) to an existing member of set, then that member is omitted and replaced by element. If there is no such element in set, then set is returned unchanged.
(srfi 113) procedure (set-replace! (set set?) element ) ⟹ set?
The set-replace! procedure is the same as set-replace, except that it is permitted to mutate and return the set argument rather than allocating a new set.
(srfi 113) procedure (set-delete (set set?) element ... ) ⟹ set?
The set-delete procedure returns a newly allocated set containing all the values of set except for any that are equal (in the sense of set's comparator) to one or more of the elements. Any element that is not equal to some member of the set is ignored.
(srfi 113) procedure (set-delete! (set set?) element ... ) ⟹ set?
The set-delete! procedure is the same as set-delete, except that it is permitted to mutate and return the set argument rather than allocating a new set.
(srfi 113) procedure (set-delete-all (set set?) (elements list?) ) ⟹ set?
The set-delete-all procedure is the same as set-delete, except that it accepts a single argument which is a list of elements to be deleted.
(srfi 113) procedure (set-delete-all! (set set?) (elements list?) ) ⟹ set?
The set-delete-all! procedure is the same as set-delete!, except that it accepts a single argument which is a list of elements to be deleted.
(srfi 113) procedure (set-search! (set set?) element (failure procedure?) (success procedure?) ) ⟹ (values set?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert obj ) ⟹ *
(ignore obj ) ⟹ *
(success element (update procedure?) (remove procedure?) ) ⟹ *
(update new-element obj ) ⟹ *
(remove obj ) ⟹ *
The set is searched for element. If it is not found, then the failure procedure is tail-called with two continuation arguments, insert and ignore, and is expected to tail-call one of them. If element is found, then the success procedure is tail-called with the matching element of set and two continuations, update and remove, and is expected to tail-call one of them. The effects of the continuations are as follows (where obj is any Scheme object):
In all cases, two values are returned: the possibly updated set and obj.
(srfi 113) procedure (set-size (set set?) ) ⟹ integer?
Returns the number of elements in set as an exact integer.
(srfi 113) procedure (set-find (predicate procedure?) (set set?) (failure procedure?) ) ⟹ *
(predicate obj ) ⟹ boolean?
(failure ) ⟹ *
Returns an arbitrarily chosen element of set that satisfies predicate, or the result of invoking failure with no arguments if there is none.
(srfi 113) procedure (set-count (predicate procedure?) (set set?) ) ⟹ integer?
(predicate obj ) ⟹ boolean?
Returns the number of elements of set that satisfy predicate as an exact integer.
(srfi 113) procedure (set-any? (predicate procedure?) (set set?) ) ⟹ boolean?
(predicate obj ) ⟹ boolean?
Returns #t if any element of set satisfies predicate, or #f otherwise. Note that this differs from the SRFI 1 analogue because it does not return an element of the set.
(srfi 113) procedure (set-every? (predicate procedure?) (set set?) ) ⟹ boolean?
(predicate obj ) ⟹ boolean?
Returns #t if every element of set satisfies predicate, or #f otherwise. Note that this differs from the SRFI 1 analogue because it does not return an element of the set.
(srfi 113) procedure (set-map (comparator comparator?) (proc procedure?) (set set?) ) ⟹ *
(proc obj ) ⟹ *
Applies proc to each element of set in arbitrary order and returns a newly allocated set, created as if by (set comparator), which contains the results of the applications. For example:
(set-map string-ci-comparator symbol->string (set eq? 'foo 'bar 'baz)) => (set string-ci-comparator "foo" "bar" "baz")
Note that, when proc defines a mapping that is not 1:1, some of the mapped objects may be equivalent in the sense of comparator's equality predicate, and in this case duplicate elements are omitted as in the set constructor.
(srfi 113) procedure (set-for-each (proc procedure?) (set set?) ) ⟹ undefined
(proc obj ) ⟹ undefined
Applies proc to set in arbitrary order, discarding the returned values. Returns an unspecified result.
(srfi 113) procedure (set-fold (proc procedure?) nil (set set?) ) ⟹ *
(proc obj state ) ⟹ *
Invokes proc on each member of set in arbitrary order, passing the result of the previous invocation as a second argument. For the first invocation, nil is used as the second argument. Returns the result of the last invocation, or nil if there was no invocation.
(srfi 113) procedure (set-filter (predicate procedure?) (set set?) ) ⟹ set?
(predicate obj ) ⟹ *
Returns a newly allocated set with the same comparator as set, containing just the elements of set that satisfy predicate.
(srfi 113) procedure (set-filter! (predicate procedure?) (set set?) ) ⟹ set?
(predicate obj ) ⟹ *
A linear update procedure that returns a set containing just the elements of set that satisfy predicate.
(srfi 113) procedure (set-remove (predicate procedure?) (set set?) ) ⟹ set?
(predicate obj ) ⟹ *
Returns a newly allocated set with the same comparator as set, containing just the elements of set that do not satisfy predicate.
(srfi 113) procedure (set-remove! (predicate procedure?) (set set?) ) ⟹ set?
(predicate obj ) ⟹ *
A linear update procedure that returns a set containing just the elements of set that do not satisfy predicate.
(srfi 113) procedure (set-partition (predicate procedure?) (set set?) ) ⟹ (values set?set?)
(predicate obj ) ⟹ *
Returns two values: a newly allocated set with the same comparator as set that contains just the elements of set that satisfy predicate, and another newly allocated set, also with the same comparator, that contains just the elements of set that do not satisfy predicate.
(srfi 113) procedure (set-partition! (predicate procedure?) (set set?) ) ⟹ (values set?set?)
(predicate obj ) ⟹ *
A linear update procedure that returns two sets containing the elements of set that do and do not, respectively, not satisfy predicate.
(srfi 113) procedure (set-copy (set set?) ) ⟹ set?
Returns a newly allocated set containing the elements of set, and using the same comparator.
(srfi 113) procedure (set->list (set set?) ) ⟹ list?
Returns a newly allocated list containing the members of set in unspecified order.
(srfi 113) procedure (list->set (comparator comparator?) (list list?) ) ⟹ set?
Returns a newly allocated set, created as if by set using comparator, that contains the elements of list. Duplicate elements (in the sense of the equality predicate) are omitted.
(srfi 113) procedure (list->set! (set set?) (list list?) ) ⟹ set?
Returns a set that contains the elements of both set and list. Duplicate elements (in the sense of the equality predicate) are omitted.
(srfi 113) procedure (set=? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set contains the same elements.
(srfi 113) procedure (set<? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set other than the last is a proper subset of the following set, and #f otherwise.
(srfi 113) procedure (set>? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set other than the last is a proper superset of the following set, and #f otherwise.
(srfi 113) procedure (set<=? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set other than the last is a subset of the following set, and #f otherwise.
(srfi 113) procedure (set>=? (set1 set?) (set2 set?) ... ) ⟹ boolean?
Returns #t if each set other than the last is a superset of the following set, and #f otherwise.
(srfi 113) procedure (set-union (set1 set?) (set2 set?) ... ) ⟹ set?
Return a newly allocated set that is the union of the sets.
(srfi 113) procedure (set-intersection (set1 set?) (set2 set?) ... ) ⟹ set?
Return a newly allocated set that is the intersection of the sets.
(srfi 113) procedure (set-difference (set1 set?) (set2 set?) ... ) ⟹ set?
Return a newly allocated set that is the asymmetric difference of the sets. Asymmetric difference is extended to more than two sets by taking the difference between the first set and the union of the others.
(srfi 113) procedure (set-xor (set1 set?) (set2 set?) ) ⟹ set?
Return a newly allocated set that is the symmetric difference of the sets. Symmetric difference is not extended beyond two sets. Elements in the result set are drawn from the first set in which they appear.
(srfi 113) procedure (set-union! (set1 set?) (set2 set?) ... ) ⟹ set?
Linear update returning a set that is the union of the sets.
(srfi 113) procedure (set-intersection! (set1 set?) (set2 set?) ... ) ⟹ set?
Linear update returning a set that is the intersection of the sets.
(srfi 113) procedure (set-difference! (set1 set?) (set2 set?) ... ) ⟹ set?
Linear update returning a set that is the asymmetric difference of the sets. Asymmetric difference is extended to more than two sets by taking the difference between the first set and the union of the others.
(srfi 113) procedure (set-xor! (set1 set?) (set2 set?) ) ⟹ set?
Linear update returning a set that is the symmetric difference of the sets. Symmetric difference is not extended beyond two sets. Elements in the result set are drawn from the first set in which they appear.
(srfi 113) procedure (bag (comparator comparator?) element ... ) ⟹ bag?
Returns a newly allocated empty bag. The comparator argument is a SRFI 114 comparator, which is used to control and distinguish the elements of the bag. The elements are used to initialize the bag.
(srfi 113) procedure (bag-unfold (comparator comparator?) (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ bag?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Create a newly allocated bag as if by bag using comparator. If the result of applying the predicate stop? to seed is true, return the bag. Otherwise, apply the procedure mapper to seed. The value that mapper returns is added to the bag. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
(srfi 113) procedure (bag? obj ) ⟹ boolean?
Returns #t if obj is a bag, and #f otherwise.
(srfi 113) procedure (bag-contains? (bag bag?) element ) ⟹ boolean?
Returns #t if element is a member of bag and #f otherwise.
(srfi 113) procedure (bag-empty? (bag bag?) ) ⟹ boolean?
Returns #t if bag has no elements and #f otherwise.
(srfi 113) procedure (bag-disjoint? (bag1 bag?) (bag2 bag?) ) ⟹ boolean?
Returns #t if bag1 and bag2 have no elements in common and #f otherwise.
(srfi 113) procedure (bag-member (bag bag?) element default ) ⟹ *
Returns the element of bag that is equal, in the sense of bag's equality predicate, to element. If element is not a member of bag, default is returned.
(srfi 113) procedure (bag-element-comparator (bag bag?) ) ⟹ comparator?
Returns the comparator used to compare the elements of bag.
(srfi 113) procedure (bag-adjoin (bag bag?) element ... ) ⟹ bag?
The bag-adjoin procedure returns a newly allocated bag that uses the same comparator as bag and contains all the values of bag, and in addition each element unless it is already equal (in the sense of the comparator) to one of the existing or newly added members. It is an error to add an element to bag that does not return #t when passed to the type test procedure of the comparator.
(srfi 113) procedure (bag-adjoin! (bag bag?) element ... ) ⟹ bag?
The bag-adjoin! procedure is the same as bag-adjoin, except that it is permitted to mutate and return the bag argument rather than allocating a new bag.
(srfi 113) procedure (bag-replace (bag bag?) element ) ⟹ bag?
The bag-replace procedure returns a newly allocated bag that uses the same comparator as bag and contains all the values of bag except as follows: If element is equal (in the sense of bag's comparator) to an existing member of bag, then that member is omitted and replaced by element. If there is no such element in bag, then bag is returned unchanged.
(srfi 113) procedure (bag-replace! (bag bag?) element ) ⟹ bag?
The bag-replace! procedure is the same as bag-replace, except that it is permitted to mutate and return the bag argument rather than allocating a new bag.
(srfi 113) procedure (bag-delete (bag bag?) element ... ) ⟹ bag?
The bag-delete procedure returns a newly allocated bag containing all the values of bag except for any that are equal (in the sense of bag's comparator) to one or more of the elements. Any element that is not equal to some member of the bag is ignored.
(srfi 113) procedure (bag-delete! (bag bag?) element ... ) ⟹ bag?
The bag-delete! procedure is the same as bag-delete, except that it is permitted to mutate and return the bag argument rather than allocating a new bag.
(srfi 113) procedure (bag-delete-all (bag bag?) (elements list?) ) ⟹ bag?
The bag-delete-all procedure is the same as bag-delete, except that it accepts a single argument which is a list of elements to be deleted.
(srfi 113) procedure (bag-delete-all! (bag bag?) (elements list?) ) ⟹ bag?
The bag-delete-all! procedure is the same as bag-delete!, except that it accepts a single argument which is a list of elements to be deleted.
(srfi 113) procedure (bag-search! (bag bag?) element (failure procedure?) (success procedure?) ) ⟹ (values bag?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert obj ) ⟹ *
(ignore obj ) ⟹ *
(success element (update procedure?) (remove procedure?) ) ⟹ *
(update new-element obj ) ⟹ *
(remove obj ) ⟹ *
The bag is searched for element. If it is not found, then the failure procedure is tail-called with two continuation arguments, insert and ignore, and is expected to tail-call one of them. If element is found, then the success procedure is tail-called with the matching element of bag and two continuations, update and remove, and is expected to tail-call one of them. The effects of the continuations are as follows (where obj is any Scheme object):
In all cases, two values are returned: the possibly updated bag and obj.
(srfi 113) procedure (bag-size (bag bag?) ) ⟹ integer?
Returns the number of elements in bag as an exact integer.
(srfi 113) procedure (bag-find (predicate procedure?) (bag bag?) (failure procedure?) ) ⟹ *
(predicate obj ) ⟹ boolean?
(failure ) ⟹ *
Returns an arbitrarily chosen element of bag that satisfies predicate, or the result of invoking failure with no arguments if there is none.
(srfi 113) procedure (bag-count (predicate procedure?) (bag bag?) ) ⟹ integer?
(predicate obj ) ⟹ boolean?
Returns the number of elements of bag that satisfy predicate as an exact integer.
(srfi 113) procedure (bag-any? (predicate procedure?) (bag bag?) ) ⟹ boolean?
(predicate obj ) ⟹ boolean?
Returns #t if any element of bag satisfies predicate, or #f otherwise. Note that this differs from the SRFI 1 analogue because it does not return an element of the bag.
(srfi 113) procedure (bag-every? (predicate procedure?) (bag bag?) ) ⟹ boolean?
(predicate obj ) ⟹ boolean?
Returns #t if every element of bag satisfies predicate, or #f otherwise. Note that this differs from the SRFI 1 analogue because it does not return an element of the bag.
(srfi 113) procedure (bag-map (comparator comparator?) (proc procedure?) (bag bag?) ) ⟹ *
(proc obj ) ⟹ *
Applies proc to each element of bag in arbitrary order and returns a newly allocated bag, created as if by (bag comparator), which contains the results of the applications. For example:
(bag-map string-ci-comparator symbol->string (bag eq? 'foo 'bar 'baz)) => (bag string-ci-comparator "foo" "bar" "baz")
Note that, when proc defines a mapping that is not 1:1, some of the mapped objects may be equivalent in the sense of comparator's equality predicate, and in this case duplicate elements are omitted as in the bag constructor.
(srfi 113) procedure (bag-for-each (proc procedure?) (bag bag?) ) ⟹ undefined
(proc obj ) ⟹ undefined
Applies proc to bag in arbitrary order, discarding the returned values. Returns an unspecified result.
(srfi 113) procedure (bag-fold (proc procedure?) nil (bag bag?) ) ⟹ *
(proc obj state ) ⟹ *
Invokes proc on each member of bag in arbitrary order, passing the result of the previous invocation as a second argument. For the first invocation, nil is used as the second argument. Returns the result of the last invocation, or nil if there was no invocation.
(srfi 113) procedure (bag-filter (predicate procedure?) (bag bag?) ) ⟹ bag?
(predicate obj ) ⟹ *
Returns a newly allocated bag with the same comparator as bag, containing just the elements of bag that satisfy predicate.
(srfi 113) procedure (bag-filter! (predicate procedure?) (bag bag?) ) ⟹ bag?
(predicate obj ) ⟹ *
A linear update procedure that returns a bag containing just the elements of bag that satisfy predicate.
(srfi 113) procedure (bag-remove (predicate procedure?) (bag bag?) ) ⟹ bag?
(predicate obj ) ⟹ *
Returns a newly allocated bag with the same comparator as bag, containing just the elements of bag that do not satisfy predicate.
(srfi 113) procedure (bag-remove! (predicate procedure?) (bag bag?) ) ⟹ bag?
(predicate obj ) ⟹ *
A linear update procedure that returns a bag containing just the elements of bag that do not satisfy predicate.
(srfi 113) procedure (bag-partition (predicate procedure?) (bag bag?) ) ⟹ (values bag?bag?)
(predicate obj ) ⟹ *
Returns two values: a newly allocated bag with the same comparator as bag that contains just the elements of bag that satisfy predicate, and another newly allocated bag, also with the same comparator, that contains just the elements of bag that do not satisfy predicate.
(srfi 113) procedure (bag-partition! (predicate procedure?) (bag bag?) ) ⟹ (values bag?bag?)
(predicate obj ) ⟹ *
A linear update procedure that returns two bags containing the elements of bag that do and do not, respectively, not satisfy predicate.
(srfi 113) procedure (bag-copy (bag bag?) ) ⟹ bag?
Returns a newly allocated bag containing the elements of bag, and using the same comparator.
(srfi 113) procedure (bag->list (bag bag?) ) ⟹ list?
Returns a newly allocated list containing the members of bag in unspecified order.
(srfi 113) procedure (list->bag (comparator comparator?) (list list?) ) ⟹ bag?
Returns a newly allocated bag, created as if by bag using comparator, that contains the elements of list. Duplicate elements (in the sense of the equality predicate) are omitted.
(srfi 113) procedure (list->bag! (bag bag?) (list list?) ) ⟹ bag?
Returns a bag that contains the elements of both bag and list. Duplicate elements (in the sense of the equality predicate) are omitted.
(srfi 113) procedure (bag=? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag contains the same elements.
(srfi 113) procedure (bag<? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag other than the last is a proper subbag of the following bag, and #f otherwise.
(srfi 113) procedure (bag>? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag other than the last is a proper superbag of the following bag, and #f otherwise.
(srfi 113) procedure (bag<=? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag other than the last is a subbag of the following bag, and #f otherwise.
(srfi 113) procedure (bag>=? (bag1 bag?) (bag2 bag?) ... ) ⟹ boolean?
Returns #t if each bag other than the last is a superbag of the following bag, and #f otherwise.
(srfi 113) procedure (bag-union (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Return a newly allocated bag that is the union of the bags.
(srfi 113) procedure (bag-intersection (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Return a newly allocated bag that is the intersection of the bags.
(srfi 113) procedure (bag-difference (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Return a newly allocated bag that is the asymmetric difference of the bags. Asymmetric difference is extended to more than two bags by taking the difference between the first bag and the union of the others.
(srfi 113) procedure (bag-xor (bag1 bag?) (bag2 bag?) ) ⟹ bag?
Return a newly allocated bag that is the symmetric difference of the bags. Symmetric difference is not extended beyond two bags. Elements in the result bag are drawn from the first bag in which they appear.
(srfi 113) procedure (bag-union! (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Linear update returning a bag that is the union of the bags.
(srfi 113) procedure (bag-intersection! (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Linear update returning a bag that is the intersection of the bags.
(srfi 113) procedure (bag-difference! (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Linear update returning a bag that is the asymmetric difference of the bags. Asymmetric difference is extended to more than two bags by taking the difference between the first bag and the union of the others.
(srfi 113) procedure (bag-xor! (bag1 bag?) (bag2 bag?) ) ⟹ bag?
Linear update returning a bag that is the symmetric difference of the bags. Symmetric difference is not extended beyond two bags. Elements in the result bag are drawn from the first bag in which they appear.
(srfi 113) procedure (bag-sum (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
The bag-sum procedure returns a newly allocated bag containing all the unique elements in all the bags, such that the count of each unique element in the result is equal to the sum of the counts of that element in the arguments. It differs from bag-union by treating identical elements as potentially distinct rather than attempting to match them up.
(srfi 113) procedure (bag-sum! (bag1 bag?) (bag2 bag?) ... ) ⟹ bag?
Linear update returning a bag containing all the unique elements in all the bags, such that the count of each unique element in the result is equal to the sum of the counts of that element in the arguments. It differs from bag-union by treating identical elements as potentially distinct rather than attempting to match them up.
(srfi 113) procedure (bag-product (n integer?) (bag bag?) ) ⟹ bag?
The bag-product procedure returns a newly allocated bag containing all the unique elements in bag, where the count of each unique element in the bag is equal to the count of that element in bag multiplied by n.
(srfi 113) procedure (bag-product! (n integer?) (bag bag?) ) ⟹ bag?
Linear update returning a bag containing all the unique elements in bag, where the count of each unique element in the bag is equal to the count of that element in bag multiplied by n.
(srfi 113) procedure (bag-unique-size (bag bag?) ) ⟹ integer?
Returns the number of unique elements of bag.
(srfi 113) procedure (bag-element-count (bag bag?) element ) ⟹ integer?
Returns an exact integer representing the number of times that element appears in bag.
(srfi 113) procedure (bag-for-each-unique (proc procedure?) (bag bag?) ) ⟹ undefined
(proc obj ) ⟹ undefined
Applies proc to each unique element of bag in arbitrary order, passing the element and the number of times it occurs in bag, and discarding the returned values. Returns an unspecified result.
(srfi 113) procedure (bag-fold-unique (proc procedure?) nil (bag bag?) ) ⟹ *
(proc obj state ) ⟹ *
Invokes proc on each unique element of bag in arbitrary order, passing the number of occurrences as a second argument and the result of the previous invocation as a third argument. For the first invocation, nil is used as the third argument. Returns the result of the last invocation.
(srfi 113) procedure (bag-increment! (bag bag?) element count ) ⟹ bag?
Linear update procedure that returns a bag with the same elements as bag, but with the element count of element in bag increased by the exact integer count (but not less than zero).
(srfi 113) procedure (bag-decrement! (bag bag?) element count ) ⟹ bag?
Linear update procedure that returns a bag with the same elements as bag, but with the element count of element in bag decreased by the exact integer count (but not less than zero).
(srfi 113) procedure (bag->set (bag bag?) ) ⟹ set?
The bag->set procedure returns a newly allocated set containing the unique elements (in the sense of the equality predicate) of bag.
(srfi 113) procedure (set->bag (set set?) ) ⟹ bag?
The set->bag procedure returns a newly allocated bag containing the elements of set.
(srfi 113) procedure (set->bag! (set set?) ) ⟹ bag?
The set->bag! procedure returns a bag containing the elements of both bag and set.
(srfi 113) procedure (bag->alist (bag bag?) ) ⟹ list?
The bag->alist procedure returns a newly allocated alist whose keys are the unique elements of bag and whose values are the number of occurrences of each element.
(srfi 113) procedure (alist->bag (comparator comparator?) (alist list?) ) ⟹ bag?
The alist->bag returning a newly allocated bag based on comparator, where the keys of alist specify the elements and the corresponding values of alist specify how many times they occur.
set-comparator ⟹ comparator?
Set comparator. The comparator does not provide comparison procedures, as there is no ordering between sets. It is an error to compare sets with different element comparators.
bag-comparator ⟹ comparator?
Bag comparator. The comparator does not provide comparison procedures, as there is no ordering between bags. It is an error to compare bags with different element comparators.
library (srfi 115)
(srfi 115) procedure (regexp re ) ⟹ regexp?
Compiles a regexp if given an object whose structure matches the SRE syntax. This may be written as a literal or partial literal with quote or quasiquote, or may be generated entirely programmatically. Returns re unmodified if it is already a regexp. Raises an error if re is neither a regexp nor a valid representation of an SRE.
Mutating re may invalidate the resulting regexp, causing unspecified results if subsequently used for matching.
SRE syntax:
<sre> ::=
| <string> ; A literal string match.
| <cset-sre> ; A character set match.
| (* <sre> ...) ; 0 or more matches.
| (zero-or-more <sre> ...)
| (+ <sre> ...) ; 1 or more matches.
| (one-or-more <sre> ...)
| (? <sre> ...) ; 0 or 1 matches.
| (optional <sre> ...)
| (= <n> <sre> ...) ; <n> matches.
| (exactly <n> <sre> ...)
| (>= <n> <sre> ...) ; <n> or more matches.
| (at-least <n> <sre> ...)
| (** <n> <m> <sre> ...) ; <n> to <m> matches.
| (repeated <n> <m> <sre> ...)
| (| <sre> ...) ; Alternation.
| (or <sre> ...)
| (: <sre> ...) ; Sequence.
| (seq <sre> ...)
| ($ <sre> ...) ; Numbered submatch.
| (submatch <sre> ...)
| (-> <name> <sre> ...) ; Named submatch. <name> is
| (submatch-named <name> <sre> ...) ; a symbol.
| (w/case <sre> ...) ; Introduce a case-sensitive context.
| (w/nocase <sre> ...) ; Introduce a case-insensitive context.
| (w/unicode <sre> ...) ; Introduce a unicode context.
| (w/ascii <sre> ...) ; Introduce an ascii context.
| (w/nocapture <sre> ...) ; Ignore all enclosed submatches.
| bos ; Beginning of string.
| eos ; End of string.
| bol ; Beginning of line.
| eol ; End of line.
| bog ; Beginning of grapheme cluster.
| eog ; End of grapheme cluster.
| grapheme ; A single grapheme cluster.
| bow ; Beginning of word.
| eow ; End of word.
| nwb ; A non-word boundary.
| (word <sre> ...) ; An SRE wrapped in word boundaries.
| (word+ <cset-sre> ...) ; A single word restricted to a cset.
| word ; A single word.
| (?? <sre> ...) ; A non-greedy pattern, 0 or 1 match.
| (non-greedy-optional <sre> ...)
| (*? <sre> ...) ; Non-greedy 0 or more matches.
| (non-greedy-zero-or-more <sre> ...)
| (**? <m> <n> <sre> ...) ; Non-greedy <m> to <n> matches.
| (non-greedy-repeated <sre> ...)
| (look-ahead <sre> ...) ; Zero-width look-ahead assertion.
| (look-behind <sre> ...) ; Zero-width look-behind assertion.
| (neg-look-ahead <sre> ...) ; Zero-width negative look-ahead assertion.
| (neg-look-behind <sre> ...) ; Zero-width negative look-behind assertion.
| (backref <n-or-name>) ; Match a previous submatch.
The grammar for cset-sre is as follows.
<cset-sre> ::=
| <char> ; literal char
| "<char>" ; string of one char
| <char-set> ; embedded SRFI 14 char set
| (<string>) ; literal char set
| (char-set <string>)
| (/ <range-spec> ...) ; ranges
| (char-range <range-spec> ...)
| (or <cset-sre> ...) ; union
| (|\|| <cset-sre> ...)
| (and <cset-sre> ...) ; intersection
| (& <cset-sre> ...)
| (- <cset-sre> ...) ; difference
| (- <difference> ...)
| (~ <cset-sre> ...) ; complement of union
| (complement <cset-sre> ...)
| (w/case <cset-sre> ...) ; case and unicode toggling
| (w/nocase <cset-sre> ...)
| (w/ascii <cset-sre> ...)
| (w/unicode <cset-sre> ...)
| any | nonl | ascii | lower-case | lower
| upper-case | upper | title-case | title
| alphabetic | alpha | alphanumeric | alphanum | alnum
| numeric | num | punctuation | punct | symbol
| graphic | graph | whitespace | white | space
| printing | print | control | cntrl | hex-digit | xdigit
<range-spec> ::= <string> | <char>
(srfi 115) syntax (rx (* one-or-more ? optional = exactly at-least ** repeated | or : seq $ submatch -> sumatch-named w/case w/nocase w/unicode w/ascii w/nocapture bos eos bol eol bog eog grapheme bow eow nwb word word+ ?? non-greedy-optional *? non-greedy-zero-or-more **? non-greedy-repeated look-ahead look-behind neg-look-ahead neg-look-behind backref ) ((_ sre ...) regexp? ) )
string charset (* sre ...) (one-or-more sre ...) (? sre ...) (optional sre ...) (= n sre ...) (exactly n sre ...) (>= n sre ...) (at-least n sre ...) (** n m sre ...) (repeated n m sre ...) (|\|| sre ...) (or sre ...) (: sre ...) (seq sre ...) ($ sre ...) (submatch sre ...) (-> name sre ...) (submatch-named name sre ...) (w/case sre ...) (w/nocase sre ...) (w/unicode sre ...) (w/ascii sre ...) (w/nocapture sre ...) bos eos bol eol bog eog grapheme bow eow nwb (word sre ...) (word+ cset-sre ...) word (?? sre ...) (non-greedy-optional sre ...) (*? sre ...) (non-greedy-zero-or-more sre ...) (**? m n sre ...) (non-greedy-repeated sre ...) (look-ahead sre ...) (look-behind sre ...) (neg-look-ahead sre ...) (neg-look-behind sre ...) (backref n-or-name)
Macro shorthand for (regexp `(: sre ...)). May be able to perform some or all computation at compile time if sre is not unquoted. Note because of this equivalence with the procedural constructor regexp, the semantics of unquote differs from the original SCSH implementation in that unquoted expressions can expand into any object matching the SRE syntax, but not a compiled regexp object. Further, unquote and unquote-splicing both expand all matches.
(srfi 115) procedure (regexp->sre (re regexp?) ) ⟹ *
Returns an SRE corresponding to the given regexp re. The SRE will be equivalent to (will match the same strings) but not necessarily equal? to the SRE originally used to compile re. Mutating the result may invalidate re, causing unspecified results if subsequently used for matching.
(srfi 115) procedure (char-set->sre (char-set charset?) ) ⟹ *
Returns an SRE corresponding to the given SRFI 14 character set. The resulting SRE expands the character set into notation which does not make use of embedded SRFI 14 character sets, and so is suitable for writing portably.
(srfi 115) procedure (valid-sre? obj ) ⟹ boolean?
Returns true iff obj can be safely passed to regexp.
(srfi 115) procedure (regexp? obj ) ⟹ boolean?
Returns true iff obj is a regexp.
(srfi 115) procedure (regexp-matches re (str string?) ) ⟹ regexp-match? / #f /
(srfi 115) procedure (regexp-matches re (str string?) (start integer?) ) ⟹ regexp-match? / #f /
(srfi 115) procedure (regexp-matches re (str string?) (start integer?) (end integer?) ) ⟹ regexp-match? / #f /
Returns an regexp-match object if re successfully matches the entire string str from start (inclusive) to end (exclusive), or #f is the match fails. The regexp-match object will contain information needed to extract any submatches.
(srfi 115) procedure (regexp-matches? re (str string?) ) ⟹ boolean?
(srfi 115) procedure (regexp-matches? re (str string?) (start integer?) ) ⟹ boolean?
(srfi 115) procedure (regexp-matches? re (str string?) (start integer?) (end integer?) ) ⟹ boolean?
Returns #t if re matches str as in regexp-matches, or #f otherwise. May be faster than regexp-matches since it doesn't need to return submatch data.
(srfi 115) procedure (regexp-search re (str string?) ) ⟹ regexp-match? / #f /
(srfi 115) procedure (regexp-search re (str string?) (start integer?) ) ⟹ regexp-match? / #f /
(srfi 115) procedure (regexp-search re (str string?) (start integer?) (end integer?) ) ⟹ regexp-match? / #f /
Returns a regexp-match object if re successfully matches a substring of str between start (inclusive) and end (exclusive), or #f if the match fails. The regexp-match object will contain information needed to extract any submatches.
(srfi 115) procedure (regexp-fold re (kons procedure?) knil (str string?) ) ⟹ *
(srfi 115) procedure (regexp-fold re (kons procedure?) knil (str string?) (finish procedure?) ) ⟹ *
(srfi 115) procedure (regexp-fold re (kons procedure?) knil (str string?) (finish procedure?) (start integer?) ) ⟹ *
(srfi 115) procedure (regexp-fold re (kons procedure?) knil (str string?) (finish procedure?) (start integer?) (end integer?) ) ⟹ *
(kons (i integer?) (match regexp-match?) (str string?) acc ) ⟹ *
(finish (i integer?) (match #f) (str string?) acc ) ⟹ *
The fundamental regexp matching iterator. Repeatedly searches str for the regexp re so long as a match can be found. On each successful match, applies (kons i regexp-match str acc) where i is the index since the last match (beginning with start), regexp-match is the resulting match, and acc is the result of the previous kons application, beginning with knil. When no more matches can be found, calls finish with the same arguments, except that regexp-match is #f.
By default finish just returns acc.
(srfi 115) procedure (regexp-extract re (str string?) ) ⟹ list?
(srfi 115) procedure (regexp-extract re (str string?) (start integer?) ) ⟹ list?
(srfi 115) procedure (regexp-extract re (str string?) (start integer?) (end integer?) ) ⟹ list?
Extracts all non-empty substrings of str which match re between start and end as a list of strings.
(srfi 115) procedure (regexp-split re (str string?) ) ⟹ list?
(srfi 115) procedure (regexp-split re (str string?) (start integer?) ) ⟹ list?
(srfi 115) procedure (regexp-split re (str string?) (start integer?) (end integer?) ) ⟹ list?
Splits str into a list of (possibly empty) strings separated by non-empty matches of re.
(srfi 115) procedure (regexp-partition re (str string?) ) ⟹ list?
(srfi 115) procedure (regexp-partition re (str string?) (start integer?) ) ⟹ list?
(srfi 115) procedure (regexp-partition re (str string?) (start integer?) (end integer?) ) ⟹ list?
Partitions str into a list of non-empty strings matching re, interspersed with the unmatched portions of the string. The first and every odd element is an unmatched substring, which will be the empty string if re matches at the beginning of the string or end of the previous match. The second and every even element will be a substring matching re. If the final match ends at the end of the string, no trailing empty string will be included. Thus, in the degenerate case where str is the empty string, the result is ("").
Note that regexp-partition is equivalent to interleaving the results of regexp-split and regexp-extract, starting with the former.
(srfi 115) procedure (regexp-replace re (str string?) (subst (or string?integer?symbol?)) ) ⟹ string?
(srfi 115) procedure (regexp-replace re (str string?) (subst (or string?integer?symbol?)) (start integer?) ) ⟹ string?
(srfi 115) procedure (regexp-replace re (str string?) (subst (or string?integer?symbol?)) (start integer?) (end integer?) ) ⟹ string?
(srfi 115) procedure (regexp-replace re (str string?) (subst (or string?integer?symbol?)) (start integer?) (end integer?) (count integer?) ) ⟹ string?
Returns a new string replacing the countth match of re in str the subst, where the zero-indexed count defaults to zero (i.e. the first match). If there are not count matches, returns the selected substring unmodified.
subst can be a string, an integer or symbol indicating the contents of a numbered or named submatch of re, 'pre for the substring to the left of the match, or 'post for the substring to the right of the match.
The optional parameters start and end restrict both the matching and the substitution, to the given indices, such that the result is equivalent to omitting these parameters and replacing on (substring str start end). As a convenience, a value of #f for end is equivalent to (string-length str).
(srfi 115) procedure (regexp-replace-all re (str string?) (subst (or string?integer?symbol?)) (start integer?) ) ⟹ string?
(srfi 115) procedure (regexp-replace-all re (str string?) (subst (or string?integer?symbol?)) (start integer?) (end integer?) ) ⟹ string?
Equivalent to regexp-replace, but replaces all occurrences of re in str.
(srfi 115) procedure (regexp-match? obj ) ⟹ boolean?
Returns true iff obj is a successful match from regexp-matches or regexp-search.
(srfi 115) procedure (regexp-match-count (obj regexp-match?) ) ⟹ integer?
Returns the number of submatches of regexp-match, regardless of whether they matched or not. Does not include the implicit zero full match in the count.
(srfi 115) procedure (regexp-match-submatch (obj regexp-match?) (field (or integer?symbol?)) ) ⟹ string? / #f /
Returns the substring matched in regexp-match corresponding to field, either an integer or a symbol for a named submatch. Index 0 refers to the entire match, index 1 to the first lexicographic submatch, and so on. If there are multiple submatches with the same name, the first which matched is returned. If passed an integer outside the range of matches, or a symbol which does not correspond to a named submatch of the pattern, it is an error. If the corresponding submatch did not match, returns false.
The result of extracting a submatch after the original matched string has been mutated is unspecified.
(srfi 115) procedure (regexp-match-submatch-start (obj regexp-match?) (field (or integer?symbol?)) ) ⟹ integer? / #f /
Returns the start index regexp-match corresponding to field, as in regexp-match-submatch.
(srfi 115) procedure (regexp-match-submatch-end (obj regexp-match?) (field (or integer?symbol?)) ) ⟹ integer? / #f /
Returns the end index in regexp-match corresponding to field, as in regexp-match-submatch.
(srfi 115) procedure (regexp-match->list (obj regexp-match?) ) ⟹ list?
Returns a list of all submatches in regexp-match as string or false, beginning with the entire match 0.
library (srfi 116)
(srfi 116) syntax (iq () ((_ datum ...) ilist? ) )
iq is partly analogous to quote, taking an arbitrary number of literals and constructing an ilist from them, with any pairs in the literals converted to ipairs. It is useful for providing constant ipair-based objects. Note that pairs within literal vectors or other implementation-dependent literals will not be converted. Unfortunately, there is no ilist analogue of ', so we save keystrokes by using iq rather than iquote and omitting the top-level parentheses.
(srfi 116) procedure (ipair a d ) ⟹ ipair?
The primitive constructor. Returns a newly allocated ipair whose icar is a and whose icdr is d. The ipair is guaranteed to be different (in the sense of eqv?) from every existing object.
(srfi 116) procedure (ilist object ... ) ⟹ ilist?
Returns a newly allocated ilist of its arguments.
(srfi 116) procedure (xipair d a ) ⟹ ipair?
(lambda (d a) (ipair a d))
Of utility only as a value to be conveniently passed to higher-order procedures.
(srfi 116) procedure (ipair* elt1 elt2 ... ) ⟹ *
Like ilist, but the last argument provides the tail of the constructed ilist
(srfi 116) procedure (make-ilist (n integer?) ) ⟹ ilist?
(srfi 116) procedure (make-ilist (n integer?) fill ) ⟹ ilist?
Returns an n-element ilist, whose elements are all the value fill. If the fill argument is not given, the elements of the ilist may be arbitrary values.
(srfi 116) procedure (ilist-tabulate (n integer?) (init-proc procedure?) ) ⟹ ilist?
(init-proc (i integer?) ) ⟹ *
Returns an n-element ilist. Element i of the ilist, where 0 <= i < n, is produced by (init-proc i). No guarantee is made about the dynamic order in which init-proc is applied to these indices.
(srfi 116) procedure (ilist-copy (dilist ilist?) ) ⟹ ilist?
(srfi 116) procedure (ilist-copy (dilist dotted-ilist?) ) ⟹ dotted-ilist?
Copies the spine of the argument, including the ilist tail.
(srfi 116) procedure (iiota (count integer?) ) ⟹ ilist?
(srfi 116) procedure (iiota (count integer?) (start number?) ) ⟹ ilist?
(srfi 116) procedure (iiota (count integer?) (start number?) (step number?) ) ⟹ ilist?
Returns an ilist containing the elements
(start start+step ... start+(count-1)*step)
The start and step parameters default to 0 and 1, respectively. This procedure takes its name from the APL primitive.
(srfi 116) procedure (proper-ilist? obj ) ⟹ boolean?
(srfi 116) procedure (ilist? obj ) ⟹ boolean?
These identifiers are bound either to the same procedure, or to procedures of equivalent behavior. In either case, true is returned iff x is a proper ilist — a ()-terminated ilist.
More carefully: The empty list is a proper ilist. An ipair whose icdr is a proper ilist is also a proper ilist. Everything else is a dotted ilist. This includes non-ipair, non-() values (e.g. symbols, numbers, mutable pairs), which are considered to be dotted ilists of length 0.
(srfi 116) procedure (dotted-ilist? obj ) ⟹ boolean?
True if x is a finite, non-nil-terminated ilist. That is, there exists an n >= 0 such that icdrn(x) is neither an ipair nor (). This includes non-ipair, non-() values (e.g. symbols, numbers), which are considered to be dotted ilists of length 0.
(srfi 116) procedure (ipair? obj ) ⟹ boolean?
Returns #t if object is an ipair; otherwise, #f.
(srfi 116) procedure (null-ilist? (lst ilist?) ) ⟹ boolean?
Ilist is a proper ilist. This procedure returns true if the argument is the empty list (), and false otherwise. It is an error to pass this procedure a value which is not a proper ilist. This procedure is recommended as the termination condition for ilist-processing procedures that are not defined on dotted ilists.
(srfi 116) procedure (not-ipair? obj ) ⟹ boolean?
(lambda (x) (not (ipair? x)))
Provided as a procedure as it can be useful as the termination condition for ilist-processing procedures that wish to handle all ilists, both proper and dotted.
(srfi 116) procedure (ilist= (elt= procedure?) (ilist1 ilist?) ... ) ⟹ boolean?
(elt= a b ) ⟹ *
Determines ilist equality, given an element-equality procedure. Proper ilist A equals proper ilist B if they are of the same length, and their corresponding elements are equal, as determined by elt=. If the element-comparison procedure's first argument is from ilisti, then its second argument is from ilisti+1, i.e. it is always called as (elt= a b) for a an element of ilist A, and b an element of ilist B.
In the n-ary case, every ilisti is compared to ilisti+1 (as opposed, for example, to comparing ilist1 to ilisti, for i>1). If there are no ilist arguments at all, ilist= simply returns true.
It is an error to apply ilist= to anything except proper ilists. It cannot reasonably be extended to dotted ilists, as it provides no way to specify an equality procedure for comparing the ilist terminators.
Note that the dynamic order in which the elt= procedure is applied to pairs of elements is not specified. For example, if ilist= is applied to three ilists, A, B, and C, it may first completely compare A to B, then compare B to C, or it may compare the first elements of A and B, then the first elements of B and C, then the second elements of A and B, and so forth.
The equality procedure must be consistent with eq?. That is, it must be the case that
(eq? x y) => (elt= x y).
Note that this implies that two ilists which are eq? are always ilist=, as well; implementations may exploit this fact to "short-cut" the element-by-element comparisons.
(srfi 116) procedure (icar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdr (ipair ipair?) ) ⟹ *
These procedures return the contents of the icar and icdr field of their argument, respectively. Note that it is an error to apply them to the empty ilist.
(srfi 116) procedure (icaar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icadr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icddr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icaaaar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icaaadr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icaaar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icaadar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icaaddr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icaadr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icadaar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icadadr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icadar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icaddar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icadddr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icaddr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdaaar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdaadr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdaar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdadar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdaddr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdadr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icddaar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icddadr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icddar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdddar (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icddddr (ipair ipair?) ) ⟹ *
(srfi 116) procedure (icdddr (ipair ipair?) ) ⟹ *
These procedures are compositions of icar and icdr, where for example icaddr could be defined by
(define icaddr (lambda (x) (icar (icdr (icdr x))))).
Arbitrary compositions, up to four deep, are provided. There are twenty-eight of these procedures in all.
(srfi 116) procedure (ilist-ref (ilist ilist?) (i integer?) ) ⟹ *
Returns the ith element of ilist. (This is the same as the icar of (idrop ilist i).) It is an error if i >= n, where n is the length of ilist.
(srfi 116) procedure (ifirst (ipair ipair?) ) ⟹ *
(srfi 116) procedure (isecond (ipair ipair?) ) ⟹ *
(srfi 116) procedure (ithird (ipair ipair?) ) ⟹ *
(srfi 116) procedure (ifourth (ipair ipair?) ) ⟹ *
(srfi 116) procedure (ififth (ipair ipair?) ) ⟹ *
(srfi 116) procedure (isixth (ipair ipair?) ) ⟹ *
(srfi 116) procedure (iseventh (ipair ipair?) ) ⟹ *
(srfi 116) procedure (ieighth (ipair ipair?) ) ⟹ *
(srfi 116) procedure (ininth (ipair ipair?) ) ⟹ *
(srfi 116) procedure (itenth (ipair ipair?) ) ⟹ *
Synonyms for car, cadr, caddr, ...
(srfi 116) procedure (icar+icdr (ipair ipair?) ) ⟹ (values **)
The fundamental ipair deconstructor:
(lambda (p) (values (icar p) (icdr p)))
This can, of course, be implemented more efficiently by a compiler.
(srfi 116) procedure (itake (x ilist?) (i integer?) ) ⟹ ilist?
(srfi 116) procedure (itake (x dotted-ilist?) (i integer?) ) ⟹ ilist?
itake returns the first i elements of ilist x.
(srfi 116) procedure (idrop (x ilist?) (i integer?) ) ⟹ ilist?
(srfi 116) procedure (idrop (x dotted-ilist?) (i integer?) ) ⟹ *
(srfi 116) procedure (ilist-tail (x ilist?) (i integer?) ) ⟹ ilist?
(srfi 116) procedure (ilist-tail (x dotted-ilist?) (i integer?) ) ⟹ *
idrop / ilist-tail returns all but the first i elements of ilist x.
(srfi 116) procedure (itake-right (dilist ilist?) (i integer?) ) ⟹ ilist?
(srfi 116) procedure (itake-right (dilist dotted-ilist?) (i integer?) ) ⟹ *
itake-right returns the last i elements of dilist.
(srfi 116) procedure (idrop-right (dilist ilist?) (i integer?) ) ⟹ ilist?
(srfi 116) procedure (idrop-right (dilist dotted-ilist?) (i integer?) ) ⟹ ilist?
idrop-right returns all but the last i elements of dilist.
(srfi 116) procedure (isplit-at (x ilist?) (i integer?) ) ⟹ (values ilist?ilist?)
(srfi 116) procedure (isplit-at (x dotted-ilist?) (i integer?) ) ⟹ (values ilist?*)
isplit-at splits the ilist x at index i, returning an ilist of the first i elements, and the remaining tail. It is equivalent to
(values (itake x i) (idrop x i))
(srfi 116) procedure (ilast (ipair ilist?) ) ⟹ *
Returns the last element of the non-empty, possibly dotted, ilist ipair.
(srfi 116) procedure (last-ipair (ipair ilist?) ) ⟹ ipair?
last-ipair returns the last ipair in the non-empty ilist pair.
(srfi 116) procedure (ilength (ilist ilist?) ) ⟹ integer?
Returns the length of its argument. It is an error to pass a value to ilength which is not a proper ilist (()-terminated).
The length of a proper ilist is a non-negative integer n such that icdr applied n times to the ilist produces the empty list.
(srfi 116) procedure (iappend (ilist ilist?) ... ) ⟹ ilist?
(srfi 116) procedure (iappend (ilist ilist?) ... obj ) ⟹ *
Returns an ilist consisting of the elements of ilist1 followed by the elements of the other ilist parameters.
The resulting ilist is always newly allocated, except that it shares structure with the final ilisti argument. This last argument may be any value at all; an improper ilist results if it is not a proper ilist. All other arguments must be proper ilists.
(srfi 116) procedure (iconcatenate (ilist-of-ilists ilist?) ) ⟹ *
Appends the elements of its argument together. That is, iconcatenate returns
(iapply iappend ilist-of-ilists)
or, equivalently,
(ireduce-right iappend '() ilist-of-ilists)
Note that some Scheme implementations do not support passing more than a certain number (e.g., 64) of arguments to an n-ary procedure. In these implementations, the (iapply iappend ...) idiom would fail when applied to long lists, but iconcatenate would continue to function properly.
As with iappend, the last element of the input list may be any value at all.
(srfi 116) procedure (ireverse (ilist ilist?) ) ⟹ ilist?
Returns a newly allocated ilist consisting of the elements of ilist in reverse order.
(srfi 116) procedure (iappend-reverse (rev-head ilist?) (tail ilist?) ) ⟹ ilist?
(srfi 116) procedure (iappend-reverse (rev-head ilist?) tail ) ⟹ *
iappend-reverse returns (iappend (ireverse rev-head) tail). It is provided because it is a common operation — a common list-processing style calls for this exact operation to transfer values accumulated in reverse order onto the front of another ilist, and because the implementation is significantly more efficient than the simple composition it replaces. (But note that this pattern of iterative computation followed by a reverse can frequently be rewritten as a recursion, dispensing with the reverse and iappend-reverse steps, and shifting temporary, intermediate storage from the heap to the stack, which is typically a win for reasons of cache locality and eager storage reclamation.)
(srfi 116) procedure (izip (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(lambda ilists (iapply imap ilist ilists))
If izip is passed n ilists, it returns an ilist as long as the shortest of these ilists, each element of which is an n-element ilist comprised of the corresponding elements from the parameter ilists.
(srfi 116) procedure (iunzip1 (ilist ilist?) ) ⟹ ilist?
(srfi 116) procedure (iunzip2 (ilist ilist?) ) ⟹ (values ilist?ilist?)
(srfi 116) procedure (iunzip3 (ilist ilist?) ) ⟹ (values ilist?ilist?ilist?)
(srfi 116) procedure (iunzip4 (ilist ilist?) ) ⟹ (values ilist?ilist?ilist?ilist?)
(srfi 116) procedure (iunzip5 (ilist ilist?) ) ⟹ (values ilist?ilist?ilist?ilist?ilist?)
iunzip1 takes an ilist of ilists, where every ilist must contain at least one element, and returns an ilist containing the initial element of each such ilist. That is, it returns (imap icar ilists). iunzip2 takes an ilist of ilists, where every ilist must contain at least two elements, and returns two values: an ilist of the first elements, and an ilist of the second elements. iunzip3 does the same for the first three elements of the ilists, and so forth.
(srfi 116) procedure (icount (pred procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ integer?
(pred obj ... ) ⟹ *
pred is a procedure taking as many arguments as there are ilists and returning a single value. It is applied element-wise to the elements of the ilists, and a count is tallied of the number of elements that produce a true value. This count is returned. count is "iterative" in that it is guaranteed to apply pred to the ilist elements in a left-to-right order. The counting stops when the shortest ilist expires.
(srfi 116) procedure (ifold (kons procedure?) knil (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(kons obj1 obj2 ... fold-state ) ⟹ *
The fundamental ilist iterator.
First, consider the single ilist-parameter case. If ilist1 = (e1 e2 ... en), then this procedure returns
(kons en ... (kons e2 (kons e1 knil)) ... )
If n ilist arguments are provided, then the kons function must take n+1 parameters: one element from each ilist, and the "seed" or fold state, which is initially knil. The fold operation terminates when the shortest ilist runs out of values
(srfi 116) procedure (ifold-right (kons procedure?) knil (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(kons obj1 obj2 ... fold-state ) ⟹ *
The fundamental ilist recursion operator.
First, consider the single ilist-parameter case. If ilist1 = (e1 e2 ... en), then this procedure returns
(kons e1 (kons e2 ... (kons en knil)))
If n ilist arguments are provided, then the kons procedure must take n+1 parameters: one element from each ilist, and the "seed" or fold state, which is initially knil. The fold operation terminates when the shortest ilist runs out of values
(srfi 116) procedure (ipair-fold (kons procedure?) knil (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(kons (ipair1 ipair?) (ipair2 ipair?) ... fold-state ) ⟹ *
Analogous to fold, but kons is applied to successive sub-ilists of the ilists, rather than successive elements — that is, kons is applied to the ipairs making up the lists.
(srfi 116) procedure (ipair-fold-right (kons procedure?) knil (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(kons (ipair1 ipair?) (ipair2 ipair?) ... fold-state ) ⟹ *
Holds the same relationship with ifold-right that ipair-fold holds with ifold.
(srfi 116) procedure (ireduce (f procedure?) ridentity (ilist ilist?) ) ⟹ *
(f obj fold-state ) ⟹ *
ireduce is a variant of ifold.
ridentity should be a "right identity" of the procedure f - that is, for any value x acceptable to f,
(f x ridentity) = x
ireduce has the following definition:
If ilist = (), return ridentity;
Otherwise, return (ifold f (icar ilist) (icdr ilist)).
...in other words, we compute (ifold f ridentity ilist).
Note that ridentity is used only in the empty-list case. You typically use ireduce when applying f is expensive and you'd like to avoid the extra application incurred when ifold applies f to the head of ilist and the identity value, redundantly producing the same value passed in to f. For example, if f involves searching a file directory or performing a database query, this can be significant. In general, however, ifold is useful in many contexts where ireduce is not (consider the examples given in the ifold definition — only one of the five folds uses a function with a right identity. The other four may not be performed with ireduce).
(srfi 116) procedure (ireduce-right (f procedure?) ridentity (ilist ilist?) ) ⟹ *
(f obj fold-state ) ⟹ *
ireduce-right is the fold-right variant of ireduce. It obeys the following definition:
(ireduce-right f ridentity '()) = ridentity
(ireduce-right f ridentity (iq e1)) = (f e1 ridentity) = e1
(ireduce-right f ridentity (iq e1 e2 ...)) =
(f e1 (ireduce f ridentity (e2 ...)))
...in other words, we compute (ifold-right f ridentity ilist).
(srfi 116) procedure (iunfold (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ ilist?
(srfi 116) procedure (iunfold (p procedure?) (f procedure?) (g procedure?) seed (tail-gen ilist?) ) ⟹ *
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(tail-gen ) ⟹ *
iunfold is best described by its basic recursion:
(iunfold p f g seed) =
(if (p seed) (tail-gen seed)
(ipair (f seed)
(iunfold p f g (g seed))))
p: Determines when to stop unfolding.
f: Maps each seed value to the corresponding ilist element.
g: Maps each seed value to next seed value.
seed: The "state" value for the unfold.
tail-gen: Creates the tail of the ilist; defaults to (lambda (x) '())
In other words, we use g to generate a sequence of seed values
seed, g(seed), g^2(seed), g^3(seed), ...
These seed values are mapped to ilist elements by f, producing the elements of the result ilist in a left-to-right order. P says when to stop.
(srfi 116) procedure (iunfold-right (p procedure?) (f procedure?) (g procedure?) seed ) ⟹ ilist?
(srfi 116) procedure (iunfold-right (p procedure?) (f procedure?) (g procedure?) seed (tail-gen ilist?) ) ⟹ *
(p seed ) ⟹ boolean?
(f seed ) ⟹ *
(g seed ) ⟹ *
(tail-gen ) ⟹ *
iunfold-right constructs an ilist with the following loop:
(let lp ((seed seed) (lis tail))
(if (p seed) lis
(lp (g seed)
(ipair (f seed) lis))))
p: Determines when to stop unfolding.
f: Maps each seed value to the corresponding ilist element.
g: Maps each seed value to next seed value.
seed: The "state" value for the unfold.
tail: ilist terminator; defaults to '().
In other words, we use g to generate a sequence of seed values
seed, g(seed), g2(seed), g3(seed), ...
These seed values are mapped to ilist elements by f, producing the elements of the result ilist in a right-to-left order. P says when to stop.
(srfi 116) procedure (imap (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(proc obj1 obj2 ... ) ⟹ *
proc is a procedure taking as many arguments as there are ilist arguments and returning a single value. imap applies proc element-wise to the elements of the ilists and returns an ilist of the results, in order. The dynamic order in which proc is applied to the elements of the ilists is unspecified.
(srfi 116) procedure (ifor-each (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ undefined
(proc obj1 obj2 ... ) ⟹ undefined
The arguments to ifor-each are like the arguments to imap, but ifor-each calls proc for its side effects rather than for its values. Unlike imap, ifor-each is guaranteed to call proc on the elements of the ilists in order from the first element(s) to the last, and the value returned by ifor-each is unspecified.
(srfi 116) procedure (iappend-map (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(proc obj1 obj2 ... ) ⟹ ilist?
Equivalent to
(iapply iappend (imap f ilist1 ilist2 ...))
and
(iapply iappend (imap f ilist1 ilist2 ...))
Map f over the elements of the ilists, just as in the imap function. However, the results of the applications are appended together (using iappend) to make the final result.
The dynamic order in which the various applications of f are made is not specified.
(srfi 116) procedure (imap-in-order (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(proc obj1 obj2 ... ) ⟹ *
A variant of the imap procedure that guarantees to apply f across the elements of the ilisti arguments in a left-to-right order. This is useful for mapping procedures that both have side effects and return useful values.
(srfi 116) procedure (ipair-for-each (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ undefined
(proc (obj1 ipair?) (obj2 ipair?) ... ) ⟹ undefined
Like ifor-each, but f is applied to successive sub-ilists of the argument ilists. That is, f is applied to the cells of the ilists, rather than the ilists' elements. These applications occur in left-to-right order.
(srfi 116) procedure (ifilter-map (proc procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ ilist?
(proc obj1 obj2 ... ) ⟹ *
Like imap, but only true values are saved.
(srfi 116) procedure (ifilter (pred procedure?) (ilist ilist?) ) ⟹ ilist?
(pred obj ) ⟹ *
Return all the elements of ilist that satisfy predicate pred. The ilist is not disordered — elements that appear in the result ilist occur in the same order as they occur in the argument ilist. The returned ilist may share a common tail with the argument ilist. The dynamic order in which the various applications of pred are made is not specified.
(srfi 116) procedure (ipartition (pred procedure?) (ilist ilist?) ) ⟹ (values ilist?ilist?)
(pred obj ) ⟹ *
Partitions the elements of ilist with predicate pred, and returns two values: the ilist of in-elements and the ilist of out-elements. The ilist is not disordered — elements occur in the result ilists in the same order as they occur in the argument ilist. The dynamic order in which the various applications of pred are made is not specified. One of the returned ilists may share a common tail with the argument ilist.
(srfi 116) procedure (iremove (pred procedure?) (ilist ilist?) ) ⟹ ilist?
(pred obj ) ⟹ *
Returns ilist without the elements that satisfy predicate pred:
(lambda (pred ilist) (ifilter (lambda (x) (not (pred x))) ilist))
The ilist is not disordered — elements that appear in the result ilist occur in the same order as they occur in the argument ilist. The returned ilist may share a common tail with the argument ilist. The dynamic order in which the various applications of pred are made is not specified.
(srfi 116) procedure (ifind (pred procedure?) (ilist ilist?) ) ⟹ *
(pred obj ) ⟹ *
Return the first element of ilist that satisfies predicate pred; false if no element does.
(ifind even? (iq 3 1 4 1 5 9)) => 4
Note that ifind has an ambiguity in its lookup semantics — if ifind returns #f, you cannot tell (in general) if it found a #f element that satisfied pred, or if it did not find any element at all. In many situations, this ambiguity cannot arise — either the ilist being searched is known not to contain any #f elements, or the ilist is guaranteed to have an element satisfying pred. However, in cases where this ambiguity can arise, you should use ifind-tail instead of ifind — ifind-tail has no such ambiguity
(srfi 116) procedure (ifind-tail (pred procedure?) (ilist ilist?) ) ⟹ ipair? / #f /
(pred obj ) ⟹ *
Return the first ipair of ilist whose icar satisfies pred. If no ipair does, return false.
ifind-tail can be viewed as a general-predicate variant of the imember function.
Ifind-tail is essentially idrop-while, where the sense of the predicate is inverted: Ifind-tail searches until it finds an element satisfying the predicate; idrop-while searches until it finds an element that doesn't satisfy the predicate.
(srfi 116) procedure (itake-while (pred procedure?) (ilist ilist?) ) ⟹ ilist?
(pred obj ) ⟹ *
Returns the longest initial prefix of ilist whose elements all satisfy the predicate pred.
(srfi 116) procedure (idrop-while (pred procedure?) (ilist ilist?) ) ⟹ ilist?
(pred obj ) ⟹ *
idrops the longest initial prefix of ilist whose elements all satisfy the predicate pred, and returns the rest of the ilist.
(srfi 116) procedure (ispan (pred procedure?) (ilist ilist?) ) ⟹ (values ilist?ilist?)
(pred obj ) ⟹ *
(srfi 116) procedure (ibreak (pred procedure?) (ilist ilist?) ) ⟹ (values ilist?ilist?)
(pred obj ) ⟹ *
ispan splits the ilist into the longest initial prefix whose elements all satisfy pred, and the remaining tail. ibreak inverts the sense of the predicate: the tail commences with the first element of the input ilist that satisfies the predicate.
In other words: ispan finds the initial span of elements satisfying pred, and ibreak breaks the ilist at the first element satisfying pred.
(srfi 116) procedure (iany (pred procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(pred obj1 obj2 ... ) ⟹ *
Applies the predicate across the ilists, returning true if the predicate returns true on any application.
If there are n ilist arguments ilist1 ... ilistn, then pred must be a procedure taking n arguments and returning a boolean result.
iany applies pred to the first elements of the ilisti parameters. If this application returns a true value, iany immediately returns that value. Otherwise, it iterates, applying pred to the second elements of the ilisti parameters, then the third, and so forth. The iteration stops when a true value is produced or one of the ilists runs out of values; in the latter case, iany returns #f. The application of pred to the last element of the ilists is a tail call.
Note the difference between ifind and iany — ifind returns the element that satisfied the predicate; iany returns the true value that the predicate produced.
Like ievery, iany's name does not end with a question mark — this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(srfi 116) procedure (ievery (pred procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ *
(pred obj1 obj2 ... ) ⟹ *
Applies the predicate across the ilists, returning true if the predicate returns true on every application.
If there are n ilist arguments ilist1 ... ilistn, then pred must be a procedure taking n arguments and returning a boolean result.
ievery applies pred to the first elements of the ilisti parameters. If this application returns false, ievery immediately returns false. Otherwise, it iterates, applying pred to the second elements of the ilisti parameters, then the third, and so forth. The iteration stops when a false value is produced or one of the ilists runs out of values. In the latter case, ievery returns the true value produced by its final application of pred. The application of pred to the last element of the ilists is a tail call.
If one of the ilisti has no elements, ievery simply returns #t.
Like iany, ievery's name does not end with a question mark — this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(srfi 116) procedure (ilist-index (pred procedure?) (ilist1 ilist?) (ilist2 ilist?) ... ) ⟹ integer? / #f /
(pred obj1 obj2 ... ) ⟹ *
Return the index of the leftmost element that satisfies pred.
If there are n ilist arguments ilist1 ... ilistn, then pred must be a function taking n arguments and returning a boolean result.
ilist-index applies pred to the first elements of the ilisti parameters. If this application returns true, ilist-index immediately returns zero. Otherwise, it iterates, applying pred to the second elements of the ilisti parameters, then the third, and so forth. When it finds a tuple of ilist elements that cause pred to return true, it stops and returns the zero-based index of that position in the ilists.
The iteration stops when one of the ilists runs out of values; in this case, ilist-index returns #f.
(srfi 116) procedure (imember obj (ilist ilist?) ) ⟹ #f / ilist? /
(srfi 116) procedure (imember obj (ilist ilist?) (= procedure?) ) ⟹ #f / ilist? /
(= obj1 obj2 ) ⟹ *
(srfi 116) procedure (imemq obj (ilist ilist?) ) ⟹ #f / ilist? /
(srfi 116) procedure (imemv obj (ilist ilist?) ) ⟹ #f / ilist? /
These procedures return the first sub-ilist of ilist whose icar is x, where the sub-ilists of ilist are the non-empty ilists returned by (idrop ilist i) for i less than the length of ilist. If x does not occur in ilist, then #f is returned. imemq uses eq? to compare x with the elements of ilist, while imemv uses eqv?, and imember uses equal?.
The comparison procedure is used to compare the elements ei of ilist to the key x in this way:
(= x ei) ; ilist is (E1 ... En)
That is, the first argument is always x, and the second argument is one of the ilist elements.
(srfi 116) procedure (idelete obj (ilist ilist?) ) ⟹ ilist?
(srfi 116) procedure (idelete obj (ilist ilist?) (= procedure?) ) ⟹ ilist?
(= obj1 obj2 ) ⟹ *
idelete uses the comparison procedure =, which defaults to equal?, to find all elements of ilist that are equal to x, and deletes them from ilist. The dynamic order in which the various applications of = are made is not specified.
The ilist is not disordered — elements that appear in the result ilist occur in the same order as they occur in the argument ilist. The result may share a common tail with the argument ilist.
The comparison procedure is used in this way: (= x ei). That is, x is always the first argument, and an ilist element is always the second argument. The comparison procedure will be used to compare each element of ilist exactly once; the order in which it is applied to the various ei is not specified.
(srfi 116) procedure (idelete-duplicates (ilist ilist?) ) ⟹ ilist?
(srfi 116) procedure (idelete-duplicates (ilist ilist?) (= procedure?) ) ⟹ ilist?
(= obj1 obj2 ) ⟹ *
idelete-duplicates removes duplicate elements from the ilist argument. If there are multiple equal elements in the argument ilist, the result ilist only contains the first or leftmost of these elements in the result. The order of these surviving elements is the same as in the original ilist — idelete-duplicates does not disorder the ilist (hence it is useful for "cleaning up" immutable association lists).
The = parameter is used to compare the elements of the ilist; it defaults to equal?. If x comes before y in ilist, then the comparison is performed (= x y). The comparison procedure will be used to compare each pair of elements in ilist no more than once; the order in which it is applied to the various pairs is not specified.
Implementations of idelete-duplicates are allowed to share common tails between argument and result ilists — for example, if the ilist argument contains only unique elements, it may simply return exactly this ilist.
Be aware that, in general, idelete-duplicates runs in time O(n2) for n-element ilists. Uniquifying long ilists can be accomplished in O(n lg n) time by sorting the ilist to bring equal elements together, then using a linear-time algorithm to remove equal elements. Alternatively, one can use algorithms based on element-marking, with linear-time results.
(srfi 116) procedure (iassoc obj (ialist ilist?) ) ⟹ ilist? / #f /
(srfi 116) procedure (iassoc obj (ialist ilist?) (= procedure?) ) ⟹ ipair? / #f /
(= a b ) ⟹ *
(srfi 116) procedure (iassq obj (ialist ilist?) ) ⟹ ipair? / #f /
(srfi 116) procedure (iassv obj (ialist ilist?) ) ⟹ ipair? / #f /
ialist must be an immutable association list — an ilist of ipairs. These procedures find the first ipair in ialist whose icar field is key, and returns that ipair. If no ipair in ialist has key as its icar, then #f is returned. iassq uses eq? to compare key with the icar fields of the ipairs in ialist, while iassv uses eqv? and iassoc uses equal?.
The comparison procedure is used to compare the elements ei of ilist to the key parameter in this way:
(= key (icar ei)) ; ilist is (E1 ... En)
That is, the first argument is always key, and the second argument is one of the ilist elements.
(srfi 116) procedure (ialist-cons key datum (ialist ilist?) ) ⟹ ilist?
(lambda (key datum ialist) (ipair (ipair key datum) ialist))
Construct a new ialist entry mapping key -> datum onto ialist.
(srfi 116) procedure (ialist-delete key (ialist ilist?) ) ⟹ ilist?
(srfi 116) procedure (ialist-delete key (ialist ilist?) (= procedure?) ) ⟹ ilist?
(= a b ) ⟹ *
ialist-delete deletes all associations from ialist with the given key, using key-comparison procedure =, which defaults to equal?. The dynamic order in which the various applications of = are made is not specified.
Return values may share common tails with the ialist argument. The ialist is not disordered — elements that appear in the result ialist occur in the same order as they occur in the argument ialist.
The comparison procedure is used to compare the element keys ki of ialist's entries to the key parameter in this way: (= key ki)
(srfi 116) procedure (replace-icar (ipair ipair?) object ) ⟹ ipair?
This procedure returns an ipair with object in the icar field and the icdr of ipair in the icdr field.
(srfi 116) procedure (replace-icdr (ipair ipair?) object ) ⟹ ipair?
This procedure returns an ipair with object in the icdr field and the icar of ipair in the icar field.
(srfi 116) procedure (pair->ipair (pair pair?) ) ⟹ ipair?
(srfi 116) procedure (ipair->pair (ipair ipair?) ) ⟹ pair?
These procedures, which are inverses, return an ipair and a pair respectively that have the same (i)car and (i)cdr fields as the argument.
(srfi 116) procedure (list->ilist (flist list?) ) ⟹ ilist?
(srfi 116) procedure (list->ilist (flist dotted-list?) ) ⟹ dotted-ilist?
(srfi 116) procedure (ilist->list (flist ilist?) ) ⟹ list?
(srfi 116) procedure (ilist->list (flist dotted-ilist?) ) ⟹ dotted-list?
These procedures return an ilist and a list respectively that have the same elements as the argument. The tails of dotted (i)lists are preserved in the result, which makes the procedures not inverses when the tail of a dotted ilist is a list or vice versa. The empty list is converted to itself.
It is an error to apply list->ilist to a circular list.
(srfi 116) procedure (tree->itree (pair pair?) ) ⟹ ipair?
(srfi 116) procedure (tree->itree object ) ⟹ *
(srfi 116) procedure (itree->tree (ipair ipair?) ) ⟹ pair?
(srfi 116) procedure (itree->tree object ) ⟹ *
These procedures walk a tree of pairs or ipairs respectively and make a deep copy of it, returning an isomorphic tree containing ipairs or pairs respectively. The result may share structure with the argument. If the argument is not of the expected type, it is returned.
These procedures are not inverses in the general case. For example, a pair of ipairs would be converted by tree->itree to an ipair of ipairs, which if converted by itree->tree would produce a pair of pairs.
(srfi 116) procedure (gtree->itree (pair pair?) ) ⟹ ipair?
(srfi 116) procedure (gtree->itree object ) ⟹ *
(srfi 116) procedure (gtree->tree (ipair ipair?) ) ⟹ pair?
(srfi 116) procedure (gtree->tree object ) ⟹ *
These procedures walk a generalized tree consisting of pairs, ipairs, or a combination of both, and make a deep copy of it, returning an isomorphic tree containing only ipairs or pairs respectively. The result may share structure with the argument. If the argument is neither a pair nor an ipair, it is returned.
(srfi 116) procedure (iapply (proc procedure?) arg1 ... (args ilist?) ) ⟹ *
The iapply procedure is an analogue of apply whose last argument is an ilist rather than a list. It is equivalent to (apply procedure object ... (ilist->list ilist)), but may be implemented more efficiently.
ipair-comparator ⟹ comparator?
The ipair-comparator object is a SRFI-114 comparator suitable for comparing ipairs. Note that it is not a procedure. It compares pairs using default-comparator on their cars. If the cars are not equal, that value is returned. If they are equal, default-comparator is used on their cdrs and that value is returned.
ilist-comparator ⟹ comparator?
The ilist-comparator object is a SRFI-114 comparator suitable for comparing ilists. Note that it is not a procedure. It compares ilists lexicographically, as follows:
(srfi 116) procedure (make-ilist-comparator (element-comparator comparator?) ) ⟹ comparator?
The make-ilist-comparator procedure returns a comparator suitable for comparing ilists using element-comparator to compare the elements.
(srfi 116) procedure (make-improper-ilist-comparator (element-comparator comparator?) ) ⟹ comparator?
The make-improper-ilist-comparator procedure returns a comparator that compares arbitrary objects as follows: the empty list precedes all ipairs, which precede all other objects. Ipairs are compared as if with (make-ipair-comparator comparator comparator). All other objects are compared using comparator.
(srfi 116) procedure (make-ipair-comparator (car-comparator comparator?) (cdr-comparator comparator?) ) ⟹ comparator?
Returns a comparator that compares ipairs first on their icars using icar-comparator. If the icars are equal, it compares the icdrs using icdr-comparator.
(srfi 116) procedure (make-icar-comparator (comparator comparator?) ) ⟹ comparator?
The make-icar-comparator procedure returns a comparator that compares ipairs on their icars alone using comparator.
(srfi 116) procedure (make-icdr-comparator (comparator comparator?) ) ⟹ comparator?
The make-icdr-comparator procedure returns a comparator that compares ipairs on their icdrs alone using comparator.
library (srfi 117)
(srfi 117) procedure (make-list-queue (list list?) ) ⟹ list-queue?
(srfi 117) procedure (make-list-queue (list list?) (last pair?) ) ⟹ list-queue?
Returns a newly allocated list queue containing the elements of list in order. The result shares storage with list. If the last argument is not provided, this operation is O(n) where n is the length of list.
However, if last is provided, make-list-queue returns a newly allocated list queue containing the elements of the list whose first pair is first and whose last pair is last. It is an error if the pairs do not belong to the same list. Alternatively, both first and last can be the empty list. In either case, the operation is O(1).
Note: To apply a non-destructive list procedure to a list queue and return a new list queue, use (make-list-queue (proc (list-queue-list list-queue))).
(srfi 117) procedure (list-queue element ... ) ⟹ list-queue?
(srfi 117) procedure (list-queue (list-queue list-queue?) ) ⟹ list-queue?
Returns a newly allocated list queue containing the elements. This operation is O(n) where n is the number of elements.
(srfi 117) procedure (list-queue-copy (list-queue list-queue?) ) ⟹ list-queue?
Returns a newly allocated list queue containing the elements of list-queue. This operation is O(n) where n is the length of list-queue
(srfi 117) procedure (list-queue-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ list-queue?
(srfi 117) procedure (list-queue-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (queue list-queue?) ) ⟹ list-queue?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Performs the following algorithm:
If the result of applying the predicate stop? to seed is true, return queue. Otherwise, apply the procedure mapper to seed, returning a value which is added to the front of queue. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
If queue is omitted, a newly allocated list queue is used.
(srfi 117) procedure (list-queue-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ list-queue?
(srfi 117) procedure (list-queue-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (queue list-queue?) ) ⟹ list-queue?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Performs the following algorithm:
If the result of applying the predicate stop? to seed is true, return the list queue. Otherwise, apply the procedure mapper to seed, returning a value which is added to the back of the list queue. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
If queue is omitted, a newly allocated list queue is used.
(srfi 117) procedure (list-queue? obj ) ⟹ boolean?
Returns #t if obj is a list queue, and #f otherwise. This operation is O(1).
(srfi 117) procedure (list-queue-empty? (list-queue list-queue?) ) ⟹ boolean?
Returns #t if list-queue has no elements, and #f otherwise. This operation is O(1).
(srfi 117) procedure (list-queue-front (list-queue list-queue?) ) ⟹ *
Returns the first element of list-queue. If the list queue is empty, it is an error. This operation is O(1).
(srfi 117) procedure (list-queue-back (list-queue list-queue?) ) ⟹ *
Returns the last element of list-queue. If the list queue is empty, it is an error. This operation is O(1).
(srfi 117) procedure (list-queue-list (list-queue list-queue?) ) ⟹ list?
Returns the list that contains the members of list-queue in order. The result shares storage with list-queue. This operation is O(1).
(srfi 117) procedure (list-queue-first-last (list-queue list-queue?) ) ⟹ (values list?list?)
Returns two values, the first and last pairs of the list that contains the members of list-queue in order. If list-queue is empty, returns two empty lists. The results share storage with list-queue. This operation is O(1).
(srfi 117) procedure (list-queue-add-front! (list-queue list-queue?) element ) ⟹ undefined
Adds element to the beginning of list-queue. Returns an unspecified value. This operation is O(1).
(srfi 117) procedure (list-queue-add-back! (list-queue list-queue?) element ) ⟹ undefined
Adds element to the end of list-queue. Returns an unspecified value. This operation is O(1).
(srfi 117) procedure (list-queue-remove-front! (list-queue list-queue?) ) ⟹ *
Removes the first element of list-queue and returns it. If the list queue is empty, it is an error. This operation is O(1).
(srfi 117) procedure (list-queue-remove-back! (list-queue list-queue?) ) ⟹ *
Removes the last element of list-queue and returns it. If the list queue is empty, it is an error. This operation is O(n) where n is the length of list-queue, because queues do not not have backward links.
(srfi 117) procedure (list-queue-remove-all! (list-queue list-queue?) ) ⟹ list?
Removes all the elements of list-queue and returns them in order as a list. This operation is O(1).
(srfi 117) procedure (list-queue-set-list! (list-queue list-queue?) (list list?) ) ⟹ undefined
(srfi 117) procedure (list-queue-set-list! (list-queue list-queue?) (list list?) (last pair?) ) ⟹ undefined
Replaces the list associated with list-queue with list, effectively discarding all the elements of list-queue in favor of those in list. Returns an unspecified value. This operation is O(n) where n is the length of list. If last is provided, it is treated in the same way as in make-list-queue, and the operation is O(1).
Note: To apply a destructive list procedure to a list queue, use (list-queue-set-list! (proc (list-queue-list list-queue))).
(srfi 117) procedure (list-queue-append (list-queue list-queue?) ... ) ⟹ list-queue?
Returns a list queue which contains all the elements in front-to-back order from all the list-queues in front-to-back order. The result does not share storage with any of the arguments. This operation is O(n) in the total number of elements in all queues.
(srfi 117) procedure (list-queue-append! (list-queue list-queue?) ... ) ⟹ list-queue?
Returns a list queue which contains all the elements in front-to-back order from all the list-queues in front-to-back order. It is an error to assume anything about the contents of the list-queues after the procedure returns. This operation is O(n) in the total number of queues, not elements. It is not part of the R7RS-small list API, but is included here for efficiency when pure functional append is not required.
(srfi 117) procedure (list-queue-concatenate (list-of-list-queues list?) ) ⟹ list-queue?
Returns a list queue which contains all the elements in front-to-back order from all the list queues which are members of list-of-list-queues in front-to-back order. The result does not share storage with any of the arguments. This operation is O(n) in the total number of elements in all queues. It is not part of the R7RS-small list API, but is included here to make appending a large number of queues possible in Schemes that limit the number of arguments to apply.
(srfi 117) procedure (list-queue-map (proc procedure?) (list-queue list-queue?) ) ⟹ list-queue?
(proc element ) ⟹ *
Applies proc to each element of list-queue in unspecified order and returns a newly allocated list queue containing the results. This operation is O(n) where n is the length of list-queue.
(srfi 117) procedure (list-queue-map! (proc procedure?) (list-queue list-queue?) ) ⟹ undefined
(proc element ) ⟹ *
Applies proc to each element of list-queue in front-to-back order and modifies list-queue to contain the results. This operation is O(n) in the length of list-queue. It is not part of the R7RS-small list API, but is included here to make transformation of a list queue by mutation more efficient.
(srfi 117) procedure (list-queue-for-each (proc procedure?) (list-queue list-queue?) ) ⟹ undefined
(proc element ) ⟹ undefined
Applies proc to each element of list-queue in front-to-back order, discarding the returned values. Returns an unspecified value. This operation is O(n) where n is the length of list-queue.
library (srfi 118)
(srfi 118) procedure (string-append! (string string?) (value (or char?string?)) ... ) ⟹ undefined
The string must be a variable-size mutable string. The string-append! procedure extends string by appending each value (in order) to the end of string. A value can be a character or a string.
Using a string port in this situation is probably preferable: It is more portable, and you can expect decent performance in most implementations. Using string-append! may be slighly more efficient on some implementations, due to lower overhead, but that depends on the strategy used by string-append! when the allocated buffer is too small. The string-append! function is most useful when using (reading) a string is interleaved with growing it, or when also using string-replace!.
(srfi 118) procedure (string-replace! (dst string?) (dst-start integer?) (dst-end integer?) (src string?) ) ⟹ undefined
(srfi 118) procedure (string-replace! (dst string?) (dst-start integer?) (dst-end integer?) (src string?) (src-start integer?) ) ⟹ undefined
(srfi 118) procedure (string-replace! (dst string?) (dst-start integer?) (dst-end integer?) (src string?) (src-start integer?) (src-end integer?) ) ⟹ undefined
Replaces the characters of the variable-size string dst (between dst-start and dst-end) with the characters of the string src (between src-start and src-end). The number of characters from src may be different than the number replaced in dst, so the string may grow or contract. The special case where dst-start is equal to dst-end corresponds to insertion; the case where src-start is equal to src-end corresponds to deletion. 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.)
When value is a string then (string-append! dst value) is equivalent to (string-replace! dst (string-length dst) (string-length dst) value).
library (srfi 120)
(srfi 120) procedure (make-timer ) ⟹ timer?
(srfi 120) procedure (make-timer (error-handler procedure?) ) ⟹ timer?
(error-handler err ) ⟹ *
Creates and starts a timer object. The optional argument error-handler must be a procedure which accepts one argument. If it is given and when a timer task raises an error, then the handler will be invoked and timer will continue if the error-handler wouldn't raise an error. Otherwise whenever an error is raised, timer stops and preserves the error. The error is raised when timer-cancel! procedure is called.
Two timers should run in separate context, means whenever timer A is executing a task, timer B should not be disturbed executing a task by timer A's execution.
(srfi 120) procedure (timer? obj ) ⟹ boolean?
Returns #t if given obj is a timer object, otherwise #f.
(srfi 120) procedure (timer-cancel! (timer timer?) ) ⟹ undefined
Stops the given timer. The procedure raises the preserved error if there is. Once a timer is stopped, it will never be able to start again.
(srfi 120) procedure (timer-schedule! (timer timer?) (thunk procedure?) (when (or timer-delta?integer?)) ) ⟹ timer-id
(srfi 120) procedure (timer-schedule! (timer timer?) (thunk procedure?) (when (or timer-delta?integer?)) (period (or timer-delta?integer?)) ) ⟹ timer-id
(thunk ) ⟹ *
Schedules the given thunk as the given timer's task. The when argument specifies when the task will be started. It can be either timer delta object or non negative integer. The task is scheduled on the time when the given when passed from the procedure is called. The task is executed on the dynamic environment where the timer is created.
If the optional argument period is given, which must be either timer delta object or an integer, then the given task is scheduled as periodical task. The next task is scheduled by adding when and period. If the period or when is an integer, then it is interpreted as milliseconds.
The procedure returns task id, which is a readable datum such as an integer.
The executing order of the same timing tasks are not defined.
A task should be able to cancel or reschedule other tasks. But it should not be able to cancel or reschedule itself.
If a task is rescheduled whenever it's executed, the timer doesn't stop its execution. It is rescheduled but the current execution will be continued.
(srfi 120) procedure (timer-reschedule! (timer timer?) (id timer-id) (when (or timer-delta?integer?)) ) ⟹ timer-id
(srfi 120) procedure (timer-reschedule! (timer timer?) (id timer-id) (when (or timer-delta?integer?)) (period (or timer-delta?integer?)) ) ⟹ timer-id
Reschedules the task associated to the given id on the given timer. The when and period arguments are the same as timer-schedule!.
Thus to cancel the periodical task, you can specify 0 as period argument.
The procedure returns given id.
It is an error if the given task id is not associated with the given timer or if the task is already executed and not scheduled anymore.
(srfi 120) procedure (timer-task-remove! (timer timer?) (id timer-id) ) ⟹ boolean?
Removes the task associated to the given id on the given timer. It returns #t if a task is removed, otherwise #f.
(srfi 120) procedure (timer-task-exists? (timer timer?) (id timer-id) ) ⟹ boolean?
Returns #t if a task associated to the given id exists, otherwise #f.
(srfi 120) procedure (make-timer-delta (n integer?) (unit symbol?) ) ⟹ timer-delta?
Creates a timer delta object. n must be an integer and unit must be a symbol which represents the time unit. Implementations must support the following units:
h : hour
m : minute
s : second
ms : millisecond
us : microsecond
ns : nanosecond
And may support other unit.
(srfi 120) procedure (timer-delta? obj ) ⟹ boolean?
Returns #t if given obj is a timer delta object, otherwise #f.
library (srfi 123)
(srfi 123) procedure (ref object field ) ⟹ *
(srfi 123) procedure (ref object field default ) ⟹ *
Returns the value for field in object. It is an error if object has no field identified by field. If object is of a "sparse" type, meaning its fields can be "empty" or "unassigned" (e.g. a hashtable), and the requested field is empty, then the value of default is returned. It is an error if the default argument is not provided in this case. If object is not of a sparse type, then providing the default argument is an error. Valid types for object are: bytevectors, hashtables, pairs, strings, vectors, non-opaque record types, SRFI-4 vectors, and SRFI-111 boxes. Only hashtables are a sparse type. Implementations are encouraged to expand this list of types with any further types they support.
(srfi 123) procedure (ref* object field ... ) ⟹ *
(srfi 123) procedure (~ object field ... ) ⟹ *
ref* (and its synonym ~) is like ref but for chained access.
library (srfi 124)
(srfi 124) procedure (ephemeron? object ) ⟹ boolean?
Returns #t if object is an ephemeron; otherwise returns #f.
(srfi 124) procedure (make-ephemeron key datum ) ⟹ ephemeron?
Returns a newly allocated ephemeron, with components key and datum. Note that if key and datum are the same in the sense of eq?, the ephemeron is effectively a weak reference to the object.
(srfi 124) procedure (ephemeron-broken? (ephemeron ephemeron?) ) ⟹ boolean?
Returns #t if ephemeron has been broken; otherwise returns #f.
This procedure must be used with care. If it returns #f, that guarantees only that prior evaluations of ephemeron-key or ephemeron-datum yielded the key or datum that was stored in ephemeron. However, it makes no guarantees about subsequent calls to ephemeron-key or ephemeron-datum, because the GC may run and break the ephemeron immediately after ephemeron-broken? returns.
(srfi 124) procedure (ephemeron-key (ephemeron ephemeron?) ) ⟹ *
(shared description for ephemeron-key, ephemeron-datum) These return the key or datum component, respectively, of ephemeron. If ephemeron has been broken, these operations return #f, but they can also return #f if that is what was stored as the key or datum.
(srfi 124) procedure (ephemeron-datum (ephemeron ephemeron?) ) ⟹ *
(shared description for ephemeron-key, ephemeron-datum) These return the key or datum component, respectively, of ephemeron. If ephemeron has been broken, these operations return #f, but they can also return #f if that is what was stored as the key or datum.
(srfi 124) procedure (reference-barrier key ) ⟹ *
This procedure ensures that the garbage collector does not break an ephemeron containing an unreferenced key before a certain point in a program. The program can invoke a reference barrier on the key by calling this procedure, which guarantees that even if the program does not use the key, it will be considered strongly reachable until after reference-barrier returns.
Because one cannot reliably operate on ephemerons in a portable way without calling the procedure reference-barrier, reference-barrier is mandatory.
library (srfi 125)
(srfi 125) procedure (make-hash-table (comparator comparator?) arg ... ) ⟹ hash-table?
(srfi 125) procedure (make-hash-table (equality-predicate procedure?) arg ... ) ⟹ hash-table?
(srfi 125) procedure (make-hash-table (equality-predicate procedure?) (hash-function procedure?) arg ... ) ⟹ hash-table?
(equality-predicate a b ) ⟹ boolean?
(hash-function obj ) ⟹ integer?
Returns a newly allocated hash table whose equality predicate and hash function are extracted from comparator. Alternatively, for backward compatibility with SRFI 69 the equality predicate and hash function can be passed as separate arguments; this usage is deprecated.
As mentioned above, implementations are free to use an appropriate implementation-dependent hash function instead of the specified hash function, provided that the specified equality predicate is a refinement of the equal? predicate. This applies whether the hash function and equality predicate are passed as separate arguments or packaged up into a comparator.
If an equality predicate rather than a comparator is provided, the ability to omit the hash-function argument is severely limited. The implementation must provide hash functions appropriate for use with the predicates eq?, eqv?, equal?, string=?, and string-ci=?, and may extend this list. But if any unknown equality predicate is provided without a hash function, an error should be signaled. The constraints on equality predicates and hash functions are given in SRFI 128.
The meaning of any further arguments is implementation-dependent. However, implementations which support the ability to specify the initial capacity of a hash table should interpret a non-negative exact integer as the specification of that capacity. In addition, if the symbols thread-safe, weak-keys, ephemeral-keys, weak-values, or ephemeral-values are present, implementations should create thread-safe hash tables, hash tables with weak keys or ephemeral keys, or hash tables with weak or ephemeral values respectively. Implementations are free to use ephemeral keys or values when weak keys or values respectively have been requested. To avoid collision with the hash-function argument, none of these arguments can be procedures.
(R6RS make-eq-hashtable, make-eqv-hashtable, and make-hashtable; Common Lisp make-hash-table)
(srfi 125) procedure (hash-table (comparator comparator?) key1 value1 ... ) ⟹ hash-table?
Returns a newly allocated hash table, created as if by make-hash-table using comparator. For each pair of arguments, an association is added to the new hash table with key as its key and value as its value. If the implementation supports immutable hash tables, this procedure returns an immutable hash table. If the same key (in the sense of the equality predicate) is specified more than once, it is an error.
(srfi 125) procedure (hash-table-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (comparator comparator?) arg ... ) ⟹ hash-table?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ (values **)
(successor seed ) ⟹ *
Create a new hash table as if by make-hash-table using comparator and the args. If the result of applying the predicate stop? to seed is true, return the hash table. Otherwise, apply the procedure mapper to seed. Mapper returns two values, which are inserted into the hash table as the key and the value respectively. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm.
(srfi 125) procedure (alist->hash-table (alist list?) (comparator comparator?) arg ... ) ⟹ hash-table?
(srfi 125) procedure (alist->hash-table (alist list?) (equality-predicate procedure?) arg ... ) ⟹ hash-table?
(srfi 125) procedure (alist->hash-table (alist list?) (equality-predicate procedure?) (hash-function procedure?) arg ... ) ⟹ hash-table?
(equality-predicate a b ) ⟹ boolean?
(hash-function obj ) ⟹ integer?
Returns a newly allocated hash-table as if by make-hash-table using comparator and the args. It is then initialized from the associations of alist. Associations earlier in the list take precedence over those that come later. The second form is for compatibility with SRFI 69, and is deprecated.
(srfi 125) procedure (hash-table? obj ) ⟹ boolean?
Returns #t if obj is a hash table, and #f otherwise. (R6RS hashtable?; Common Lisp hash-table-p)
(srfi 125) procedure (hash-table-contains? (hash-table hash-table?) key ) ⟹ boolean?
Returns #t if there is any association to key in hash-table, and #f otherwise. Must execute in expected amortized constant time. (R6RS hashtable-contains?)
(srfi 125) procedure (hash-table-exists? (hash-table hash-table?) key ) ⟹ boolean?
Returns #t if there is any association to key in hash-table, and #f otherwise. Must execute in expected amortized constant time. The hash-table-exists? procedure is the same as hash-table-contains?, is provided for backward compatibility with SRFI 69, and is deprecated. (R6RS hashtable-contains?)
(srfi 125) procedure (hash-table-empty? (hash-table hash-table?) ) ⟹ boolean?
Returns #t if hash-table contains no associations, and #f otherwise.
(srfi 125) procedure (hash-table=? (value-comparator comparator?) (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ boolean?
Returns #t if hash-table1 and hash-table2 have the same keys (in the sense of their common equality predicate) and each key has the same value (in the sense of value-comparator), and #f otherwise.
(srfi 125) procedure (hash-table-mutable? (hash-table hash-table?) ) ⟹ boolean?
Returns #t if the hash table is mutable. Implementations may or may not support immutable hash tables. (R6RS hashtable-mutable?)
(srfi 125) procedure (hash-table-ref (hash-table hash-table?) key ) ⟹ *
(srfi 125) procedure (hash-table-ref (hash-table hash-table?) key (failure procedure?) ) ⟹ *
(srfi 125) procedure (hash-table-ref (hash-table hash-table?) key (failure procedure?) (success procedure?) ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Extracts the value associated to key in hash-table, invokes the procedure success on it, and returns its result; if success is not provided, then the value itself is returned. If key is not contained in hash-table and failure is supplied, then failure is invoked on no arguments and its result is returned. Otherwise, it is an error. Must execute in expected amortized constant time, not counting the time to call the procedures. SRFI 69 does not support the success procedure.
(srfi 125) procedure (hash-table-ref/default (hash-table hash-table?) key default ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(hash-table-ref hash-table key (lambda () default))
(R6RS hashtable-ref; Common Lisp gethash)
(srfi 125) procedure (hash-table-set! (hash-table hash-table?) key1 value1 ... ) ⟹ undefined
Repeatedly mutates hash-table, creating new associations in it by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, it is deleted. It is an error if the type check procedure of the comparator of hash-table, when invoked on a key, does not return #t. Likewise, it is an error if a key is not a valid argument to the equality predicate of hash-table. Returns an unspecified value. Must execute in expected amortized constant time per key. SRFI 69, R6RS hashtable-set! and Common Lisp (setf gethash) do not handle multiple associations.
(srfi 125) procedure (hash-table-delete! (hash-table hash-table?) key ... ) ⟹ undefined
Deletes any association to each key in hash-table and returns the number of keys that had associations. Must execute in expected amortized constant time per key. SRFI 69, R6RS hashtable-delete!, and Common Lisp remhash do not handle multiple associations.
(srfi 125) procedure (hash-table-intern! (hash-table hash-table?) key (failure procedure?) ) ⟹ undefined
(failure ) ⟹ *
Effectively invokes hash-table-ref with the given arguments and returns what it returns. If key was not found in hash-table, its value is set to the result of calling failure. Must execute in expected amortized constant time.
(srfi 125) procedure (hash-table-update! (hash-table hash-table?) key (updater procedure?) ) ⟹ undefined
(srfi 125) procedure (hash-table-update! (hash-table hash-table?) key (updater procedure?) (failure procedure?) ) ⟹ undefined
(srfi 125) procedure (hash-table-update! (hash-table hash-table?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ undefined
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(hash-table-set! hash-table key (updater (hash-table-ref hash-table key failure success)))
Must execute in expected amortized constant time. Returns an unspecified value. (SRFI 69 and R6RS hashtable-update! do not support the success procedure)
(srfi 125) procedure (hash-table-update!/default (hash-table hash-table?) key (updater procedure?) default ) ⟹ undefined
(updated value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(hash-table-set! hash-table key (updater (hash-table-ref/default hash-table key default)))
Must execute in expected amortized constant time. Returns an unspecified value.
(srfi 125) procedure (hash-table-pop! (hash-table hash-table?) ) ⟹ (values **)
Chooses an arbitrary association from hash-table and removes it, returning the key and value as two values.
It is an error if hash-table is empty.
(srfi 125) procedure (hash-table-clear! (hash-table hash-table?) ) ⟹ undefined
Delete all the associations from hash-table. (R6RS hashtable-clear!; Common Lisp clrhash)
(srfi 125) procedure (hash-table-size (hash-table hash-table?) ) ⟹ integer?
Returns the number of associations in hash-table as an exact integer. Should execute in constant time. (R6RS hashtable-size; Common Lisp hash-table-count.)
(srfi 125) procedure (hash-table-keys (hash-table hash-table?) ) ⟹ list?
Returns a newly allocated list of all the keys in hash-table. R6RS hashtable-keys returns a vector.
(srfi 125) procedure (hash-table-values (hash-table hash-table?) ) ⟹ list?
Returns a newly allocated list of all the keys in hash-table.
(srfi 125) procedure (hash-table-entries (hash-table hash-table?) ) ⟹ (values list?list?)
Returns two values, a newly allocated list of all the keys in hash-table and a newly allocated list of all the values in hash-table in the corresponding order. R6RS hash-table-entries returns vectors.
(srfi 125) procedure (hash-table-find (proc procedure?) (hash-table hash-table?) (failure procedure?) ) ⟹ *
(proc key value ) ⟹ *
(failure ) ⟹ *
For each association of hash-table, invoke proc on its key and value. If proc returns true, then hash-table-find returns what proc returns. If all the calls to proc return #f, return the result of invoking the thunk failure.
(srfi 125) procedure (hash-table-count (pred procedure?) (hash-table hash-table?) ) ⟹ integer?
(pred key value ) ⟹ boolean?
For each association of hash-table, invoke pred on its key and value. Return the number of calls to pred which returned true.
(srfi 125) procedure (hash-table-map (proc procedure?) (comparator comparator?) (hash-table hash-table?) ) ⟹ hash-table?
(proc value ) ⟹ *
Returns a newly allocated hash table as if by (make-hash-table comparator). Calls proc for every association in hash-table with the value of the association. The key of the association and the result of invoking proc are entered into the new hash table. Note that this is not the result of lifting mapping over the domain of hash tables, but it is considered more useful.
If comparator recognizes multiple keys in the hash-table as equivalent, any one of such associations is taken.
(srfi 125) procedure (hash-table-for-each (proc procedure?) (hash-table hash-table?) ) ⟹ undefined
(proc key value ) ⟹ undefined
Calls proc for every association in hash-table with two arguments: the key of the association and the value of the association. The value returned by proc is discarded. Returns an unspecified value. (Common Lisp maphash)
(srfi 125) procedure (hash-table-walk (hash-table hash-table?) (proc procedure?) ) ⟹ undefined
(proc key value ) ⟹ undefined
Calls proc for every association in hash-table with two arguments: the key of the association and the value of the association. The value returned by proc is discarded. Returns an unspecified value. The hash-table-walk procedure is equivalent to hash-table-for-each with the arguments reversed, is provided for backward compatibility with SRFI 69, and is deprecated. (Common Lisp maphash)
(srfi 125) procedure (hash-table-map! (proc procedure?) (comparator comparator?) (hash-table hash-table?) ) ⟹ undefined
(proc key value ) ⟹ *
Calls proc for every association in hash-table with two arguments: the key of the association and the value of the association. The value returned by proc is used to update the value of the association. Returns an unspecified value.
(srfi 125) procedure (hash-table-map->list (proc procedure?) (hash-table hash-table?) ) ⟹ list?
(proc key value ) ⟹ *
Calls proc for every association in hash-table with two arguments: the key of the association and the value of the association. The values returned by the invocations of proc are accumulated into a list, which is returned.
(srfi 125) procedure (hash-table-fold (proc procedure?) seed (hash-table hash-table?) ) ⟹ *
(srfi 125) procedure (hash-table-fold (hash-table hash-table?) (proc procedure?) seed ) ⟹ *
(proc key value state ) ⟹ *
Calls proc for every association in hash-table with three arguments: the key of the association, the value of the association, and an accumulated value val. Val is seed for the first invocation of procedure, and for subsequent invocations of proc, the returned value of the previous invocation. The value returned by hash-table-fold is the return value of the last invocation of proc. The order of arguments with hash-table as the first argument is provided for SRFI 69 compatibility, and is deprecated.
(srfi 125) procedure (hash-table-prune! (proc procedure?) (hash-table hash-table?) ) ⟹ undefined
(proc key value ) ⟹ boolean?
Calls proc for every association in hash-table with two arguments, the key and the value of the association, and removes all associations from hash-table for which proc returns true. Returns an unspecified value.
(srfi 125) procedure (hash-table-copy (hash-table hash-table?) ) ⟹ hash-table?
(srfi 125) procedure (hash-table-copy (hash-table hash-table?) (mutable boolean?) ) ⟹ hash-table?
Returns a newly allocated hash table with the same properties and associations as hash-table. If the second argument is present and is true, the new hash table is mutable. Otherwise it is immutable provided that the implementation supports immutable hash tables. SRFI 69 hash-table-copy does not support a second argument. (R6RS hashtable-copy)
(srfi 125) procedure (hash-table-empty-copy (hash-table hash-table?) ) ⟹ hash-table?
Returns a newly allocated mutable hash table with the same properties as hash-table, but with no associations.
(srfi 125) procedure (hash-table->alist (hash-table hash-table?) ) ⟹ list?
Returns an alist with the same associations as hash-table in an unspecified order.
(srfi 125) procedure (hash-table-union! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Adds the associations of hash-table2 to hash-table1 and returns hash-table1. If a key appears in both hash tables, its value is set to the value appearing in hash-table1. Returns hash-table1.
(srfi 125) procedure (hash-table-merge! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Adds the associations of hash-table2 to hash-table1 and returns hash-table1. If a key appears in both hash tables, its value is set to the value appearing in hash-table1. Returns hash-table1. The hash-table-merge! procedure is the same as hash-table-union!, is provided for compatibility with SRFI 69, and is deprecated.
(srfi 125) procedure (hash-table-intersection! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Deletes the associations from hash-table1 whose keys don't also appear in hash-table2 and returns hash-table1.
(srfi 125) procedure (hash-table-difference! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Deletes the associations of hash-table1 whose keys are also present in hash-table2 and returns hash-table1.
(srfi 125) procedure (hash-table-xor! (hash-table1 hash-table?) (hash-table2 hash-table?) ) ⟹ hash-table?
Deletes the associations of hash-table1 whose keys are also present in hash-table2, and then adds the associations of hash-table2 whose keys are not present in hash-table1 to hash-table1. Returns hash-table1.
(srfi 125) procedure (hash obj ) ⟹ integer?
(srfi 125) procedure (hash obj arg ) ⟹ integer?
The same as SRFI 128's default-hash procedure, except that it must accept (and should ignore) an optional second argument.
(srfi 125) procedure (string-hash (str string?) ) ⟹ integer?
(srfi 125) procedure (string-hash (str string?) arg ) ⟹ integer?
Similar to SRFI 128's string-hash procedure, except that it must accept (and should ignore) an optional second argument. It is incompatible with the procedure of the same name exported by SRFI 128 and SRFI 126.
(srfi 125) procedure (string-ci-hash (str string?) ) ⟹ integer?
(srfi 125) procedure (string-ci-hash (str string?) arg ) ⟹ integer?
Similar to SRFI 128's string-ci-hash procedure, except that it must accept (and should ignore) an optional second argument. It is incompatible with the procedure of the same name exported by SRFI 128 and SRFI 126.
(srfi 125) procedure (hash-by-identity obj ) ⟹ integer?
(srfi 125) procedure (hash-by-identity obj arg ) ⟹ integer?
The same as SRFI 128's default-hash procedure, except that it must accept (and should ignore) an optional second argument. However, if the implementation replaces the hash function associated with the eq? predicate with an implementation-dependent alternative, it is an error to call this procedure at all.
(srfi 125) procedure (hash-table-equivalence-function (hash-table hash-table?) ) ⟹ procedure?
(return a b ) ⟹ boolean?
Returns the equivalence procedure used to create hash-table.
(srfi 125) procedure (hash-table-hash-function (hash-table hash-table?) ) ⟹ procedure?
(return obj ) ⟹ integer?
Returns the hash function used to create hash-table. However, if the implementation has replaced the user-specified hash function with an implementation-specific alternative, the implementation may return #f instead.
library (srfi 126)
(srfi 126) procedure (make-eq-hashtable ) ⟹ hashtable?
(srfi 126) procedure (make-eq-hashtable (capacity integer?) ) ⟹ hashtable?
(srfi 126) procedure (make-eq-hashtable (capacity integer?) (weakness (or #fsymbol?)) ) ⟹ hashtable?
Returns a newly allocated mutable hashtable that accepts arbitrary objects as keys, and compares those keys with eq?. If the capacity argument is provided and not #f, it must be an exact non-negative integer and the initial capacity of the hashtable is set to approximately capacity elements. The weakness argument, if provided, must be one of: #f, weak-key, weak-value, weak-key-and-value, ephemeral-key, ephemeral-value, and ephemeral-key-and-value, and determines the weakness or ephemeral status for the keys and values in the hashtable. All values other than #f are optional to support; the implementation should signal the user in an implementation-defined manner when an unsupported value is used.
(srfi 126) procedure (make-eqv-hashtable ) ⟹ hashtable?
(srfi 126) procedure (make-eqv-hashtable (k integer?) ) ⟹ hashtable?
(srfi 126) procedure (make-eqv-hashtable (capacity integer?) (weakness (or #fsymbol?)) ) ⟹ hashtable?
Returns a newly allocated mutable hashtable that accepts arbitrary objects as keys, and compares those keys with eqv?. The semantics of the optional arguments are as in make-eq-hashtable.
(srfi 126) procedure (make-hashtable (hash procedure?) (equiv procedure?) ) ⟹ hashtable?
(srfi 126) procedure (make-hashtable (hash procedure?) (equiv procedure?) (capacity integer?) ) ⟹ hashtable?
(srfi 126) procedure (make-hashtable (hash procedure?) (equiv procedure?) (capacity integer?) (weakness (or #fsymbol?)) ) ⟹ hashtable?
(hash key ) ⟹ integer?
(equiv a b ) ⟹ boolean?
If hash is #f and equiv is the eq? procedure, the semantics of make-eq-hashtable apply to the rest of the arguments. If hash is #f and equiv is the eqv? procedure, the semantics of make-eqv-hashtable apply to the rest of the arguments.
Otherwise, hash must be a pair of hash functions or a hash function, and and equiv must be a procedure. Equiv should accept two keys as arguments and return a single value. None of the procedures should mutate the hashtable returned by make-hashtable. The make-hashtable procedure returns a newly allocated mutable hashtable using the function(s) specified by hash as its hash function(s), and equiv as the equivalence function used to compare keys. The semantics of the remaining arguments are as in make-eq-hashtable and make-eqv-hashtable.
Implementations using a hashing strategy that involves a single hash function should ignore one of the functions in the pair when given a pair of hash functions. Implementations preferring a hashing strategy involving a pair of hash functions may automatically derive a pair of hash functions from a given single hash function.
The hash functions and equiv should behave like pure functions on the domain of keys. For example, the string-hash and string=? procedures are permissible only if all keys are strings and the contents of those strings are never changed so long as any of them continues to serve as a key in the hashtable. Furthermore, any pair of keys for which equiv returns true should be hashed to the same exact integer objects by the given hash function(s).
Note: Hashtables are allowed to cache the results of calling a hash function and equivalence function, so programs cannot rely on a hash function being called for every lookup or update. Furthermore any hashtable operation may call a hash function more than once.
(srfi 126) procedure (hashtable? obj ) ⟹ boolean?
Returns #t if obj is a hashtable, #f otherwise.
(srfi 126) procedure (hashtable-size (hashtable hashtable?) ) ⟹ integer?
Returns the number of keys contained in hashtable as an exact integer object.
(srfi 126) procedure (hashtable-ref (hashtable hashtable?) key ) ⟹ *
(srfi 126) procedure (hashtable-ref (hashtable hashtable?) key default ) ⟹ *
Returns the value in hashtable associated with key. If hashtable does not contain an association for key, default is returned. If hashtable does not contain an association for key and the default argument is not provided, an error should be signaled.
(srfi 126) procedure (hashtable-set! (hashtable hashtable?) key obj ) ⟹ undefined
Changes hashtable to associate key with obj, adding a new association or replacing any existing association for key, and returns an unspecified value.
(srfi 126) procedure (hashtable-delete! (hashtable hashtable?) key ) ⟹ undefined
Removes any association for key within hashtable and returns an unspecified value.
(srfi 126) procedure (hashtable-contains? (hashtable hashtable?) key ) ⟹ boolean?
Returns #t if hashtable contains an association for key, #f otherwise.
(srfi 126) procedure (hashtable-lookup (hashtable hashtable?) key ) ⟹ (values *boolean?)
Returns two values: the value in hashtable associated with key or an unspecified value if there is none, and a Boolean indicating whether an association was found.
(srfi 126) procedure (hashtable-update! (hashtable hashtable?) key (proc procedure?) ) ⟹ boolean?
(srfi 126) procedure (hashtable-update! (hashtable hashtable?) key (proc procedure?) default ) ⟹ boolean?
(proc value ) ⟹ *
Proc should accept one argument, should return a single value, and should not mutate hashtable. The hashtable-update! procedure applies proc to the value in hashtable associated with key, or to default if hashtable does not contain an association for key. The hashtable is then changed to associate key with the value returned by proc. If hashtable does not contain an association for key and the default argument is not provided, an error should be signaled. Hashtable-update! returns the value of the new association for key in hashtable.
(srfi 126) procedure (hashtable-intern! (hashtable hashtable?) key (default-proc procedure?) ) ⟹ *
(default-proc ) ⟹ *
Default-proc should accept zero arguments, should return a single value, and should not mutate hashtable. The hashtable-intern! procedure returns the association for key in hashtable if there is one, otherwise it calls default-proc with zero arguments, associates its return value with key in hashtable, and returns that value.
(srfi 126) procedure (hashtable-copy (hashtable hashtable?) ) ⟹ hashtable?
(srfi 126) procedure (hashtable-copy (hashtable hashtable?) (mutable boolean?) ) ⟹ hashtable?
(srfi 126) procedure (hashtable-copy (hashtable hashtable?) (mutable boolean?) (weakness (or #fsymbol?)) ) ⟹ hashtable?
Returns a copy of hashtable. If the mutable argument is provided and is true, the returned hashtable is mutable; otherwise it is immutable. If the optional weakness argument is provided, it determines the weakness of the copy, otherwise the weakness attribute of hashtable is used.
(srfi 126) procedure (hashtable-clear! (hashtable hashtable?) ) ⟹ undefined
(srfi 126) procedure (hashtable-clear! (hashtable hashtable?) (capacity integer?) ) ⟹ undefined
Removes all associations from hashtable and returns an unspecified value. If capacity is provided and not #f, it must be an exact non-negative integer and the current capacity of the hashtable is reset to approximately capacity elements.
(srfi 126) procedure (hashtable-empty-copy (hashtable hashtable?) ) ⟹ hashtable?
(srfi 126) procedure (hashtable-empty-copy (hashtable hashtable?) (capacity integer?) ) ⟹ hashtable?
Returns a newly allocated mutable hashtable that has the same hash and equivalence functions and weakness attribute as hashtable. The capacity argument may be #t to set the initial capacity of the copy to approximately (hashtable-size hashtable) elements; otherwise the semantics of make-eq-hashtable apply to the capacity argument.
(srfi 126) procedure (hashtable-keys (hashtable hashtable?) ) ⟹ vector?
Returns a vector of all keys in hashtable. The order of the vector is unspecified.
(srfi 126) procedure (hashtable-values (hashtable hashtable?) ) ⟹ vector?
Returns a vector of all values in hashtable. The order of the vector is unspecified, and is not guaranteed to match the order of keys in the result of hashtable-keys.
(srfi 126) procedure (hashtable-entries (hashtable hashtable?) ) ⟹ (values vector?vector?)
Returns two values, a vector of the keys in hashtable, and a vector of the corresponding values.
(srfi 126) procedure (hashtable-key-list (hashtable hashtable?) ) ⟹ list?
Returns a list of all keys in hashtable. The order of the list is unspecified.
(srfi 126) procedure (hashtable-value-list (hashtable hashtable?) ) ⟹ list?
Returns a list of all values in hashtable. The order of the list is unspecified, and is not guaranteed to match the order of keys in the result of hashtable-key-list.
(srfi 126) procedure (hashtable-entry-list (hashtable hashtable?) ) ⟹ (values list?list?)
Returns two values, a list of the keys in hashtable, and a list of the corresponding values.
(srfi 126) procedure (hashtable-walk (hashtable hashtable?) (proc procedure?) ) ⟹ undefined
(proc key value ) ⟹ undefined
Proc should accept two arguments, and should not mutate hashtable. The hashtable-walk procedure applies proc once for every association in hashtable, passing it the key and value as arguments. The order in which proc is applied to the associations is unspecified. Return values of proc are ignored. Hashtable-walk returns an unspecified value.
(srfi 126) procedure (hashtable-update-all! (hashtable hashtable?) (proc procedure?) ) ⟹ undefined
(proc key value ) ⟹ *
Proc should accept two arguments, should return a single value, and should not mutate hashtable. The hashtable-update-all! procedure applies proc once for every association in hashtable, passing it the key and value as arguments, and changes the value of the association to the return value of proc. The order in which proc is applied to the associations is unspecified. Hashtable-update-all! returns an unspecified value.
(srfi 126) procedure (hashtable-prune! (hashtable hashtable?) (proc procedure?) ) ⟹ undefined
(proc key value ) ⟹ boolean?
Proc should accept two arguments, should return a single value, and should not mutate hashtable. The hashtable-prune! procedure applies proc once for every association in hashtable, passing it the key and value as arguments, and deletes the association if proc returns a true value. The order in which proc is applied to the associations is unspecified. Hashtable-prune! returns an unspecified value.
(srfi 126) procedure (hashtable-merge! (hashtable-dest hashtable?) (hashtable-source hashtable?) ) ⟹ hashtable?
Effectively equivalent to:
(begin
(hashtable-walk hashtable-source
(lambda (key value)
(hashtable-set! hashtable-dest key value)))
hashtable-dest)
(srfi 126) procedure (hashtable-sum (hashtable hashtable?) init (proc procedure?) ) ⟹ *
(proc key value state ) ⟹ *
Proc should accept three arguments, should return a single value, and should not mutate hashtable. The hashtable-sum procedure accumulates a result by applying proc once for every association in hashtable, passing it as arguments: the key, the value, and the result of the previous application or init at the first application. The order in which proc is applied to the associations is unspecified.
(srfi 126) procedure (hashtable-map->lset (hashtable hashtable?) (proc procedure?) ) ⟹ list?
(proc key value ) ⟹ *
Proc should accept two arguments, should return a single value, and should not mutate hashtable. The hashtable-map->lset procedure applies proc once for every association in hashtable, passing it the key and value as arguments, and accumulates the returned values into a list. The order in which proc is applied to the associations, and the order of the results in the returned list, are unspecified.
(srfi 126) procedure (hashtable-find (hashtable hashtable?) (proc procedure?) ) ⟹ (values **boolean?)
(proc key value ) ⟹ boolean?
Proc should accept two arguments, should return a single value, and should not mutate hashtable. The hashtable-find procedure applies proc to associations in hashtable in an unspecified order until one of the applications returns a true value or the associations are exhausted. Three values are returned: the key and value of the matching association or two unspecified values if none matched, and a Boolean indicating whether any association matched.
(srfi 126) procedure (hashtable-empty? (hashtable hashtable?) ) ⟹ boolean?
Effectively equivalent to:
(zero? (hashtable-size hashtable))
(srfi 126) procedure (hashtable-pop! (hashtable hashtable?) ) ⟹ *
Effectively equivalent to:
(let-values (((key value found?)
(hashtable-find hashtable (lambda (k v) #t))))
(when (not found?)
(error))
(hashtable-delete! hashtable key)
(values key value))
(srfi 126) procedure (hashtable-inc! (hashtable hashtable?) key ) ⟹ boolean?
(srfi 126) procedure (hashtable-inc! (hashtable hashtable?) key (number number?) ) ⟹ boolean?
Effectively equivalent to:
(hashtable-update! hashtable key (lambda (v) (+ v number)) 0)
where number is 1 when not provided.
(srfi 126) procedure (hashtable-dec! (hashtable hashtable?) key ) ⟹ boolean?
(srfi 126) procedure (hashtable-dec! (hashtable hashtable?) key (number number?) ) ⟹ boolean?
Effectively equivalent to:
(hashtable-update! hashtable key (lambda (v) (- v number)) 0)
where number is 1 when not provided.
(srfi 126) procedure (hashtable-equivalence-function (hashtable hashtable?) ) ⟹ procedure?
(return a b ) ⟹ boolean?
Returns the equivalence function used by hashtable to compare keys. For hashtables created with make-eq-hashtable and make-eqv-hashtable, returns eq? and eqv? respectively.
(srfi 126) procedure (hashtable-hash-function (hashtable hashtable?) ) ⟹ procedure?
(return key ) ⟹ integer?
Returns the hash function(s) used by hashtable, that is, either a procedure, or a pair of procedures. For hashtables created by make-eq-hashtable or make-eqv-hashtable, #f is returned.
(srfi 126) procedure (hashtable-weakness (hashtable hashtable?) ) ⟹ #f / sybmol? /
Returns the weakness attribute of hashtable. The same values that are accepted as the weakness argument in the constructor procedures are returned. This procedure may expose the fact that weak-key and weak-value hashtables are implemented as ephemeral-key and ephemeral-value hashtables, returning symbols indicating the latter even when the former were used to construct the hashtable.
(srfi 126) procedure (hashtable-mutable? (hashtable hashtable?) ) ⟹ boolean?
Returns #t if hashtable is mutable, otherwise #f.
(srfi 126) syntax (hash-salt () ((_) integer? ) )
Expands to a form evaluating to an exact non-negative integer that lies within the fixnum range of the implementation. The value the expanded form evaluates to remains constant throughout the execution of the program. It is random for every run of the program, except when the environment variable SRFI_126_HASH_SEED is set to a non-empty string before program startup, in which case it is derived from the value of that environment variable in a deterministic manner.
(srfi 126) procedure (equal-hash obj ) ⟹ integer?
Returns an integer hash value for obj, based on its structure and current contents. This hash function is suitable for use with equal? as an equivalence function.
(srfi 126) procedure (string-hash (string string?) ) ⟹ integer?
Returns an integer hash value for string, based on its current contents. This hash function is suitable for use with string=? as an equivalence function.
(srfi 126) procedure (string-ci-hash (string string?) ) ⟹ integer?
Returns an integer hash value for string based on its current contents, ignoring case. This hash function is suitable for use with string-ci=? as an equivalence function.
(srfi 126) procedure (symbol-hash (symbol symbol?) ) ⟹ integer?
Returns an integer hash value for symbol.
library (srfi 127)
(srfi 127) procedure (generator->lseq (generator procedure?) ) ⟹ lseq?
(generator ) ⟹ *
Returns an lseq whose elements are the values generated by generator. The exact behavior is as follows:
(srfi 127) procedure (lseq? x ) ⟹ boolean?
Returns #t if x is an lseq. This procedure may also return #t if x is an improper list whose last cdr is a procedure that requires arguments, since there is no portable way to examine a procedure to determine how many arguments it requires. Otherwise it returns #f.
(srfi 127) procedure (lseq=? (elt=? procedure?) (lseq1 lseq?) (lseq2 lseq?) ) ⟹ boolean?
(elt=? a b ) ⟹ boolean?
Determines lseq equality, given an element-equality procedure. Two lseqs are equal if they are of the same length, and their corresponding elements are equal, as determined by elt=?. When elt=? is called, its first argument is always from lseq1 and its second argument is from lseq2.
The dynamic order in which the elt=? procedure is applied to pairs of elements is not specified.
The elt=? procedure must be consistent with eq?. This implies that two lseqs which are eq? are always lseq=?, as well; implementations may exploit this fact to "short-cut" the element-by-element equality tests.
(srfi 127) procedure (lseq-car (lseq lseq?) ) ⟹ *
Returns the first element of lseq. It is included for completeness, as it is the same as car. It is an error to apply it to an empty lseq.
(srfi 127) procedure (lseq-first (lseq lseq?) ) ⟹ *
Returns the first element of lseq. It is included for completeness, as it is the same as car. It is an error to apply it to an empty lseq.
(srfi 127) procedure (lseq-cdr (lseq lseq?) ) ⟹ lseq?
Returns an lseq with the contents of lseq except for the first element. The exact behavior is as follows:
If obj is an end-of-file object, then the cdr of lseq is set to the empty list, which is returned.
If obj is any other object, then a new pair is allocated whose car is obj and whose cdr is the cdr of lseq (i.e. the procedure). The cdr of lseq is set to the newly allocated pair, which is returned.
(srfi 127) procedure (lseq-rest (lseq lseq?) ) ⟹ lseq?
Returns an lseq with the contents of lseq except for the first element. The exact behavior is as follows:
If obj is an end-of-file object, then the cdr of lseq is set to the empty list, which is returned.
If obj is any other object, then a new pair is allocated whose car is obj and whose cdr is the cdr of lseq (i.e. the procedure). The cdr of lseq is set to the newly allocated pair, which is returned.
(srfi 127) procedure (lseq-ref (lseq lseq?) (i integer?) ) ⟹ *
Returns the ith element of lseq. (This is the same as (lseq-first (lseq-drop lseq i)).) It is an error if i >= n, where n is the length of lseq.
(srfi 127) procedure (lseq-take (lseq lseq?) (i integer?) ) ⟹ lseq?
lseq-take lazily returns the first i elements of lseq.
(srfi 127) procedure (lseq-drop (lseq lseq?) (i integer?) ) ⟹ lseq?
lseq-drop returns all but the first i elements of lseq.
(srfi 127) procedure (lseq-realize (lseq lseq?) ) ⟹ list?
Repeatedly applies lseq-cdr to lseq until its generator (if there is one) has been exhausted, and returns lseq, which is now guaranteed to be a proper list. This procedure can be called on an arbitrary lseq before passing it to a procedure which only accepts lists. However, if the generator never returns an end-of-file object, lseq-realize will never return.
(srfi 127) procedure (lseq->generator (lseq lseq?) ) ⟹ procedure?
(return ) ⟹ *
Returns a generator which when invoked will return all the elements of lseq, including any that have not yet been realized.
(srfi 127) procedure (lseq-length (lseq lseq?) ) ⟹ integer?
Returns the length of its argument, which is the non-negative integer n such that lseq-rest applied n times to the lseq produces an empty lseq. lseq must be finite, or this procedure will not return.
(srfi 127) procedure (lseq-append (lseq lseq?) ... ) ⟹ lseq?
Returns an lseq that lazily contains all the elements of all the lseqs in order.
(srfi 127) procedure (lseq-zip (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ lseq?
If lseq-zip is passed n lseqs, it lazily returns an lseq each element of which is an n-element list comprised of the corresponding elements from the lseqs. If any of the lseqs are finite in length, the result is as long as the shortest lseq.
(srfi 127) procedure (lseq-map (proc procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ lseq?
(proc value1 value2 ... ) ⟹ *
The lseq-map procedure lazily applies proc element-wise to the corresponding elements of the lseqs, where proc is a procedure taking as many arguments as there are lseqs and returning a single value, and returns an lseq of the results in order. The dynamic order in which proc is applied to the elements of the lseqs is unspecified.
(srfi 127) procedure (lseq-for-each (proc procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ *
(proc value1 value2 ... ) ⟹ *
The arguments to lseq-for-each are like the arguments to lseq-map, but lseq-for-each calls proc for its side effects rather than for its values. Unlike lseq-map, lseq-for-each is guaranteed to call proc on the elements of the lseqs in order from the first element(s) to the last, and the value returned by lseq-for-each is unspecified.
If none of the lseqs are finite, lseq-for-each never returns.
(srfi 127) procedure (lseq-filter (pred procedure?) (lseq lseq?) ) ⟹ lseq?
(pred element ) ⟹ boolean?
The procedure lseq-filter lazily returns an lseq that contains only the elements of lseq that satisfy pred.
(srfi 127) procedure (lseq-remove (pred procedure?) (lseq lseq?) ) ⟹ lseq?
(pred element ) ⟹ boolean?
The procedure lseq-remove is the same as lseq-filter, except that it returns elements that do not satisfy pred. These procedures are guaranteed to call pred on the elements of the lseqs in sequence order.
(srfi 127) procedure (lseq-find (pred procedure?) (lseq lseq?) ) ⟹ *
(pred element ) ⟹ boolean?
Return the first element of lseq that satisfies predicate pred, or #f if no element does. It cannot reliably be applied to lseqs that include #f as an element; use lseq-find-tail instead. The predicate is guaranteed to be evaluated on the elements of lseq in sequence order, and only as often as necessary.
(srfi 127) procedure (lseq-find-tail (pred procedure?) (lseq lseq?) ) ⟹ #f / lseq? /
(pred element ) ⟹ boolean?
Returns the longest tail of lseq whose first element satisfies pred, or #f if no element does. The predicate is guaranteed to be evaluated on the elements of lseq in sequence order, and only as often as necessary. lseq-find-tail can be viewed as a general-predicate variant of the lseq-member function.
(srfi 127) procedure (lseq-take-while (pred procedure?) (lseq lseq?) ) ⟹ lseq?
(pred element ) ⟹ boolean?
Lazily returns the longest initial prefix of lseq whose elements all satisfy the predicate pred.
(srfi 127) procedure (lseq-drop-while (pred procedure?) (lseq lseq?) ) ⟹ lseq?
(pred element ) ⟹ boolean?
Drops the longest initial prefix of lseq whose elements all satisfy the predicate pred, and returns the rest of the lseq. Note that lseq-drop-while is essentially lseq-find-tail where the sense of the predicate is inverted: lseq-find-tail searches until it finds an element satisfying the predicate; lseq-drop-while searches until it finds an element that doesn't satisfy the predicate.
(srfi 127) procedure (lseq-any (pred procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ *
(pred element ) ⟹ *
Applies pred to successive elements of the lseqs, returning true if pred returns true on any application. If an application returns a true value, lseq-any immediately returns that value. Otherwise, it iterates until a true value is produced or one of the lseqs runs out of values; in the latter case, lseq-any returns #f. It is an error if pred does not accept the same number of arguments as there are lseqs and return a boolean result. Note the difference between lseq-find and lseq-any — lseq-find returns the element that satisfied the predicate; lseq-any returns the true value that the predicate produced. Like lseq-every, lseq-any's name does not end with a question mark — this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(srfi 127) procedure (lseq-every (pred procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ *
(pred element ) ⟹ *
Applies pred to successive elements of the lseqs, returning true if the predicate returns true on every application. If an application returns a false value, lseq-every immediately returns that value. Otherwise, it iterates until a false value is produced or one of the lseqs runs out of values; in the latter case, lseq-every returns the last value returned by pred, or #t if pred was never invoked. It is an error if pred does not accept the same number of arguments as there are lseqs and return a boolean result. Like lseq-any, lseq-every's name does not end with a question mark — this is to indicate that it does not return a simple boolean (#t or #f), but a general value.
(srfi 127) procedure (lseq-index (pred procedure?) (lseq1 lseq?) (lseq2 lseq?) ... ) ⟹ integer? / #f /
(pred element ) ⟹ *
Return the index of the leftmost element that satisfies pred. Applies pred to successive elements of the lseqs, returning an index usable with lseq-ref if the predicate returns true. Otherwise, it iterates until one of the lseqs runs out of values, in which case #f is returned. It is an error if pred does not accept the same number of arguments as there are lseqs and return a boolean result. The iteration stops when one of the lseqs runs out of values; in this case, lseq-index returns #f.
(srfi 127) procedure (lseq-member x (lseq lseq?) ) ⟹ #f / lseq? /
(srfi 127) procedure (lseq-member x (lseq lseq?) (= procedure?) ) ⟹ #f / lseq? /
(= a b ) ⟹ boolean?
Returns the longest tail of lseq whose first element is x, where the tails of lseq are the non-empty lseqs returned by (lseq-drop lseq i) for i less than the length of lseq. If x does not occur in lseq, then #f is returned. lseq-member uses pred to compare x with the elements of lseq, which defaults to equal?.
The equality procedure is used to compare the elements ei of lseq to the key x in this way: the first argument is always x, and the second argument is one of the lseq elements. Thus one can reliably find the first element of lseq that is greater than five with (lseq-member 5 lseq <)
Note that fully general lseq searching may be performed with the lseq-find-tail procedure.
(srfi 127) procedure (lseq-memq x (lseq lseq?) ) ⟹ #f / lseq? /
Returns the longest tail of lseq whose first element is x, where the tails of lseq are the non-empty lseqs returned by (lseq-drop lseq i) for i less than the length of lseq. If x does not occur in lseq, then #f is returned. lseq-memq uses eq? to compare x with the elements of lseq.
The equality procedure is used to compare the elements ei of lseq to the key x in this way: the first argument is always x, and the second argument is one of the lseq elements. Thus one can reliably find the first element of lseq that is greater than five with (lseq-member 5 lseq <)
Note that fully general lseq searching may be performed with the lseq-find-tail procedure.
(srfi 127) procedure (lseq-memv x (lseq lseq?) ) ⟹ #f / lseq? /
Returns the longest tail of lseq whose first element is x, where the tails of lseq are the non-empty lseqs returned by (lseq-drop lseq i) for i less than the length of lseq. If x does not occur in lseq, then #f is returned. lseq-memv uses eqv? to compare x with the elements of lseq.
The equality procedure is used to compare the elements ei of lseq to the key x in this way: the first argument is always x, and the second argument is one of the lseq elements. Thus one can reliably find the first element of lseq that is greater than five with (lseq-member 5 lseq <)
Note that fully general lseq searching may be performed with the lseq-find-tail procedure.
library (srfi 128)
(srfi 128) procedure (comparator? obj ) ⟹ boolean?
Returns #t if obj is a comparator, and #f otherwise.
(srfi 128) procedure (comparator-ordered? (comparator comparator?) ) ⟹ boolean?
Returns #t if comparator has a supplied ordering predicate, and #f otherwise.
(srfi 128) procedure (comparator-hashable? (comparator comparator?) ) ⟹ boolean?
Returns #t if comparator has a supplied hash function, and #f otherwise.
(srfi 128) procedure (make-comparator (type-test procedure?) (equality procedure?) (ordering (or procedure?#f)) (hash (or procedure?#f)) ) ⟹ comparator?
(type-test obj ) ⟹ boolean?
(equality obj1 obj2 ) ⟹ boolean?
(ordering obj1 obj2 ) ⟹ boolean?
(hash obj ) ⟹ integer?
Returns a comparator which bundles the type-test, equality, ordering, and hash procedures provided. However, if ordering or hash is #f, a procedure is provided that signals an error on application. The predicates comparator-ordered? and/or comparator-hashable?, respectively, will return #f in these cases.
(srfi 128) procedure (make-pair-comparator (car-comparator comparator?) (cdr-comparator comparator?) ) ⟹ comparator?
This procedure returns comparators whose functions behave as follows.
1 The type test returns #t if its argument is a pair, if the car satisfies the type test predicate of car-comparator, and the cdr satisfies the type test predicate of cdr-comparator.
2 The equality function returns #t if the cars are equal according to car-comparator and the cdrs are equal according to cdr-comparator, and #f otherwise.
3 The ordering function first compares the cars of its pairs using the equality predicate of car-comparator. If they are not equal, then the ordering predicate of car-comparator is applied to the cars and its value is returned. Otherwise, the predicate compares the cdrs using the equality predicate of cdr-comparator. If they are not equal, then the ordering predicate of cdr-comparator is applied to the cdrs and its value is returned.
4 The hash function computes the hash values of the car and the cdr using the hash functions of car-comparator and cdr-comparator respectively and then hashes them together in an implementation-defined way.
(srfi 128) procedure (make-list-comparator (element-comparator comparator?) (type-test procedure?) (empty? procedure?) (head procedure?) (tail procedure?) ) ⟹ comparator?
(type-test obj ) ⟹ boolean?
(empty? obj ) ⟹ boolean?
(head obj ) ⟹ *
(tail obj ) ⟹ *
This procedure returns comparators whose functions behave as follows:
1 The type test returns #t if its argument satisfies type-test and the elements satisfy the type test predicate of element-comparator.
2 The total order defined by the equality and ordering functions is as follows (known as lexicographic order):
2.1 The empty sequence, as determined by calling empty?, compares equal to itself.
2.2 The empty sequence compares less than any non-empty sequence.
2.3 Two non-empty sequences are compared by calling the head procedure on each. If the heads are not equal when compared using element-comparator, the result is the result of that comparison. Otherwise, the results of calling the tail procedure are compared recursively.
3 The hash function computes the hash values of the elements using the hash function of element-comparator and then hashes them together in an implementation-defined way.
(srfi 128) procedure (make-vector-comparator (element-comparator comparator?) (type-test procedure?) (length procedure?) (ref procedure?) ) ⟹ comparator?
(type-test obj ) ⟹ boolean?
(length obj ) ⟹ integer?
(ref vec (index integer?) ) ⟹ *
This procedure returns comparators whose functions behave as follows:
1 The type test returns #t if its argument satisfies type-test and the elements satisfy the type test predicate of element-comparator.
2 The equality predicate returns #t if both of the following tests are satisfied in order: the lengths of the vectors are the same in the sense of =, and the elements of the vectors are the same in the sense of the equality predicate of element-comparator.
3 The ordering predicate returns #t if the results of applying length to the first vector is less than the result of applying length to the second vector. If the lengths are equal, then the elements are examined pairwise using the ordering predicate of element-comparator. If any pair of elements returns #t, then that is the result of the list comparator's ordering predicate; otherwise the result is #f
4 The hash function computes the hash values of the elements using the hash function of element-comparator and then hashes them together in an implementation-defined way.
(srfi 128) procedure (make-eq-comparator ) ⟹ comparator?
make-eq-comparator, make-eqv-comparator, make-equal-comparator These procedures return comparators whose functions behave as follows:
1 The type test returns #t in all cases.
2 The equality functions are eq?, eqv?, and equal? respectively.
3 The ordering function is implementation-defined, except that it must conform to the rules for ordering functions. It may signal an error instead.
4 The hash function is default-hash.
(srfi 128) procedure (make-eqv-comparator ) ⟹ comparator?
make-eq-comparator, make-eqv-comparator, make-equal-comparator These procedures return comparators whose functions behave as follows:
1 The type test returns #t in all cases.
2 The equality functions are eq?, eqv?, and equal? respectively.
3 The ordering function is implementation-defined, except that it must conform to the rules for ordering functions. It may signal an error instead.
4 The hash function is default-hash.
(srfi 128) procedure (make-equal-comparator ) ⟹ comparator?
make-eq-comparator, make-eqv-comparator, make-equal-comparator These procedures return comparators whose functions behave as follows:
1 The type test returns #t in all cases.
2 The equality functions are eq?, eqv?, and equal? respectively.
3 The ordering function is implementation-defined, except that it must conform to the rules for ordering functions. It may signal an error instead.
4 The hash function is default-hash.
(srfi 128) procedure (boolean-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(srfi 128) procedure (char-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(srfi 128) procedure (char-ci-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(srfi 128) procedure (string-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(srfi 128) procedure (string-ci-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(srfi 128) procedure (symbol-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(srfi 128) procedure (number-hash obj ) ⟹ integer?
boolean-hash, char-hash, char-ci-hash string-hash, string-ci-hash, symbol-hash, number-hash These are hash functions for some standard Scheme types, suitable for passing to make-comparator. Users may write their own hash functions with the same signature. However, if programmers wish their hash functions to be backward compatible with the reference implementation of SRFI 69, they are advised to write their hash functions to accept a second argument and ignore it. These are suitable hash functions for the specified types. The hash functions char-ci-hash and string-ci-hash treat their argument case-insensitively. Note that while symbol-hash may return the hashed value of applying symbol->string and then string-hash to the symbol, this is not a requirement.
(srfi 128) syntax (hash-bound () ((_) integer? ) )
Hash functions should be written so as to return a number between 0 and the largest reasonable number of elements (such as hash buckets) a data structure in the implementation might have. What that value is depends on the implementation. This value provides the current bound as a positive exact integer, typically for use by user-written hash functions. However, they are not required to bound their results in this way.
(srfi 128) syntax (hash-salt () ((_) integer? ) )
A salt is random data in the form of a non-negative exact integer used as an additional input to a hash function in order to defend against dictionary attacks, or (when used in hash tables) against denial-of-service attacks that overcrowd certain hash buckets, increasing the amortized O(1) lookup time to O(n). Salt can also be used to specify which of a family of hash functions should be used for purposes such as cuckoo hashing. This macro provides the current value of the salt, typically for use by user-written hash functions. However, they are not required to make use of the current salt.
The initial value is implementation-dependent, but must be less than the value of (hash-bound), and should be distinct for distinct runs of a program unless otherwise specified by the implementation. Implementations may provide a means to specify the salt value to be used by a particular invocation of a hash function.
(srfi 128) procedure (make-default-comparator ) ⟹ comparator?
Returns a comparator known as a default comparator that accepts Scheme values and orders them in some implementation-defined way, subject to the following conditions:
1 Given disjoint types a and b, one of three conditions must hold:
1.1 All objects of type a compare less than all objects of type b.
1.2 All objects of type a compare greater than all objects of type b.
1.3 All objects of both type a and type b compare equal to each other. This is not permitted for any of the Scheme types mentioned below.
2 The empty list must be ordered before all pairs.
3 When comparing booleans, it must use the total order #f < #t.
4 When comparing characters, it must use char=? and char<?. Note: In R5RS, this is an implementation-dependent order that is typically the same as Unicode codepoint order; in R6RS and R7RS, it is Unicode codepoint order.
5 When comparing pairs, it must behave the same as a comparator returned by make-pair-comparator with default comparators as arguments.
6 When comparing symbols, it must use an implementation-dependent total order. One possibility is to use the order obtained by applying symbol->string to the symbols and comparing them using the total order implied by string<?.
7 When comparing bytevectors, it must behave the same as a comparator created by the expression (make-vector-comparator (make-comparator bytevector? = < number-hash) bytevector? bytevector-length bytevector-u8-ref).
8 When comparing numbers where either number is complex, since non-real numbers cannot be compared with <, the following least-surprising ordering is defined: If the real parts are < or >, so are the numbers; otherwise, the numbers are ordered by their imaginary parts. This can still produce somewhat surprising results if one real part is exact and the other is inexact.
9 When comparing real numbers, it must use = and <.
10 When comparing strings, it must use string=? and string<?. Note: In R5RS, this is lexicographic order on the implementation-dependent order defined by char<?; in R6RS it is lexicographic order on Unicode codepoint order; in R7RS it is an implementation-defined order.
11 When comparing vectors, it must behave the same as a comparator returned by (make-vector-comparator (make-default-comparator) vector? vector-length vector-ref).
12 When comparing members of types registered with comparator-register-default!, it must behave in the same way as the comparator registered using that function.
Default comparators use default-hash as their hash function.
(srfi 128) procedure (default-hash obj ) ⟹ integer?
This is the hash function used by default comparators, which accepts a Scheme value and hashes it in some implementation-defined way, subject to the following conditions:
1 When applied to a pair, it must return the result of hashing together the values returned by default-hash when applied to the car and the cdr.
2 When applied to a boolean, character, string, symbol, or number, it must return the same result as boolean-hash, char-hash, string-hash, symbol-hash, or number-hash respectively.
3 When applied to a list or vector, it must return the result of hashing together the values returned by default-hash when applied to each of the elements.
(srfi 128) procedure (comparator-register-default! (comparator comparator?) ) ⟹ undefined
Registers comparator for use by default comparators, such that if the objects being compared both satisfy the type test predicate of comparator, it will be employed by default comparators to compare them. Returns an unspecified value. It is an error if any value satisfies both the type test predicate of comparator and any of the following type test predicates: boolean?, char?, null?, pair?, symbol?, bytevector?, number?, string?, vector?, or the type test predicate of a comparator that has already been registered.
This procedure is intended only to extend default comparators into territory that would otherwise be undefined, not to override their existing behavior. In general, the ordering of calls to comparator-register-default! should be irrelevant. However, implementations that support inheritance of record types may wish to ensure that default comparators always check subtypes before supertypes.
This SRFI recommends (but does not require) that libraries which expose comparators do not register them with this procedure, because the default comparator (which is meant mostly for ad hoc programming) is meant to be under the control of the program author rather than the library author. It is the program author's responsibility to ensure that the registered comparators do not conflict with each other.
(srfi 128) procedure (comparator-type-test-predicate (comparator comparator?) ) ⟹ procedure?
(return obj ) ⟹ boolean?
(srfi 128) procedure (comparator-equality-predicate (comparator comparator?) ) ⟹ procedure?
(return obj1 obj2 ) ⟹ boolean?
(srfi 128) procedure (comparator-ordering-predicate (comparator comparator?) ) ⟹ #f / procedure? /
(return obj1 obj2 ) ⟹ boolean?
(srfi 128) procedure (comparator-hash-function (comparator comparator?) ) ⟹ #f / procedure? /
(return obj ) ⟹ integer?
Return the four procedures of comparator.
(srfi 128) procedure (comparator-test-type (comparator comparator?) obj ) ⟹ boolean?
Invokes the type test predicate of comparator on obj and returns what it returns. More convenient than comparator-type-test-predicate, but less efficient when the predicate is called repeatedly.
(srfi 128) procedure (comparator-check-type (comparator comparator?) obj ) ⟹ boolean?
Invokes the type test predicate of comparator on obj and returns true if it returns true, but signals an error otherwise. More convenient than comparator-type-test-predicate, but less efficient when the predicate is called repeatedly.
(srfi 128) procedure (comparator-hash (comparator comparator?) obj ) ⟹ integer?
Invokes the hash function of comparator on obj and returns what it returns. More convenient than comparator-hash-function, but less efficient when the function is called repeatedly. Note: No invokers are required for the equality and ordering predicates, because =? and <? serve this function.
(srfi 128) procedure (=? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(srfi 128) procedure (<? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(srfi 128) procedure (>? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(srfi 128) procedure (<=? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(srfi 128) procedure (>=? (comparator comparator?) object1 object2 object3 ... ) ⟹ boolean?
=?, <?, >?, <=?, >=? These procedures are analogous to the number, character, and string comparison predicates of Scheme. They allow the convenient use of comparators to handle variable data types.
These procedures apply the equality and ordering predicates of comparator to the objects as follows. If the specified relation returns #t for all objecti and objectj where n is the number of objects and 1 <= i < j <= n, then the procedures return #t, but otherwise #f. Because the relations are transitive, it suffices to compare each object with its successor. The order in which the values are compared is unspecified.
(srfi 128) syntax (comparator-if<=> () ((_ comparator object1 object2 less-than equal-to greater-than)) ((_ object1 object2 less-than equal-to greater-than)) )
comparator ⟹ comparator?
It is an error unless <comparator> evaluates to a comparator and <object1> and <object2> evaluate to objects that the comparator can handle. If the ordering predicate returns true when applied to the values of <object1> and <object2> in that order, then <less-than> is evaluated and its value returned. If the equality predicate returns true when applied in the same way, then <equal-to> is evaluated and its value returned. If neither returns true, <greater-than> is evaluated and its value returned.
If <comparator> is omitted, a default comparator is used.
library (srfi 129)
(srfi 129) procedure (char-title-case? (char char?) ) ⟹ boolean?
Returns #t if char is a character belonging to the Unicode category Lt, and #f otherwise. (The same as the R6RS equivalent.)
(srfi 129) procedure (char-titlecase (char char?) ) ⟹ char?
Returns the titlecase equivalent of char, if that character exists in the implementation, and char otherwise. The titlecase equivalent of a character is typically not a titlecase character; for most characters it is the same as the uppercase equivalent or else the character itself. Note that language-sensitive mappings are not used. (The same as the R6RS equivalent.)
(srfi 129) procedure (string-titlecase (string string?) ) ⟹ string?
This procedure applies the Unicode full string lowercasing algorithm to its argument. However, any character preceded by a non-cased character, or which is the first character of string, is processed by a different algorithm. If such a character has a multi-character titlecase mapping specified by Unicode, and all the characters of the mapping are supported by the implementation, then it is replaced by that mapping. Otherwise, it is replaced by its single-character titlecase mapping as if by char-titlecase. The result of the application of these algorithms is returned.
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 are not used. (The R6RS version does not make use of multi-character mappings.)
library (srfi 130)
(srfi 130) procedure (string-cursor? obj ) ⟹ boolean?
Returns #t if obj can be a string cursor, and #f otherwise. In implementations where cursors and indexes are the same thing, #t is returned on any cursor or index; where they are disjoint, #t is returned on cursors, #f on indexes. If obj is neither a cursor nor an index, string-cursor? will always return #f.
(srfi 130) procedure (string-cursor-start (s string?) ) ⟹ string-cursor?
(srfi 130) procedure (string-cursor-end (s string?) ) ⟹ string-cursor?
Returns the start/post-end cursor of s respectively.
(srfi 130) procedure (string-cursor-next (s string?) (cursor (or integer?string-cursor?)) ) ⟹ string-cursor?
(srfi 130) procedure (string-cursor-prev (s string?) (cursor (or integer?string-cursor?)) ) ⟹ string-cursor?
Returns the cursor into s following/preceding cursor. If cursor is an index, returns one more/less than cursor. It is an error if cursor is the post-end/start cursor of s.
(srfi 130) procedure (string-cursor-forward (s string?) (cursor (or integer?string-cursor?)) (nchars integer?) ) ⟹ string-cursor?
(srfi 130) procedure (string-cursor-back (s string?) (cursor (or integer?string-cursor?)) (nchars integer?) ) ⟹ string-cursor?
Returns the cursor into s which follows/precedes cursor by nchars characters. If cursor is an index, returns nchars more/less than cursor. It is an error if the result would be an invalid cursor or index.
(srfi 130) procedure (string-cursor=? (cursor1 (or integer?string-cursor?)) (cursor2 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-cursor<? (cursor1 (or integer?string-cursor?)) (cursor2 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-cursor>? (cursor1 (or integer?string-cursor?)) (cursor2 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-cursor<=? (cursor1 (or integer?string-cursor?)) (cursor2 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-cursor>=? (cursor1 (or integer?string-cursor?)) (cursor2 (or integer?string-cursor?)) ) ⟹ boolean?
Compares two cursors or two indexes pointing into the same string.
(srfi 130) procedure (string-cursor-diff (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ integer?
Returns the number of characters between start and end in string s. Note that the result is always non-negative if start and end are a valid start-end pair.
(srfi 130) procedure (string-cursor->index (s string?) (cursor string-cursor?) ) ⟹ integer?
(srfi 130) procedure (string-index->cursor (s string?) (index integer?) ) ⟹ string-cursor?
Converts a cursor/index into s into the corresponding index/cursor. If the argument is already an index/cursor, it is returned unchanged.
(srfi 130) procedure (string-null? (s string?) ) ⟹ boolean?
Is s the empty string?
(srfi 130) procedure (string-every (pred procedure?) (s string?) ) ⟹ *
(srfi 130) procedure (string-every (pred procedure?) (s string?) (start (or integer?string-cursor?)) ) ⟹ *
(srfi 130) procedure (string-every (pred procedure?) (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ *
(pred (c char?) ) ⟹ *
(srfi 130) procedure (string-any (pred procedure?) (s string?) ) ⟹ *
(srfi 130) procedure (string-any (pred procedure?) (s string?) (start (or integer?string-cursor?)) ) ⟹ *
(srfi 130) procedure (string-any (pred procedure?) (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ *
(pred (c char?) ) ⟹ *
Checks to see if every/any character in s satisfies pred proceeding from left (index start) to right (index end). The predicate is "witness-generating":
The names of these procedures do not end with a question mark — this is to indicate that they do not return a simple boolean (#t or #f), but a general value.
(srfi 130) procedure (string-tabulate (proc procedure?) (len integer?) ) ⟹ string?
(srfi 130) procedure (string-tabulate (proc procedure?) (len integer?) ) ⟹ string?
(proc (index integer?) ) ⟹ char?
Proc is an integer → char procedure. Construct a string of size len by applying proc to each value from 0 (inclusive) to len (exclusive) to produce the corresponding string element. The order in which proc is applied to the indexes is not specified.
Note that the order of arguments is not the same as SRFI 1's list-tabulate, but is the same as tabulation functions in other SRFIs. When this discrepancy was discovered in SRFI 13, it was too late to change SRFI 1.
(srfi 130) procedure (string-unfold (stop? procedure?) (mapper procedure?) seed ) ⟹ string?
(srfi 130) procedure (string-unfold (stop? procedure?) (mapper procedure?) seed (base string?) ) ⟹ string?
(srfi 130) procedure (string-unfold (stop? procedure?) (mapper procedure?) seed (base string?) (make-final procedure?) ) ⟹ string?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char?
(make-final seed ) ⟹ string?
This is a fundamental constructor for strings.
string-unfold is a fairly powerful string constructor — you can use it to convert a list to a string, read a port into a string, reverse a string, copy a string, and so forth.
(srfi 130) procedure (string-unfold-right (stop? procedure?) (mapper procedure?) seed ) ⟹ string?
(srfi 130) procedure (string-unfold-right (stop? procedure?) (mapper procedure?) seed (base string?) ) ⟹ string?
(srfi 130) procedure (string-unfold-right (stop? procedure?) (mapper procedure?) seed (base string?) (make-final procedure?) ) ⟹ string?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char?
(make-final seed ) ⟹ string?
This is a fundamental constructor for strings. It is equivalent to string-unfold, except that the results of mapper are assembled into the string in a right-to-left order, base is the optional rightmost portion of the constructed string, and make-final produces the leftmost portion of the constructed string.
(srfi 130) procedure (string->list/cursors (s string?) ) ⟹ list?
(srfi 130) procedure (string->list/cursors (s string?) (start (or integer?string-cursor?)) ) ⟹ list?
(srfi 130) procedure (string->list/cursors (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ list?
return ⟹ (list (c char?) )
(srfi 130) procedure (string->vector/cursors (s string?) ) ⟹ vector?
(srfi 130) procedure (string->vector/cursors (s string?) (start (or integer?string-cursor?)) ) ⟹ vector?
(srfi 130) procedure (string->vector/cursors (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ vector?
return ⟹ (vector (c char?) )
string->list/cursors and string->vector/cursors return a newly allocated list or vector of the characters that make up the given string. They differ from the R7RS procedures string->list and string->vector by accepting either cursors or indexes.
(srfi 130) procedure (reverse-list->string (char-list list?) ) ⟹ string?
An efficient implementation of (compose list->string reverse):
(reverse-list->string '(#\a #\B #\c)) → "cBa"
This is a common idiom in the epilog of string-processing loops that accumulate an answer in a reverse-order list. (See also string-concatenate-reverse for the "chunked" variant.)
(srfi 130) procedure (string-join (string-list list?) ) ⟹ string?
(srfi 130) procedure (string-join (string-list list?) (delimiter string?) ) ⟹ string?
(srfi 130) procedure (string-join (string-list list?) (delimiter string?) (grammar symbol?) ) ⟹ string?
This procedure is a simple unparser —- it pastes strings together using the delimiter string.
The grammar argument is a symbol that determines how the delimiter is used, and defaults to 'infix.
'infix means an infix or separator grammar: insert the delimiter between list elements. An empty list will produce an empty string — note, however, that parsing an empty string with an infix or separator grammar is ambiguous. Is it an empty list, or a list of one element, the empty string?
'strict-infix means the same as 'infix, but will signal an error if given an empty list.
'suffix means a suffix or terminator grammar: insert the delimiter after every list element. This grammar has no ambiguities.
'prefix means a prefix grammar: insert the delimiter before every list element. This grammar has no ambiguities.
The delimiter is the string used to delimit elements; it defaults to a single space " ".
(srfi 130) procedure (string-ref/cursor (s string?) (cursor (or integer?string-cursor?)) ) ⟹ char?
Returns character s[i] using a valid cursor or index of s. It differs from the R7RS procedure string-ref by accepting either a cursor or an index.
(srfi 130) procedure (substring/cursors (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-copy/cursors (s string?) ) ⟹ string?
(srfi 130) procedure (string-copy/cursors (s string?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-copy/cursors (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
These procedures return a string whose contents are the characters of s beginning with index start (inclusive) and ending with index end (exclusive). If substring/cursors produces the entire string, it may return either s or a copy of s; in some implementations, proper substrings may share memory with s. However, string-copy/cursors always returns a newly allocated string. They differ from the R7RS procedures substring and string-copy by accepting either cursors or indexes.
(srfi 130) procedure (string-take (s string?) (nchars integer?) ) ⟹ string?
(srfi 130) procedure (string-drop (s string?) (nchars integer?) ) ⟹ string?
(srfi 130) procedure (string-take-right (s string?) (nchars integer?) ) ⟹ string?
(srfi 130) procedure (string-drop-right (s string?) (nchars integer?) ) ⟹ string?
string-take returns the first nchars of s; string-drop returns all but the first nchars of s. string-take-right returns the last nchars of s; string-drop-right returns all but the last nchars of s. If these procedures produce the entire string, they may return either s or a copy of s; in some implementations, proper substrings may share memory with s.
(srfi 130) procedure (string-pad (s string?) (len integer?) ) ⟹ string?
(srfi 130) procedure (string-pad (s string?) (len integer?) (char char?) ) ⟹ string?
(srfi 130) procedure (string-pad (s string?) (len integer?) (char char?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-pad (s string?) (len integer?) (char char?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-pad-right (s string?) (len integer?) ) ⟹ string?
(srfi 130) procedure (string-pad-right (s string?) (len integer?) (char char?) ) ⟹ string?
(srfi 130) procedure (string-pad-right (s string?) (len integer?) (char char?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-pad-right (s string?) (len integer?) (char char?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
Build a string of length len comprised of s padded on the left (right) by as many occurrences of the character char as needed. If s has more than len chars, it is truncated on the left (right) to length len. Char defaults to #\space.
If len <= end-start, the returned value is allowed to share storage with s, or be exactly s (if len = end-start).
(srfi 130) procedure (string-trim (s string?) ) ⟹ string?
(srfi 130) procedure (string-trim (s string?) (pred procedure?) ) ⟹ string?
(srfi 130) procedure (string-trim (s string?) (pred procedure?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-trim (s string?) (pred procedure?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
(pred (c char?) ) ⟹ boolean?
(srfi 130) procedure (string-trim-right (s string?) ) ⟹ string?
(srfi 130) procedure (string-trim-right (s string?) (pred procedure?) ) ⟹ string?
(srfi 130) procedure (string-trim-right (s string?) (pred procedure?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-trim-right (s string?) (pred procedure?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
(pred (c char?) ) ⟹ boolean?
(srfi 130) procedure (string-trim-both (s string?) ) ⟹ string?
(srfi 130) procedure (string-trim-both (s string?) (pred procedure?) ) ⟹ string?
(srfi 130) procedure (string-trim-both (s string?) (pred procedure?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-trim-both (s string?) (pred procedure?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
(pred (c char?) ) ⟹ boolean?
Trim s by skipping over all characters on the left / on the right / on both sides that satisfy the second parameter pred: pred defaults to char-whitespace?.
If no trimming occurs, these functions may return either s or a copy of s; in some implementations, proper substrings may share memory with s.
(srfi 130) procedure (string-prefix-length (s1 string?) (s2 string?) ) ⟹ integer?
(srfi 130) procedure (string-prefix-length (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) ) ⟹ integer?
(srfi 130) procedure (string-prefix-length (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) ) ⟹ integer?
(srfi 130) procedure (string-prefix-length (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) ) ⟹ integer?
(srfi 130) procedure (string-prefix-length (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) (end2 (or integer?string-cursor?)) ) ⟹ integer?
(srfi 130) procedure (string-suffix-length (s1 string?) (s2 string?) ) ⟹ integer?
(srfi 130) procedure (string-suffix-length (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) ) ⟹ integer?
(srfi 130) procedure (string-suffix-length (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) ) ⟹ integer?
(srfi 130) procedure (string-suffix-length (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) ) ⟹ integer?
(srfi 130) procedure (string-suffix-length (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) (end2 (or integer?string-cursor?)) ) ⟹ integer?
Return the length of the longest common prefix/suffix of the two strings. For prefixes, this is equivalent to the "mismatch index" for the strings (modulo the start cursors).
The optional start/end cursors or indexes restrict the comparison to the indicated substrings of s1 and s2.
(srfi 130) procedure (string-prefix? (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 130) procedure (string-prefix? (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-prefix? (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-prefix? (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-prefix? (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) (end2 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-suffix? (s1 string?) (s2 string?) ) ⟹ boolean?
(srfi 130) procedure (string-suffix? (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-suffix? (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-suffix? (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) ) ⟹ boolean?
(srfi 130) procedure (string-suffix? (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) (end2 (or integer?string-cursor?)) ) ⟹ boolean?
Is s1 a prefix/suffix of s2?
The optional start/end cursors or indexes restrict the comparison to the indicated substrings of s1 and s2.
(srfi 130) procedure (string-index (s string?) (pred procedure?) ) ⟹ string-cursor?
(srfi 130) procedure (string-index (s string?) (pred procedure?) (start (or integer?string-cursor?)) ) ⟹ string-cursor?
(srfi 130) procedure (string-index (s string?) (pred procedure?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string-cursor?
(pred (c char?) ) ⟹ boolean?
(srfi 130) procedure (string-index-right (s string?) (pred procedure?) ) ⟹ string-cursor?
(srfi 130) procedure (string-index-right (s string?) (pred procedure?) (start (or integer?string-cursor?)) ) ⟹ string-cursor?
(srfi 130) procedure (string-index-right (s string?) (pred procedure?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string-cursor?
(pred (c char?) ) ⟹ boolean?
(srfi 130) procedure (string-skip (s string?) (pred procedure?) ) ⟹ string-cursor?
(srfi 130) procedure (string-skip (s string?) (pred procedure?) (start (or integer?string-cursor?)) ) ⟹ string-cursor?
(srfi 130) procedure (string-skip (s string?) (pred procedure?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string-cursor?
(pred (c char?) ) ⟹ boolean?
(srfi 130) procedure (string-skip-right (s string?) (pred procedure?) ) ⟹ string-cursor?
(srfi 130) procedure (string-skip-right (s string?) (pred procedure?) (start (or integer?string-cursor?)) ) ⟹ string-cursor?
(srfi 130) procedure (string-skip-right (s string?) (pred procedure?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string-cursor?
(pred (c char?) ) ⟹ boolean?
string-index searches through s from the left, returning the cursor of the first occurrence of a character which satisfies the predicate pred. If no match is found, it returns end. string-index-right searches through s from the right, returning the cursor of the successor of the first occurrence of a character which satisfies the predicate pred. If no match is found, it returns start.
The start and end parameters specify the beginning and end cursors or indexes of the search; the search includes the start, but not the end. Be careful of "fencepost" considerations: when searching right-to-left, the first position considered is (string-cursor-prev end), whereas when searching left-to-right, the first index considered is start. That is, the start/end indexes describe the same half-open interval [start,end) in these procedures that they do in all the other SRFI 130 procedures.
The skip functions are similar, but use the complement of the criteria: they search for the first char that doesn't satisfy pred. E.g., to skip over initial whitespace, say
(substring/cursors s (string-skip s char-whitespace?))
Note that the result is always a cursor, even when start and end are indexes. Use string-cursor->index to convert the result to an index. Therefore, these four functions are not entirely compatible with their SRFI 13 counterparts, which return #f on failure.
These functions can be trivially composed with string-take and string-drop to produce take-while, drop-while, span, and break procedures without loss of efficiency.
(srfi 130) procedure (string-contains (s1 string?) (s2 string?) ) ⟹ #f / string-cursor? /
(srfi 130) procedure (string-contains (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) ) ⟹ #f / string-cursor? /
(srfi 130) procedure (string-contains (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) ) ⟹ #f / string-cursor? /
(srfi 130) procedure (string-contains (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) ) ⟹ #f / string-cursor? /
(srfi 130) procedure (string-contains (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) (end2 (or integer?string-cursor?)) ) ⟹ #f / string-cursor? /
(srfi 130) procedure (string-contains-right (s1 string?) (s2 string?) ) ⟹ #f / string-cursor? /
(srfi 130) procedure (string-contains-right (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) ) ⟹ #f / string-cursor? /
(srfi 130) procedure (string-contains-right (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) ) ⟹ #f / string-cursor? /
(srfi 130) procedure (string-contains-right (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) ) ⟹ #f / string-cursor? /
(srfi 130) procedure (string-contains-right (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) (end2 (or integer?string-cursor?)) ) ⟹ #f / string-cursor? /
Does string s1 contain string s2?
Returns the cursor in s1 referring to the first character of the first/last instance of s2 as a substring, or #f if there is no match. The optional start/end indexes restrict the operation to the indicated substrings.
The returned cursor is in the range [start1,end1). A successful match must lie entirely in the [start1,end1) range of s1.
Note that the result is always a cursor, even when start1 and end1 are indexes.
Use string-cursor->index to convert a cursor result to an index.
(string-contains "eek -- what a geek." "ee"
12 18) ; Searches "a geek"
=> {Cursor 15}
The name of this procedure does not end with a question mark — this is to indicate that it does not return a simple boolean (#t or #f). Rather, it returns either false (#f) or a cursor.
(srfi 130) procedure (string-reverse (s string?) ) ⟹ string?
(srfi 130) procedure (string-reverse (s string?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-reverse (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
Reverse the string.
(srfi 130) procedure (string-concatenate (string-list list?) ) ⟹ string?
Append the elements of string-list together into a single string. Guaranteed to return a freshly allocated string.
Note that the (apply string-append string-list) idiom is not robust for long lists of strings, as some Scheme implementations limit the number of arguments that may be passed to an n-ary procedure.
(srfi 130) procedure (string-concatenate-reverse (string-list list?) ) ⟹ string?
(srfi 130) procedure (string-concatenate-reverse (string-list list?) (final-string string?) ) ⟹ string?
(srfi 130) procedure (string-concatenate-reverse (string-list list?) (final-string string?) (end (or integer?string-cursor?)) ) ⟹ string?
With no optional arguments, this function is equivalent to
(string-concatenate (reverse string-list))
If the optional argument final-string is specified, it is consed onto the beginning of string-list before performing the list-reverse and string-concatenate operations.
If the optional argument end is given, only the characters up to but not including end in final-string are added to the result.
(srfi 130) procedure (string-fold (kons procedure?) knil (s string?) ) ⟹ *
(srfi 130) procedure (string-fold (kons procedure?) knil (s string?) (start (or integer?string-cursor?)) ) ⟹ *
(srfi 130) procedure (string-fold (kons procedure?) knil (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ *
(kons (c char?) state ) ⟹ *
The left-fold operator maps the kons procedure across the string from left to right
(... (kons s[2] (kons s[1] (kons s[0] knil))))
(srfi 130) procedure (string-fold-right (kons procedure?) knil (s string?) ) ⟹ *
(srfi 130) procedure (string-fold-right (kons procedure?) knil (s string?) (start (or integer?string-cursor?)) ) ⟹ *
(srfi 130) procedure (string-fold-right (kons procedure?) knil (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ *
(kons (c char?) state ) ⟹ *
The right-fold operator maps the kons procedure across the string from right to left
(kons s[0] (... (kons s[end-3] (kons s[end-2] (kons s[end-1] knil)))))
(srfi 130) procedure (string-for-each-cursor (proc procedure?) (s string?) ) ⟹ undefined
(srfi 130) procedure (string-for-each-cursor (proc procedure?) (s string?) (start (or integer?string-cursor?)) ) ⟹ undefined
(srfi 130) procedure (string-for-each-cursor (proc procedure?) (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ undefined
(proc (cursor string-cursor?) ) ⟹ undefined
Apply proc to each cursor of s, in order, excluding the post-end cursor. The optional start/end pairs restrict the endpoints of the loop. This is simply a method of looping over a string that is guaranteed to be safe and correct.
(srfi 130) procedure (string-replicate (s string?) (from integer?) (to integer?) ) ⟹ string?
(srfi 130) procedure (string-replicate (s string?) (from integer?) (to integer?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-replicate (s string?) (from integer?) (to integer?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
This is an "extended substring" procedure that implements replicated copying of a substring of some string.
S is a string; start and end are optional arguments that demarcate a substring of s, defaulting to 0 and the length of s (i.e., the whole string). Replicate this substring up and down index space, in both the positive and negative directions.
string-replicate returns the substring of this string beginning at index from, and ending at to. Note that these arguments cannot be cursors. It is an error if from is greater than to.
Note that
It is an error if start=end — although this is allowed by special dispensation when from=to.
(srfi 130) procedure (string-count (s string?) (pred procedure?) ) ⟹ integer?
(srfi 130) procedure (string-count (s string?) (pred procedure?) (start (or integer?string-cursor?)) ) ⟹ integer?
(srfi 130) procedure (string-count (s string?) (pred procedure?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ integer?
(pred (c char?) ) ⟹ boolean?
Return a count of the number of characters in s that satisfy the pred argument.
(srfi 130) procedure (string-replace (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-replace (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-replace (s1 string?) (s2 string?) (start1 (or integer?string-cursor?)) (end1 (or integer?string-cursor?)) (start2 (or integer?string-cursor?)) (end2 (or integer?string-cursor?)) ) ⟹ string?
The segment of characters in s1 from start1 to end1 is replaced by the segment of characters in s2 from start2 to end2. If start1=end1, this simply splices the s2 characters into s1 at the specified index.
(srfi 130) procedure (string-split (s string?) (delimiter string?) ) ⟹ list?
(srfi 130) procedure (string-split (s string?) (delimiter string?) (grammar symbol?) ) ⟹ list?
(srfi 130) procedure (string-split (s string?) (delimiter string?) (grammar symbol?) (limit (or integer?#f)) ) ⟹ list?
(srfi 130) procedure (string-split (s string?) (delimiter string?) (grammar symbol?) (limit (or integer?#f)) (start (or integer?string-cursor?)) ) ⟹ list?
(srfi 130) procedure (string-split (s string?) (delimiter string?) (grammar symbol?) (limit (or integer?#f)) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ list?
Returns a list of the words contained in the substring of string from start (inclusive) to end (exclusive). Delimiter specifies a string that is to be used as the word separator. This will often be a single character, but multiple characters are allowed for cases like splitting on "\r\n". The returned list will then have one more item than the number of non-overlapping occurrences of the delimiter in the string. If delimiter is an empty string, then the returned list contains a list of strings, each of which contains a single character.
Grammar is a symbol with the same meaning as in the string-join procedure. If it is infix, which is the default, processing is done as described above, except that an empty s produces the empty list; if it is strict-infix, an empty s signals an error. The values prefix and suffix cause a leading/trailing empty string in the result to be suppressed.
If limit is a non-negative exact integer, at most that many splits occur, and the remainder of string is returned as the final element of the list (thus, the result will have at most limit+1 elements). If limit is not specified or is #f, then as many splits as possible are made. It is an error if limit is any other value.
Use SRFI 115's regexp-split to split on a regular expression rather than a simple string.
(srfi 130) procedure (string-filter (pred procedure?) (s string?) ) ⟹ string?
(srfi 130) procedure (string-filter (pred procedure?) (s string?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-filter (pred procedure?) (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
(pred (c char?) ) ⟹ boolean?
(srfi 130) procedure (string-remove (pred procedure?) (s string?) ) ⟹ string?
(srfi 130) procedure (string-remove (pred procedure?) (s string?) (start (or integer?string-cursor?)) ) ⟹ string?
(srfi 130) procedure (string-remove (pred procedure?) (s string?) (start (or integer?string-cursor?)) (end (or integer?string-cursor?)) ) ⟹ string?
(pred (c char?) ) ⟹ boolean?
Filter the string s, retaining only those characters that satisfy / do not satisfy pred.
If the string is unaltered by the filtering operation, these functions may return either s or a copy of s.
Compatibility note: string-remove is identical to the string-delete procedure of SRFI 13, but the name string-delete is inconsistent with the conventions of SRFI 1 and other SRFIs.
library (srfi 131)
(srfi 131) procedure (make-rtd (name symbol?) (fieldspecs vector?) ) ⟹ rtd?
(srfi 131) procedure (make-rtd (name symbol?) (fieldspecs vector?) (parent (or rtd?#f)) ) ⟹ rtd?
name is a symbol, which matters only to the rtd-name procedure of the inspection layer. fieldspecs is a vector of field specifiers, where each field specifier is one of
The optional parent is an rtd or #f. It is an error for any of the symbols in fieldspecs to name more than one of the fields specified by fieldspecs, but the field names in fieldspecs may shadow field names in the parent record-type.
Implementations may wish to extend this procedure to support the non-generative, sealed, and/or opaque features of the R6RS. The recommended way to support those features is to allow any combination of the following arguments to follow the optional parent argument:
The recommendation above is not binding on implementations of SRFI 99. There are other ways to realize sealed, opaque, or non-generative rtds.
Returns an R6RS-compatible record-type descriptor.
(srfi 131) procedure (rtd? obj ) ⟹ boolean?
Equivalent to the record-type-descriptor? procedure of the R6RS.
(srfi 131) procedure (rtd-constructor (rtd rtd?) ) ⟹ procedure?
(srfi 131) procedure (rtd-constructor (rtd rtd?) (fieldspec vector?) ) ⟹ procedure?
(return fieldvalue ... ) ⟹ record?
rtd is a record-type descriptor, and fieldspecs is an optional vector of symbols.
If no fieldspecs argument is supplied, then rtd-constructor returns a procedure that expects one argument for each field of the record-type described by rtd and returns an instance of that record-type with its fields initialized to the corresponding arguments. Arguments that correspond to the fields of the record-type's parent (if any) come first.
If fieldspecs is supplied, then rtd-constructor returns a procedure that expects one argument for each element of fieldspecs and returns an instance of the record-type described by rtd with the named fields initialized to the corresponding arguments.
It is an error if some symbol occurs more than once in fieldspecs. Fields of a derived record-type shadow fields of the same name in its parent; the fieldspecs argument cannot be used to initialize a shadowed field.
(srfi 131) procedure (rtd-predicate (rtd rtd?) ) ⟹ procedure?
(return obj ) ⟹ boolean?
Equivalent to the record-predicate procedure of the R6RS.
(srfi 131) procedure (rtd-accessor (rtd rtd?) (field symbol?) ) ⟹ procedure?
(return (rec record?) ) ⟹ *
field is a symbol that names a field of the record-type described by the record-type descriptor rtd. Returns a unary procedure that accepts instances of rtd (or any record-type that inherits from rtd) and returns the current value of the named field.
Fields in derived record-types shadow fields of the same name in a parent record-type.
(srfi 131) procedure (rtd-mutator (rtd rtd?) (field symbol?) ) ⟹ procedure?
(return (rec record?) value ) ⟹ undefined
field is a symbol that names a field of the record-type described by the record-type descriptor rtd. Returns a binary procedure that accepts instances of rtd (or any record-type that inherits from rtd) and a new value to be stored into the named field, performs that side effect, and returns an unspecified value.
Fields in derived record-types shadow fields of the same name in a parent record-type.
library (srfi 131)
(srfi 131) procedure (record? obj ) ⟹ boolean?
Equivalent to its R6RS namesake.
(srfi 131) procedure (record-rtd (rec record?) ) ⟹ rtd?
Equivalent to its R6RS namesake.
(srfi 131) procedure (rtd-name (rtd rtd?) ) ⟹ symbol?
Equivalent to the record-type-name procedure of the R6RS.
(srfi 131) procedure (rtd-parent (rtd rtd?) ) ⟹ #f / rtd? /
Equivalent to the record-type-parent procedure of the R6RS.
(srfi 131) procedure (rtd-field-names (rtd rtd?) ) ⟹ vector?
Equivalent to the record-type-field-names procedure of the R6RS. (That is, it returns a vector of the symbols that name the fields of the record-type represented by rtd, excluding the fields of parent record-types.)
(srfi 131) procedure (rtd-all-field-names (rtd rtd?) ) ⟹ vector?
Returns a vector of the symbols that name the fields of the record-type represented by rtd, including the fields of its parent record-types, if any. The fields of parent record-types come before the fields of its children, with each subsequence in the same order as in the vectors that would be returned by calling rtd-field-names on rtd and on all its ancestral record-type descriptors.
(srfi 131) procedure (rtd-field-mutable? (rtd rtd?) (field symbol?) ) ⟹ boolean?
rtd is a record-type descriptor, and field is a symbol naming a field of the record-type described by rtd. Returns #t if the named field is mutable; otherwise returns #f.
library (srfi 131)
(srfi 131) syntax (define-record-type () ((_ type-spec constructor predicate field ...)) )
type-name (type-name parent)
#f constructor-name (constructor-name field-name ...)
#f predicate-name
field-name (field-name accessor-name) (field-name accessor-name modifier-name)
parent ⟹ rtd?
The semantics of a record type definition is the same as in R7RS-small (or SRFI 9, except that record types are generative). The record type definition macro-expands into a cluster of definitions that:
A record type definition extends R7RS-small with the following additional options:
When a constructor spec is of the form (<constructor name> <field name> ...):
These are not explicit in SRFI 99's syntactic layer section, but can be inferred from its description of the procedural layer.
library (srfi 131 records procedural)
(srfi 131 records procedural) procedure (make-rtd (name symbol?) (fieldspecs vector?) ) ⟹ rtd?
(srfi 131 records procedural) procedure (make-rtd (name symbol?) (fieldspecs vector?) (parent (or rtd?#f)) ) ⟹ rtd?
name is a symbol, which matters only to the rtd-name procedure of the inspection layer. fieldspecs is a vector of field specifiers, where each field specifier is one of
The optional parent is an rtd or #f. It is an error for any of the symbols in fieldspecs to name more than one of the fields specified by fieldspecs, but the field names in fieldspecs may shadow field names in the parent record-type.
Implementations may wish to extend this procedure to support the non-generative, sealed, and/or opaque features of the R6RS. The recommended way to support those features is to allow any combination of the following arguments to follow the optional parent argument:
The recommendation above is not binding on implementations of SRFI 99. There are other ways to realize sealed, opaque, or non-generative rtds.
Returns an R6RS-compatible record-type descriptor.
(srfi 131 records procedural) procedure (rtd? obj ) ⟹ boolean?
Equivalent to the record-type-descriptor? procedure of the R6RS.
(srfi 131 records procedural) procedure (rtd-constructor (rtd rtd?) ) ⟹ procedure?
(srfi 131 records procedural) procedure (rtd-constructor (rtd rtd?) (fieldspec vector?) ) ⟹ procedure?
(return fieldvalue ... ) ⟹ record?
rtd is a record-type descriptor, and fieldspecs is an optional vector of symbols.
If no fieldspecs argument is supplied, then rtd-constructor returns a procedure that expects one argument for each field of the record-type described by rtd and returns an instance of that record-type with its fields initialized to the corresponding arguments. Arguments that correspond to the fields of the record-type's parent (if any) come first.
If fieldspecs is supplied, then rtd-constructor returns a procedure that expects one argument for each element of fieldspecs and returns an instance of the record-type described by rtd with the named fields initialized to the corresponding arguments.
It is an error if some symbol occurs more than once in fieldspecs. Fields of a derived record-type shadow fields of the same name in its parent; the fieldspecs argument cannot be used to initialize a shadowed field.
(srfi 131 records procedural) procedure (rtd-predicate (rtd rtd?) ) ⟹ procedure?
(return obj ) ⟹ boolean?
Equivalent to the record-predicate procedure of the R6RS.
(srfi 131 records procedural) procedure (rtd-accessor (rtd rtd?) (field symbol?) ) ⟹ procedure?
(return (rec record?) ) ⟹ *
field is a symbol that names a field of the record-type described by the record-type descriptor rtd. Returns a unary procedure that accepts instances of rtd (or any record-type that inherits from rtd) and returns the current value of the named field.
Fields in derived record-types shadow fields of the same name in a parent record-type.
(srfi 131 records procedural) procedure (rtd-mutator (rtd rtd?) (field symbol?) ) ⟹ procedure?
(return (rec record?) value ) ⟹ undefined
field is a symbol that names a field of the record-type described by the record-type descriptor rtd. Returns a binary procedure that accepts instances of rtd (or any record-type that inherits from rtd) and a new value to be stored into the named field, performs that side effect, and returns an unspecified value.
Fields in derived record-types shadow fields of the same name in a parent record-type.
library (srfi 131 records inspection)
(srfi 131 records inspection) procedure (record? obj ) ⟹ boolean?
Equivalent to its R6RS namesake.
(srfi 131 records inspection) procedure (record-rtd (rec record?) ) ⟹ rtd?
Equivalent to its R6RS namesake.
(srfi 131 records inspection) procedure (rtd-name (rtd rtd?) ) ⟹ symbol?
Equivalent to the record-type-name procedure of the R6RS.
(srfi 131 records inspection) procedure (rtd-parent (rtd rtd?) ) ⟹ #f / rtd? /
Equivalent to the record-type-parent procedure of the R6RS.
(srfi 131 records inspection) procedure (rtd-field-names (rtd rtd?) ) ⟹ vector?
Equivalent to the record-type-field-names procedure of the R6RS. (That is, it returns a vector of the symbols that name the fields of the record-type represented by rtd, excluding the fields of parent record-types.)
(srfi 131 records inspection) procedure (rtd-all-field-names (rtd rtd?) ) ⟹ vector?
Returns a vector of the symbols that name the fields of the record-type represented by rtd, including the fields of its parent record-types, if any. The fields of parent record-types come before the fields of its children, with each subsequence in the same order as in the vectors that would be returned by calling rtd-field-names on rtd and on all its ancestral record-type descriptors.
(srfi 131 records inspection) procedure (rtd-field-mutable? (rtd rtd?) (field symbol?) ) ⟹ boolean?
rtd is a record-type descriptor, and field is a symbol naming a field of the record-type described by rtd. Returns #t if the named field is mutable; otherwise returns #f.
library (srfi 131 records syntactic)
(srfi 131 records syntactic) syntax (define-record-type () ((_ type-spec constructor predicate field ...)) )
type-name (type-name parent)
#f constructor-name (constructor-name field-name ...)
#f predicate-name
field-name (field-name accessor-name) (field-name accessor-name modifier-name)
parent ⟹ rtd?
The semantics of a record type definition is the same as in R7RS-small (or SRFI 9, except that record types are generative). The record type definition macro-expands into a cluster of definitions that:
A record type definition extends R7RS-small with the following additional options:
When a constructor spec is of the form (<constructor name> <field name> ...):
These are not explicit in SRFI 99's syntactic layer section, but can be inferred from its description of the procedural layer.
library (srfi 132)
(srfi 132) procedure (list-sorted? (< procedure?) (lis list?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sorted?, vector-sorted?) These procedures return true iff their input list or vector is in sorted order, as determined by <. Specifically, they return #f iff there is an adjacent pair ... X Y ... in the input list or vector such that Y < X in the sense of <. The optional start and end range arguments restrict vector-sorted? to examining the indicated subvector.
These procedures are equivalent to the SRFI 95 sorted? procedure when applied to lists or vectors respectively, except that they do not accept a key procedure.
(srfi 132) procedure (vector-sorted? (< procedure?) (v vector?) ) ⟹ boolean?
(srfi 132) procedure (vector-sorted? (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(srfi 132) procedure (vector-sorted? (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sorted?, vector-sorted?) These procedures return true iff their input list or vector is in sorted order, as determined by <. Specifically, they return #f iff there is an adjacent pair ... X Y ... in the input list or vector such that Y < X in the sense of <. The optional start and end range arguments restrict vector-sorted? to examining the indicated subvector.
These procedures are equivalent to the SRFI 95 sorted? procedure when applied to lists or vectors respectively, except that they do not accept a key procedure.
(srfi 132) procedure (list-sort (< procedure?) (lis list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sort, list-stable-sort) These procedures do not alter their inputs, but are allowed to return a value that shares a common tail with a list argument.
The list-stable-sort procedure is equivalent to the R6RS list-sort procedure. It is also equivalent to the SRFI 95 sort procedure when applied to lists, except that it does not accept a key procedure.
(srfi 132) procedure (list-stable-sort (< procedure?) (lis list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sort, list-stable-sort) These procedures do not alter their inputs, but are allowed to return a value that shares a common tail with a list argument.
The list-stable-sort procedure is equivalent to the R6RS list-sort procedure. It is also equivalent to the SRFI 95 sort procedure when applied to lists, except that it does not accept a key procedure.
(srfi 132) procedure (list-sort! (< procedure?) (lis list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sort!, list-stable-sort!) These procedures are linear update operators — they are allowed, but not required, to alter the cons cells of their arguments to produce their results. They return a sorted list containing the same elements as lis.
The list-stable-sort! procedure is equivalent to the SRFI 95 sort! procedure when applied to lists, except that it does not accept a key procedure.
(srfi 132) procedure (list-stable-sort! (< procedure?) (lis list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
(shared description for list-sort!, list-stable-sort!) These procedures are linear update operators — they are allowed, but not required, to alter the cons cells of their arguments to produce their results. They return a sorted list containing the same elements as lis.
The list-stable-sort! procedure is equivalent to the SRFI 95 sort! procedure when applied to lists, except that it does not accept a key procedure.
(srfi 132) procedure (vector-sort (< procedure?) (v vector?) ) ⟹ boolean?
(srfi 132) procedure (vector-sort (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(srfi 132) procedure (vector-sort (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for vector-sort, vector-stable-sort) These procedures do not alter their inputs, but allocate a fresh vector as their result, of length end - start. The vector-stable-sort procedure with no optional arguments is equivalent to the R6RS vector-sort procedure. It is also equivalent to the SRFI 95 sort procedure when applied to vectors, except that it does not accept a key procedure.
(srfi 132) procedure (vector-stable-sort (< procedure?) (v vector?) ) ⟹ boolean?
(srfi 132) procedure (vector-stable-sort (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(srfi 132) procedure (vector-stable-sort (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for vector-sort, vector-stable-sort) These procedures do not alter their inputs, but allocate a fresh vector as their result, of length end - start. The vector-stable-sort procedure with no optional arguments is equivalent to the R6RS vector-sort procedure. It is also equivalent to the SRFI 95 sort procedure when applied to vectors, except that it does not accept a key procedure.
(srfi 132) procedure (vector-sort! (< procedure?) (v vector?) ) ⟹ boolean?
(srfi 132) procedure (vector-sort! (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(srfi 132) procedure (vector-sort! (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for vector-sort!, vector-stable-sort!) These procedures sort their data in-place. (But note that vector-stable-sort! may allocate temporary storage proportional to the size of the input — there are no known O(n lg n) stable vector sorting algorithms that run in constant space.) They return an unspecified value.
The vector-sort! procedure with no optional arguments is equivalent to the R6RS vector-sort! procedure.
(srfi 132) procedure (vector-stable-sort! (< procedure?) (v vector?) ) ⟹ boolean?
(srfi 132) procedure (vector-stable-sort! (< procedure?) (v vector?) (start integer?) ) ⟹ boolean?
(srfi 132) procedure (vector-stable-sort! (< procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ boolean?
(< obj1 obj2 ) ⟹ boolean?
(shared description for vector-sort!, vector-stable-sort!) These procedures sort their data in-place. (But note that vector-stable-sort! may allocate temporary storage proportional to the size of the input — there are no known O(n lg n) stable vector sorting algorithms that run in constant space.) They return an unspecified value.
The vector-sort! procedure with no optional arguments is equivalent to the R6RS vector-sort! procedure.
(srfi 132) procedure (list-merge (< procedure?) (lis1 list?) (lis2 list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
This procedure does not alter its inputs, and is allowed to return a value that shares a common tail with a list argument.
This procedure is equivalent to the SRFI 95 merge procedure when applied to lists, except that it does not accept a key procedure.
(srfi 132) procedure (list-merge! (< procedure?) (lis1 list?) (lis2 list?) ) ⟹ list?
(< obj1 obj2 ) ⟹ boolean?
This procedure makes only a single, iterative, linear-time pass over its argument lists, using set-cdr!s to rearrange the cells of the lists into the list that is returned — it works "in place." Hence, any cons cell appearing in the result must have originally appeared in an input. It returns the sorted input.
Additionally, list-merge! is iterative, not recursive — it can operate on arguments of arbitrary size without requiring an unbounded amount of stack space. The intent of this iterative-algorithm commitment is to allow the programmer to be sure that if, for example, list-merge! is asked to merge two ten-million-element lists, the operation will complete without performing some extremely (possibly twenty-million) deep recursion.
This procedure is equivalent to the SRFI 95 merge! procedure when applied to lists, except that it does not accept a key procedure.
(srfi 132) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) ) ⟹ vector?
(srfi 132) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) ) ⟹ vector?
(srfi 132) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) ) ⟹ vector?
(srfi 132) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ vector?
(srfi 132) procedure (vector-merge (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ vector?
(< obj1 obj2 ) ⟹ boolean?
This procedure does not alter its inputs, and returns a newly allocated vector of length (end1 - start1) + (end2 - start2).
This procedure is equivalent to the SRFI 95 merge procedure when applied to vectors, except that it does not accept a key procedure.
(srfi 132) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) ) ⟹ vector?
(srfi 132) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) ) ⟹ vector?
(srfi 132) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) ) ⟹ vector?
(srfi 132) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ vector?
(srfi 132) procedure (vector-merge! (< procedure?) (v1 vector?) (v2 vector?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ vector?
(< obj1 obj2 ) ⟹ boolean?
This procedure writes its result into vector to, beginning at index start, for indices less than end, which is defined as start + (end1 - start1) + (end2 - start2). The target subvector to[start, end) may not overlap either of the source subvectors from1[start1, end1] and from2[start2, end2]. It returns an unspecified value.
This procedure is equivalent to the SRFI 95 merge! procedure when applied to lists, except that it does not accept a key procedure.
(srfi 132) procedure (list-delete-neighbor-dups (= procedure?) (lis list?) ) ⟹ list?
(= obj1 obj2 ) ⟹ boolean?
This procedure does not alter its input list, but its result may share storage with the input list.
(srfi 132) procedure (list-delete-neighbor-dups! (= procedure?) (lis list?) ) ⟹ list?
(= obj1 obj2 ) ⟹ boolean?
This procedure mutates its input list in order to construct its result. It makes only a single, iterative, linear-time pass over its argument, using set-cdr!s to rearrange the cells of the list into the final result — it works "in place." Hence, any cons cell appearing in the result must have originally appeared in the input.
(srfi 132) procedure (vector-delete-neighbor-dups (= procedure?) (v vector?) ) ⟹ vector?
(srfi 132) procedure (vector-delete-neighbor-dups (= procedure?) (v vector?) (start integer?) ) ⟹ vector?
(srfi 132) procedure (vector-delete-neighbor-dups (= procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ vector?
(= obj1 obj2 ) ⟹ boolean?
This procedure does not alter its input vector, but rather newly allocates and returns a vector to hold the result.
(srfi 132) procedure (vector-delete-neighbor-dups! (= procedure?) (v vector?) ) ⟹ vector?
(srfi 132) procedure (vector-delete-neighbor-dups! (= procedure?) (v vector?) (start integer?) ) ⟹ vector?
(srfi 132) procedure (vector-delete-neighbor-dups! (= procedure?) (v vector?) (start integer?) (end integer?) ) ⟹ vector?
(= obj1 obj2 ) ⟹ boolean?
This procedure reuses its input vector to hold the answer, packing it into the index range [start, newend), where newend is the non-negative exact integer that is returned as its value. The vector is not altered outside the range [start, newend).
(srfi 132) procedure (vector-find-median (< procedure?) (v vector?) knil ) ⟹ *
(srfi 132) procedure (vector-find-median (< procedure?) (v vector?) knil (mean procedure?) ) ⟹ *
(< obj1 obj2 ) ⟹ boolean?
(mean obj1 obj2 ) ⟹ *
This procedure does not alter its input vector, but rather newly allocates a vector to hold the intermediate result. Runs in O(n) time.
(srfi 132) procedure (vector-find-median! (< procedure?) (v vector?) knil ) ⟹ *
(srfi 132) procedure (vector-find-median! (< procedure?) (v vector?) knil (mean procedure?) ) ⟹ *
(< obj1 obj2 ) ⟹ boolean?
(mean obj1 obj2 ) ⟹ *
This procedure reuses its input vector to hold the intermediate result, leaving it sorted, but is otherwise the same as vector-find-median. Runs in O(n ln n) time.
(srfi 132) procedure (vector-select! (< procedure?) (v vector?) (k integer?) ) ⟹ *
(srfi 132) procedure (vector-select! (< procedure?) (v vector?) (k integer?) (start integer?) ) ⟹ *
(srfi 132) procedure (vector-select! (< procedure?) (v vector?) (k integer?) (start integer?) (end integer?) ) ⟹ *
(< obj1 obj2 ) ⟹ boolean?
This procedure returns the kth smallest element (in the sense of the < argument) of the region of a vector between start and end. Elements within the range may be reordered, whereas those outside the range are left alone. Runs in O(n) time.
(srfi 132) procedure (vector-separate! (< procedure?) (v vector?) (k integer?) ) ⟹ undefined
(srfi 132) procedure (vector-separate! (< procedure?) (v vector?) (k integer?) (start integer?) ) ⟹ undefined
(srfi 132) procedure (vector-separate! (< procedure?) (v vector?) (k integer?) (start integer?) (end integer?) ) ⟹ undefined
(< obj1 obj2 ) ⟹ boolean?
This procedure places the smallest k elements (in the sense of the < argument) of the region of a vector between start and end into the first k positions of that range, and the remaining elements into the remaining positions. Otherwise, the elements are not in any particular order. Elements outside the range are left alone. Runs in O(n) time. Returns an unspecified value.
library (srfi 133)
(srfi 133) procedure (make-vector (k integer?) ) ⟹ vector?
(srfi 133) procedure (make-vector (k integer?) fill ) ⟹ vector?
Creates and returns a vector of size size. If fill is specified, all the elements of the vector are initialized to fill. Otherwise, their contents are indeterminate.
(srfi 133) procedure (vector obj ... ) ⟹ vector?
Creates and returns a vector whose elements are x ....
(srfi 133) procedure (vector-unfold (f procedure?) (length integer?) initial-seed ... ) ⟹ vector?
(f (index integer?) seed ... ) ⟹ (values **...)
The fundamental vector constructor. Creates a vector whose length is length and iterates across each index k between 0 and length, applying f at each iteration to the current index and current seeds, in that order, to receive n + 1 values: first, the element to put in the kth slot of the new vector and n new seeds for the next iteration. It is an error for the number of seeds to vary between iterations. Note that the termination condition is different from the unfold procedure of SRFI 1.
(srfi 133) procedure (vector-unfold-right (f procedure?) (length integer?) initial-seed ... ) ⟹ vector?
(f (index integer?) seed ... ) ⟹ (values **...)
Like vector-unfold, but it uses f to generate elements from right-to-left, rather than left-to-right. The first index used is length - 1. Note that the termination condition is different from the unfold-right procedure of SRFI 1.
(srfi 133) procedure (vector-copy (vector vector?) ) ⟹ vector?
(srfi 133) procedure (vector-copy (vector vector?) (start integer?) ) ⟹ vector?
(srfi 133) procedure (vector-copy (vector vector?) (start integer?) (end integer?) ) ⟹ vector?
Allocates a new vector whose length is end - start and fills it with elements from vec, taking elements from vec starting at index start and stopping at index end. Start defaults to 0 and end defaults to the value of (vector-length vec). SRFI 43 provides an optional fill argument to supply values if end is greater than the length of vec. Neither R7RS-small nor this SRFI requires support for this argument.
(srfi 133) procedure (vector-reverse-copy (vector vector?) ) ⟹ vector?
(srfi 133) procedure (vector-reverse-copy (vector vector?) (start integer?) ) ⟹ vector?
(srfi 133) procedure (vector-reverse-copy (vector vector?) (start integer?) (end integer?) ) ⟹ vector?
Like vector-copy, but it copies the elements in the reverse order from vec.
(srfi 133) procedure (vector-append (vector vector?) ... ) ⟹ vector?
Returns a newly allocated vector that contains all elements in order from the subsequent locations in vec ....
(srfi 133) procedure (vector-concatenate (list-of-vectors list?) ... ) ⟹ vector?
list-of-vectors ⟹ (list (vec vector?) )
Appends each vector in list-of-vectors.
(srfi 133) procedure (vector-append-subvectors (vec1 vector?) (start1 integer?) (end1 integer?) ... ) ⟹ vector?
Returns a vector that contains every element of each vec from start to end in the specified order. This procedure is a generalization of vector-append.
(srfi 133) procedure (vector? obj ) ⟹ boolean?
Disjoint type predicate for vectors: this returns #t if x is a vector, and #f if otherwise.
(srfi 133) procedure (vector-empty? (vec vector?) ) ⟹ boolean?
Returns #t if vec is empty, i.e. its length is 0, and #f if not.
(srfi 133) procedure (vector= (elt=? procedure?) (vec vector?) ... ) ⟹ boolean?
(elt=? a b ) ⟹ boolean?
Vector structure comparator, generalized across user-specified element comparators. Vectors a and b are considered equal by vector= iff their lengths are the same, and for each respective element Ea and Eb, (elt=? Ea Eb) returns a true value. Elt=? is always applied to two arguments.
If there are only zero or one vector arguments, #t is automatically returned. The dynamic order in which comparisons of elements and of vectors are performed is left completely unspecified; do not rely on a particular order.
(srfi 133) procedure (vector-ref (vector vector?) (k integer?) ) ⟹ *
Vector element dereferencing: returns the value that the location in vec at i is mapped to in the store. Indexing is based on zero. I must be within the range [0, (vector-length vec)).
(srfi 133) procedure (vector-length (vector vector?) ) ⟹ integer?
Returns the length of vec, the number of locations reachable from vec. (The careful word 'reachable' is used to allow for 'vector slices,' whereby vec refers to a larger vector that contains more locations that are unreachable from vec. This SRFI does not define vector slices, but later SRFIs may.)
(srfi 133) procedure (vector-fold (kons procedure?) knil (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(kons state obj1 obj2 ... ) ⟹ *
The fundamental vector iterator. Kons is iterated over each value in all of the vectors, stopping at the end of the shortest; kons is applied as (kons state (vector-ref vec1 i) (vector-ref vec2 i) ...) where state is the current state value — the current state value begins with knil, and becomes whatever kons returned on the previous iteration —, and i is the current index.
The iteration is strictly left-to-right.
(srfi 133) procedure (vector-fold-right (kons procedure?) knil (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(kons state obj1 obj2 ... ) ⟹ *
Similar to vector-fold, but it iterates right to left instead of left to right.
(srfi 133) procedure (vector-map (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ vector?
(proc obj ... ) ⟹ *
Constructs a new vector of the shortest size of the vector arguments. Each element at index i of the new vector is mapped from the old vectors by (f (vector-ref vec1 i) (vector-ref vec2 i) ...). The dynamic order of application of f is unspecified.
(srfi 133) procedure (vector-map! (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ undefined
(proc obj ... ) ⟹ *
Similar to vector-map, but rather than mapping the new elements into a new vector, the new mapped elements are destructively inserted into vec1. Again, the dynamic order of application of f unspecified, so it is dangerous for f to apply either vector-ref or vector-set! to vec1 in f.
(srfi 133) procedure (vector-for-each (proc procedure?) (vector1 vector?) (vector2 vector?) ... ) ⟹ undefined
(proc obj ... ) ⟹ undefined
Simple vector iterator: applies f to the corresponding list of parallel elements from vec1 vec2 ... in the range [0, length), where length is the length of the smallest vector argument passed, In contrast with vector-map, f is reliably applied to each subsequent element, starting at index 0, in the vectors.
(srfi 133) procedure (vector-count (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer?
(pred? obj1 obj2 ... ) ⟹ *
Counts the number of parallel elements in the vectors that satisfy pred?, which is applied, for each index i in the range [0, length) where length is the length of the smallest vector argument, to each parallel element in the vectors, in order.
(srfi 133) procedure (vector-cumulate (f procedure?) knil (vec vector?) ) ⟹ vector?
(f obj1 obj2 ) ⟹ *
Returns a newly allocated vector new with the same length as vec. Each element i of new is set to the result of invoking f on newi-1 and veci, except that for the first call on f, the first argument is knil. The new vector is returned.
Note that the order of arguments to vector-cumulate was changed by errata-3 on 2016-09-02.
(srfi 133) procedure (vector-index (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Finds & returns the index of the first elements in vec1 vec2 ... that satisfy pred?. If no matching element is found by the end of the shortest vector, #f is returned.
(srfi 133) procedure (vector-index-right (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Like vector-index, but it searches right-to-left, rather than left-to-right, and all of the vectors must have the same length.
(srfi 133) procedure (vector-skip (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Finds & returns the index of the first elements in vec1 vec2 ... that do not satisfy pred?. If all the values in the vectors satisfy pred? until the end of the shortest vector, this returns #f.
(srfi 133) procedure (vector-skip-right (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ integer? / #f /
(pred? obj1 obj2 ... ) ⟹ *
Like vector-skip, but it searches for a non-matching element right-to-left, rather than left-to-right, and it is an error if all of the vectors do not have the same length.
(srfi 133) procedure (vector-binary-search (vec vector?) value (cmp procedure?) ) ⟹ integer? / #f /
(cmp a b ) ⟹ integer?
Similar to vector-index and vector-index-right, but instead of searching left to right or right to left, this performs a binary search. If there is more than one element of vec that matches value in the sense of cmp, vector-binary-search may return the index of any of them.
cmp should be a procedure of two arguments and return a negative integer, which indicates that its first argument is less than its second, zero, which indicates that they are equal, or a positive integer, which indicates that the first argument is greater than the second argument.
(srfi 133) procedure (vector-any (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(pred? obj1 obj2 ... ) ⟹ *
Finds the first set of elements in parallel from vec1 vec2 ... for which pred? returns a true value. If such a parallel set of elements exists, vector-any returns the value that pred? returned for that set of elements. The iteration is strictly left-to-right.
(srfi 133) procedure (vector-every (pred? procedure?) (vec1 vector?) (vec2 vector?) ... ) ⟹ *
(pred? obj1 obj2 ... ) ⟹ *
If, for every index i between 0 and the length of the shortest vector argument, the set of elements (vector-ref vec1 i) (vector-ref vec2 i) ... satisfies pred?, vector-every returns the value that pred? returned for the last set of elements, at the last index of the shortest vector. The iteration is strictly left-to-right.
(srfi 133) procedure (vector-partition (pred? procedure?) (vec vector?) ) ⟹ (values vector?integer?)
(pred? obj ) ⟹ boolean?
A vector the same size as vec is newly allocated and filled with all the elements of vec that satisfy pred? in their original order followed by all the elements that do not satisfy pred?, also in their original order.
Two values are returned, the newly allocated vector and the index of the leftmost element that does not satisfy pred?.
(srfi 133) procedure (vector-set! (vector vector?) (k integer?) obj ) ⟹ undefined
Assigns the contents of the location at i in vec to value.
(srfi 133) procedure (vector-swap! (vector vector?) (i integer?) (j integer?) ) ⟹ undefined
Swaps or exchanges the values of the locations in vec at i & j.
(srfi 133) procedure (vector-fill! (vector vector?) fill ) ⟹ undefined
(srfi 133) procedure (vector-fill! (vector vector?) fill (start integer?) ) ⟹ undefined
(srfi 133) procedure (vector-fill! (vector vector?) fill (start integer?) (end integer?) ) ⟹ undefined
Assigns the value of every location in vec between start, which defaults to 0 and end, which defaults to the length of vec, to fill.
(srfi 133) procedure (vector-reverse! (vector vector?) ) ⟹ undefined
(srfi 133) procedure (vector-reverse! (vector vector?) (start integer?) ) ⟹ undefined
(srfi 133) procedure (vector-reverse! (vector vector?) (start integer?) (end integer?) ) ⟹ undefined
Destructively reverses the contents of the sequence of locations in vec between start and end. Start defaults to 0 and end defaults to the length of vec. Note that this does not deeply reverse.
(srfi 133) procedure (vector-copy! (to vector?) (at integer?) (from vector?) ) ⟹ undefined
(srfi 133) procedure (vector-copy! (to vector?) (at integer?) (from vector?) (start integer?) ) ⟹ undefined
(srfi 133) procedure (vector-copy! (to vector?) (at integer?) (from vector?) (start integer?) (end integer?) ) ⟹ undefined
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.
(srfi 133) procedure (vector-reverse-copy! (to vector?) (at integer?) (from vector?) ) ⟹ undefined
(srfi 133) procedure (vector-reverse-copy! (to vector?) (at integer?) (from vector?) (start integer?) ) ⟹ undefined
(srfi 133) procedure (vector-reverse-copy! (to vector?) (at integer?) (from vector?) (start integer?) (end integer?) ) ⟹ undefined
Like vector-copy!, but the elements appear in to in reverse order.
(srfi 133) procedure (vector-unfold! (f procedure?) (vec vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like vector-unfold, but the elements are copied into the vector vec starting at element start rather than into a newly allocated vector. Terminates when end-start elements have been generated.
(srfi 133) procedure (vector-unfold-right! (f procedure?) (vec vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like vector-unfold!, but the elements are copied in reverse order into the vector vec starting at the index preceding end.
(srfi 133) procedure (vector->list (vector vector?) ) ⟹ list?
(srfi 133) procedure (vector->list (vector vector?) (start integer?) ) ⟹ list?
(srfi 133) procedure (vector->list (vector vector?) (start integer?) (end integer?) ) ⟹ list?
Creates a list containing the elements in vec between start, which defaults to 0, and end, which defaults to the length of vec.
(srfi 133) procedure (reverse-vector->list (vector vector?) ) ⟹ list?
(srfi 133) procedure (reverse-vector->list (vector vector?) (start integer?) ) ⟹ list?
(srfi 133) procedure (reverse-vector->list (vector vector?) (start integer?) (end integer?) ) ⟹ list?
Like vector->list, but the resulting list contains the elements in reverse of vec.
(srfi 133) procedure (list->vector (list list?) ) ⟹ vector?
Creates a vector of elements from proper-list.
(srfi 133) procedure (reverse-list->vector (list list?) ) ⟹ vector?
Like list->vector, but the resulting vector contains the elements in reverse of proper-list.
(srfi 133) procedure (string->vector (string string?) ) ⟹ vector?
(srfi 133) procedure (string->vector (string string?) (start integer?) ) ⟹ vector?
(srfi 133) procedure (string->vector (string string?) (start integer?) (end integer?) ) ⟹ vector?
Creates a vector containing the elements in string between start, which defaults to 0, and end, which defaults to the length of string.
(srfi 133) procedure (vector->string (vector vector?) ) ⟹ string?
(srfi 133) procedure (vector->string (vector vector?) (start integer?) ) ⟹ string?
(srfi 133) procedure (vector->string (vector vector?) (start integer?) (end integer?) ) ⟹ string?
Creates a string containing the elements in vec between start, which defaults to 0, and end, which defaults to the length of vec. It is an error if the elements are not characters.
library (srfi 134)
(srfi 134) procedure (ideque element ... ) ⟹ ideque?
Returns an ideque containing the elements. The first element (if any) will be at the front of the ideque and the last element (if any) will be at the back. Takes O(n) time, where n is the number of elements.
(srfi 134) procedure (ideque-tabulate (n integer?) (proc procedure?) ) ⟹ ideque?
(proc (k integer?) ) ⟹ *
Invokes the predicate proc on every exact integer from 0 (inclusive) to n (exclusive). Returns an ideque containing the results in order of generation. Takes O(n) time.
(srfi 134) procedure (ideque-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ ideque?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Invokes the predicate stop? on seed. If it returns false, generate the next result by applying mapper to seed, generate the next seed by applying successor to seed, and repeat this algorithm with the new seed. If stop? returns true, return an ideque containing the results in order of accumulation. Takes O(n) time.
(srfi 134) procedure (ideque-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ ideque?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Invokes the predicate stop? on seed. If it returns false, generate the next result by applying mapper to seed, generate the next seed by applying successor to seed, and repeat the algorithm with the new seed. If stop? returns true, return an ideque containing the results in reverse order of accumulation. Takes O(n) time.
(srfi 134) procedure (ideque? x ) ⟹ boolean?
Returns #t if x is an ideque, and #f otherwise. Takes O(1) time.
(srfi 134) procedure (ideque-empty? (ideque ideque?) ) ⟹ boolean?
Returns #t if ideque contains zero elements, and #f otherwise. Takes O(1) time.
(srfi 134) procedure (ideque= (elt= procedure?) (ideque ideque?) ... ) ⟹ boolean?
(elt= a b ) ⟹ boolean?
Determines ideque equality, given an element-equality procedure. Ideque A equals ideque B if they are of the same length, and their corresponding elements are equal, as determined by elt=. If the element-comparison procedure's first argument is from idequei, then its second argument is from idequei+1, i.e. it is always called as (elt= a b) for a an element of ideque A, and b an element of ideque B.
In the n-ary case, every idequei is compared to idequei+1 (as opposed, for example, to comparing ideque1 to every idequei, for i > 1). If there are zero or one ideque arguments, ideque= simply returns true. The name does not end in a question mark for compatibility with the SRFI-1 procedure list=.
Note that the dynamic order in which the elt= procedure is applied to pairs of elements is not specified. For example, if ideque= is applied to three ideques, A, B, and C, it may first completely compare A to B, then compare B to C, or it may compare the first elements of A and B, then the first elements of B and C, then the second elements of A and B, and so forth.
The equality procedure must be consistent with eq?. Note that this implies that two ideques which are eq? are always ideque=, as well; implementations may exploit this fact to "short-cut" the element-by-element comparisons.
(srfi 134) procedure (ideque-any (pred procedure?) (ideque ideque?) ) ⟹ *
(pred element ) ⟹ *
Invokes pred on the elements of the ideque in order until one call returns a true value, which is then returned. If there are no elements, returns #f. Takes O(n) time.
(srfi 134) procedure (ideque-every (pred procedure?) (ideque ideque?) ) ⟹ *
(pred element ) ⟹ *
Invokes pred on the elements of the ideque in order until one call returns a false value, which is then returned. If there are no elements, returns #t. Takes O(n) time.
(srfi 134) procedure (ideque-front (ideque ideque?) ) ⟹ *
Returns the front element of ideque. It is an error for ideque to be empty. Takes O(1) time.
(srfi 134) procedure (ideque-back (ideque ideque?) ) ⟹ *
Returns the back element of ideque. It is an error for ideque to be empty. Takes O(1) time.
(srfi 134) procedure (ideque-remove-front (ideque ideque?) ) ⟹ ideque?
Returns an ideque with the front element of ideque removed. It is an error for ideque to be empty. Takes O(1) time.
(srfi 134) procedure (ideque-remove-back (ideque ideque?) ) ⟹ ideque?
Returns an ideque with the back element of ideque removed. It is an error for ideque to be empty. Takes O(1) time.
(srfi 134) procedure (ideque-add-front (ideque ideque?) obj ) ⟹ ideque?
Returns an ideque with obj pushed to the front of ideque. Takes O(1) time.
(srfi 134) procedure (ideque-add-back (ideque ideque?) obj ) ⟹ ideque?
Returns an ideque with obj pushed to the back of ideque. Takes O(1) time.
(srfi 134) procedure (ideque-ref (ideque ideque?) (n integer?) ) ⟹ *
Returns the nth element of ideque. It is an error unless n is less than the length of ideque. Takes O(n) time.
(srfi 134) procedure (ideque-take (ideque ideque?) (n integer?) ) ⟹ ideque?
Returns an ideque containing the first n elements of ideque. It is an error if n is greater than the length of ideque. Takes O(n) time.
(srfi 134) procedure (ideque-take-right (ideque ideque?) (n integer?) ) ⟹ ideque?
Returns an ideque containing the last n elements of ideque. It is an error if n is greater than the length of ideque. Takes O(n) time.
(srfi 134) procedure (ideque-drop (ideque ideque?) (n integer?) ) ⟹ ideque?
Returns an ideque containing all but the first n elements of ideque. It is an error if n is greater than the length of ideque. Takes O(n) time.
(srfi 134) procedure (ideque-drop-right (ideque ideque?) (n integer?) ) ⟹ ideque?
Returns an ideque containing all but the last n elements of ideque. It is an error if n is greater than the length of ideque. Takes O(n) time.
(srfi 134) procedure (ideque-split-at (ideque ideque?) (n integer?) ) ⟹ (values ideque?ideque?)
Returns two values, the results of (ideque-take ideque n) and (ideque-drop ideque n) respectively, but may be more efficient. Takes O(n) time.
(srfi 134) procedure (ideque-length (ideque ideque?) ) ⟹ integer?
Returns the length of ideque as an exact integer. May take O(n) time, though O(1) is optimal.
(srfi 134) procedure (ideque-append (ideque ideque?) ... ) ⟹ ideque?
Returns an ideque with the contents of the ideque followed by the others, or an empty ideque if there are none. Takes O(kn) time, where k is the number of ideques and n is the number of elements involved, though O(k log n) is possible.
(srfi 134) procedure (ideque-reverse (ideque ideque?) ) ⟹ ideque?
Returns an ideque containing the elements of ideque in reverse order. Takes O(1) time.
(srfi 134) procedure (ideque-count (pred procedure?) (ideque ideque?) ) ⟹ integer?
(pred element ) ⟹ boolean?
Pred is a procedure taking a single value and returning a single value. It is applied element-wise to the elements of ideque, and a count is tallied of the number of elements that produce a true value. This count is returned. Takes O(n) time. The dynamic order of calls to pred is unspecified.
(srfi 134) procedure (ideque-zip (ideque1 ideque?) (ideque2 ideque?) ... ) ⟹ ideque?
Returns an ideque of lists (not ideques) each of which contains the corresponding elements of ideques in the order specified. Terminates when all the elements of any of the ideques have been processed. Takes O(kn) time, where k is the number of ideques and n is the number of elements in the shortest ideque.
(srfi 134) procedure (ideque-map (proc procedure?) (ideque ideque?) ) ⟹ ideque?
(proc element ) ⟹ *
Applies proc to the elements of ideque and returns an ideque containing the results in order. The dynamic order of calls to proc is unspecified. Takes O(n) time.
(srfi 134) procedure (ideque-filter-map (proc procedure?) (ideque ideque?) ) ⟹ ideque?
(proc element ) ⟹ *
Applies proc to the elements of ideque and returns an ideque containing the true (i.e. non-#f) results in order. The dynamic order of calls to proc is unspecified. Takes O(n) time.
(srfi 134) procedure (ideque-for-each (proc procedure?) (ideque ideque?) ) ⟹ undefined
(proc element ) ⟹ undefined
Applies proc to the elements of ideque in forward order and returns an unspecified result. Takes O(n) time.
(srfi 134) procedure (ideque-for-each-right (proc procedure?) (ideque ideque?) ) ⟹ undefined
(proc element ) ⟹ undefined
Applies proc to the elements of ideque in reverse order and returns an unspecified result. Takes O(n) time.
(srfi 134) procedure (ideque-fold (proc procedure?) nil (ideque ideque?) ) ⟹ *
(proc element state ) ⟹ *
Invokes proc on the elements of ideque in forward order, passing the result of the previous invocation as a second argument. For the first invocation, nil is used as the second argument. Returns the result of the last invocation, or nil if there was no invocation. Takes O(n) time.
(srfi 134) procedure (ideque-fold-right (proc procedure?) nil (ideque ideque?) ) ⟹ *
(proc element state ) ⟹ *
Invokes proc on the elements of ideque in reverse order, passing the result of the previous invocation as a second argument. For the first invocation, nil is used as the second argument. Returns the result of the last invocation, or nil if there was no invocation. Takes O(n) time.
(srfi 134) procedure (ideque-append-map (proc procedure?) (ideque ideque?) ) ⟹ ideque?
(proc element ) ⟹ list?
Applies proc to the elements of ideque. It is an error if the result is not a list. Returns an ideque containing the elements of the lists in order. Takes O(n) time, where n is the number of elements in all the lists returned.
(srfi 134) procedure (ideque-filter (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque containing the elements of ideque that do satisfy pred. Takes O(n) time.
(srfi 134) procedure (ideque-remove (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque containing the elements of ideque that do not satisfy pred. Takes O(n) time.
(srfi 134) procedure (ideque-partition (pred procedure?) (ideque ideque?) ) ⟹ (values ideque?ideque?)
(pred element ) ⟹ boolean?
Returns two values, the results of (ideque-filter pred ideque) and (ideque-remove pred ideque) respectively, but may be more efficient. Takes O(n) time.
(srfi 134) procedure (ideque-find (pred procedure?) (ideque ideque?) ) ⟹ *
(srfi 134) procedure (ideque-find (pred procedure?) (ideque ideque?) (failure procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(failure ) ⟹ *
Returns the first element of ideque that satisfies pred. If there is no such element, returns the result of invoking the thunk failure; the default thunk is (lambda () #f). Takes O(n) time.
(srfi 134) procedure (ideque-find-right (pred procedure?) (ideque ideque?) ) ⟹ *
(srfi 134) procedure (ideque-find-right (pred procedure?) (ideque ideque?) (failure procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(failure ) ⟹ *
Returns the last element of ideque that satisfies pred. If there is no such element, returns the result of invoking the thunk failure; the default thunk is (lambda () #f). Takes O(n) time.
(srfi 134) procedure (ideque-take-while (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque containing the longest initial prefix of elements in ideque all of which satisfy pred. Takes O(n) time.
(srfi 134) procedure (ideque-take-while-right (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque containing the longest final prefix of elements in ideque all of which satisfy pred. Takes O(n) time.
(srfi 134) procedure (ideque-drop-while (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque which omits the longest initial prefix of elements in ideque all of which satisfy pred, but includes all other elements of ideque. Takes O(n) time.
(srfi 134) procedure (ideque-drop-while-right (pred procedure?) (ideque ideque?) ) ⟹ ideque?
(pred element ) ⟹ boolean?
Returns an ideque which omits the longest final prefix of elements in ideque all of which satisfy pred, but includes all other elements of ideque. Takes O(n) time.
(srfi 134) procedure (ideque-span (pred procedure?) (ideque ideque?) ) ⟹ (values ideque?ideque?)
(pred element ) ⟹ boolean?
Returns two values, the initial prefix of the elements of ideque which do satisfy pred, and the remaining elements. Takes O(n) time.
(srfi 134) procedure (ideque-break (pred procedure?) (ideque ideque?) ) ⟹ (values ideque?ideque?)
(pred element ) ⟹ boolean?
Returns two values, the initial prefix of the elements of ideque which do not satisfy pred, and the remaining elements. Takes O(n) time.
(srfi 134) procedure (list->ideque (list list?) ) ⟹ ideque?
(shared description for list->ideque, ideque->list) Conversion between ideque and list structures. FIFO order is preserved, so the front of a list corresponds to the front of an ideque. Each operation takes O(n) time.
(srfi 134) procedure (ideque->list (ideque ideque?) ) ⟹ list?
(shared description for list->ideque, ideque->list) Conversion between ideque and list structures. FIFO order is preserved, so the front of a list corresponds to the front of an ideque. Each operation takes O(n) time.
(srfi 134) procedure (generator->ideque (generator procedure?) ) ⟹ ideque?
(generator ) ⟹ *
(shared description for generator->ideque, ideque->generator) Conversion between SRFI 121 generators and ideques. Each operation takes O(n) time. A generator is a procedure that is called repeatedly with no arguments to generate consecutive values, and returns an end-of-file object when it has no more values to return.
(srfi 134) procedure (ideque->generator (ideque ideque?) ) ⟹ procedure?
(return ) ⟹ *
(shared description for generator->ideque, ideque->generator) Conversion between SRFI 121 generators and ideques. Each operation takes O(n) time. A generator is a procedure that is called repeatedly with no arguments to generate consecutive values, and returns an end-of-file object when it has no more values to return.
library (srfi 135)
(srfi 135) procedure (text? obj ) ⟹ boolean?
Is obj an immutable text? In particular, (text? obj) returns false if (string? obj) returns true, which implies string? returns false if text? returns true. Must execute in O(1) time.
(srfi 135) procedure (textual? obj ) ⟹ boolean?
Returns true if and only if obj is an immutable text or a string. Must execute in O(1) time.
(srfi 135) procedure (textual-null? (textual textual?) ) ⟹ boolean?
Is textual the empty text or the empty string? Must execute in O(1) time.
(srfi 135) procedure (textual-every (pred procedure?) (textual textual?) ) ⟹ *
(srfi 135) procedure (textual-every (pred procedure?) (textual textual?) (start integer?) ) ⟹ *
(srfi 135) procedure (textual-every (pred procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ *
(pred (char char?) ) ⟹ *
(srfi 135) procedure (textual-any (pred procedure?) (textual textual?) ) ⟹ *
(srfi 135) procedure (textual-any (pred procedure?) (textual textual?) (start integer?) ) ⟹ *
(srfi 135) procedure (textual-any (pred procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ *
(pred (char char?) ) ⟹ *
Checks to see if every/any character in textual satisfies pred, proceeding from left (index start) to right (index end). textual-every These procedures are short-circuiting: if pred returns false, textual-every does not call pred on subsequent characters; if pred returns true, textual-any does not call pred on subsequent characters; Both procedures are "witness-generating":
Note: The names of these procedures do not end with a question mark. This indicates a general value is returned instead of a simple boolean (#t or #f).
(srfi 135) procedure (make-text (len integer?) (char char?) ) ⟹ text?
Returns a text of the given length filled with the given character.
(srfi 135) procedure (text (char char?) ... ) ⟹ text?
Returns a text consisting of the given characters.
(srfi 135) procedure (text-tabulate (proc procedure?) (len integer?) ) ⟹ text?
(proc (k integer?) ) ⟹ char?
Proc is a procedure that accepts an exact integer as its argument and returns a character. Constructs a text of size len by calling proc on each value from 0 (inclusive) to len (exclusive) to produce the corresponding element of the text. The order in which proc is called on those indexes is not specified.
(srfi 135) procedure (text-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ text?
(srfi 135) procedure (text-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base textual?) ) ⟹ text?
(srfi 135) procedure (text-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base textual?) (make-final procedure?) ) ⟹ text?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char? / string? / text? /
(success seed ) ⟹ *
(make-final seed ) ⟹ char? / string? / text? /
This is a fundamental constructor for texts.
text-unfold is a fairly powerful text constructor. You can use it to convert a list to a text, read a port into a text, reverse a text, copy a text, and so forth.
(srfi 135) procedure (text-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ text?
(srfi 135) procedure (text-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base textual?) ) ⟹ text?
(srfi 135) procedure (text-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base textual?) (make-final procedure?) ) ⟹ text?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char? / string? / text? /
(success seed ) ⟹ *
(make-final seed ) ⟹ char? / string? / text? /
This is a fundamental constructor for texts. It is the same as text-unfold except the results of mapper are assembled into the text in right-to-left order, base is the optional rightmost portion of the constructed text, and make-final produces the leftmost portion of the constructed text.
(srfi 135) procedure (textual->text (textual textual?) ) ⟹ text?
When given a text, textual->text just returns that text. When given a string, textual->text returns the result of calling string->text on that string. Signals an error when its argument is neither string nor text.
(srfi 135) procedure (textual->string (textual textual?) ) ⟹ string?
(srfi 135) procedure (textual->string (textual textual?) (start integer?) ) ⟹ string?
(srfi 135) procedure (textual->string (textual textual?) (start integer?) (end integer?) ) ⟹ string?
(srfi 135) procedure (textual->vector (textual textual?) ) ⟹ vector?
(srfi 135) procedure (textual->vector (textual textual?) (start integer?) ) ⟹ vector?
(srfi 135) procedure (textual->vector (textual textual?) (start integer?) (end integer?) ) ⟹ vector?
return ⟹ (vector (c char?) )
(srfi 135) procedure (textual->list (textual textual?) ) ⟹ list?
(srfi 135) procedure (textual->list (textual textual?) (start integer?) ) ⟹ list?
(srfi 135) procedure (textual->list (textual textual?) (start integer?) (end integer?) ) ⟹ list?
return ⟹ (list (c char?) )
textual->string, textual->vector, and textual->list return a newly allocated (unless empty) mutable string, vector, or list of the characters that make up the given subtext or substring.
(srfi 135) procedure (string->text (string string?) ) ⟹ text?
(srfi 135) procedure (string->text (string string?) (start integer?) ) ⟹ text?
(srfi 135) procedure (string->text (string string?) (start integer?) (end integer?) ) ⟹ text?
(srfi 135) procedure (vector->text (vector vector?) ) ⟹ text?
(srfi 135) procedure (vector->text (vector vector?) (start integer?) ) ⟹ text?
(srfi 135) procedure (vector->text (vector vector?) (start integer?) (end integer?) ) ⟹ text?
vector ⟹ (vector (c char?) )
(srfi 135) procedure (list->text (list list?) ) ⟹ text?
(srfi 135) procedure (list->text (list list?) (start integer?) ) ⟹ text?
(srfi 135) procedure (list->text (list list?) (start integer?) (end integer?) ) ⟹ text?
list ⟹ (list (c char?) )
These procedures return a text containing the characters of the given substring, subvector, or sublist. The behavior of the text will not be affected by subsequent mutation of the given string, vector, or list.
(srfi 135) procedure (reverse-list->text (char-list list?) ) ⟹ text?
char-list ⟹ (list (c char?) )
An efficient implementation of (compose list->text reverse):
(reverse-list->text '(#\a #\B #\c)) → "cBa"
This is a common idiom in the epilogue of text-processing loops that accumulate their result using a list in reverse order. (See also textual-concatenate-reverse for the "chunked" variant.)
(srfi 135) procedure (textual->utf8 (textual textual?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf8 (textual textual?) (start integer?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf8 (textual textual?) (start integer?) (end integer?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf16 (textual textual?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf16 (textual textual?) (start integer?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf16 (textual textual?) (start integer?) (end integer?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf16be (textual textual?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf16be (textual textual?) (start integer?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf16be (textual textual?) (start integer?) (end integer?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf16le (textual textual?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf16le (textual textual?) (start integer?) ) ⟹ bytevector?
(srfi 135) procedure (textual->utf16le (textual textual?) (start integer?) (end integer?) ) ⟹ bytevector?
These procedures return a newly allocated (unless empty) bytevector containing a UTF-8 or UTF-16 encoding of the given subtext or substring.
The bytevectors returned by textual->utf8, textual->utf16be, and textual->utf16le do not contain a byte-order mark (BOM). textual->utf16be returns a big-endian encoding, while textual->utf16le returns a little-endian encoding.
The bytevectors returned by textual->utf16 begin with a BOM that declares an implementation-dependent endianness, and the bytevector elements following that BOM encode the given subtext or substring using that endianness.
(srfi 135) procedure (utf8->text (bytevector bytevector?) ) ⟹ text?
(srfi 135) procedure (utf8->text (bytevector bytevector?) (start integer?) ) ⟹ text?
(srfi 135) procedure (utf8->text (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ text?
(srfi 135) procedure (utf16->text (bytevector bytevector?) ) ⟹ text?
(srfi 135) procedure (utf16->text (bytevector bytevector?) (start integer?) ) ⟹ text?
(srfi 135) procedure (utf16->text (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ text?
(srfi 135) procedure (utf16be->text (bytevector bytevector?) ) ⟹ text?
(srfi 135) procedure (utf16be->text (bytevector bytevector?) (start integer?) ) ⟹ text?
(srfi 135) procedure (utf16be->text (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ text?
(srfi 135) procedure (utf16le->text (bytevector bytevector?) ) ⟹ text?
(srfi 135) procedure (utf16le->text (bytevector bytevector?) (start integer?) ) ⟹ text?
(srfi 135) procedure (utf16le->text (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ text?
These procedures interpret their bytevector argument as a UTF-8 or UTF-16 encoding of a sequence of characters, and return a text containing that sequence.
The bytevector subrange given to utf16->text may begin with a byte order mark (BOM); if so, that BOM determines whether the rest of the subrange is to be interpreted as big-endian or little-endian; in either case, the BOM will not become a character in the returned text. If the subrange does not begin with a BOM, it is decoded using the same implementation-dependent endianness used by textual->utf16.
The utf16be->text and utf16le->text procedures interpret their inputs as big-endian or little-endian, respectively. If a BOM is present, it is treated as a normal character and will become part of the result.
It is an error if the bytevector subrange given to utf8->text contains invalid UTF-8 byte sequences. For the other three procedures, it is an error if start or end are odd, or if the bytevector subrange contains invalid UTF-16 byte sequences.
(srfi 135) procedure (text-length (text text?) ) ⟹ integer?
Returns the number of characters within the given text. Must execute in O(1) time.
(srfi 135) procedure (text-ref (text text?) (idx integer?) ) ⟹ char?
Returns character text[idx], using 0-origin indexing. Must execute in O(1) time.
(srfi 135) procedure (textual-length (textual textual?) ) ⟹ integer?
Returns the number of characters within the given textual. Generalization of text-length to accept strings as well as texts.
(srfi 135) procedure (textual-ref (text textual?) (idx integer?) ) ⟹ char?
Returns character text[idx], using 0-origin indexing. Generalization of text-ref to accept strings as well as texts.
(srfi 135) procedure (subtext (text text?) (start integer?) (end integer?) ) ⟹ text?
(srfi 135) procedure (subtextual (text textual?) (start integer?) (end integer?) ) ⟹ text?
These procedures return a text containing the characters of text or textual beginning with index start (inclusive) and ending with index end (exclusive).
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by subtextual. When the first argument is a text, as is required by subtext, implementations are encouraged to return a result that shares storage with that text, to whatever extent sharing is possible while maintaining some small fixed bound on the ratio of storage used by the shared representation divided by the storage that would be used by an unshared representation. In particular, these procedures should just return their first argument when that argument is a text, start is 0, and end is the length of that text.
(srfi 135) procedure (textual-copy (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-copy (textual textual?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-copy (textual textual?) (start integer?) (end integer?) ) ⟹ text?
Returns a text containing the characters of textual beginning with index start (inclusive) and ending with index end (exclusive).
Unlike subtext and subtextual, the result of textual-copy never shares substructures that would retain characters or sequences of characters that are substructures of its first argument or previously allocated objects.
If textual-copy returns an empty text, that empty text may be eq? or eqv? to the text returned by (text). If the text returned by textual-copy is non-empty, then it is not eqv? to any previously extant object.
(srfi 135) procedure (textual-take (textual textual?) (nchars integer?) ) ⟹ text?
(srfi 135) procedure (textual-drop (textual textual?) (nchars integer?) ) ⟹ text?
(srfi 135) procedure (textual-take-right (textual textual?) (nchars integer?) ) ⟹ text?
(srfi 135) procedure (textual-drop-right (textual textual?) (nchars integer?) ) ⟹ text?
textual-take returns a text containing the first nchars of textual; textual-drop returns a text containing all but the first nchars of textual. textual-take-right returns a text containing the last nchars of textual; textual-drop-right returns a text containing all but the last nchars of textual.
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by these procedures. If textual is a text, implementations are encouraged to return a result that shares storage with that text (which is easily accomplished by using subtext to create the result).
(srfi 135) procedure (textual-pad (textual textual?) (len integer?) ) ⟹ text?
(srfi 135) procedure (textual-pad (textual textual?) (len integer?) (char char?) ) ⟹ text?
(srfi 135) procedure (textual-pad (textual textual?) (len integer?) (char char?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-pad (textual textual?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ text?
(srfi 135) procedure (textual-pad-right (textual textual?) (len integer?) ) ⟹ text?
(srfi 135) procedure (textual-pad-right (textual textual?) (len integer?) (char char?) ) ⟹ text?
(srfi 135) procedure (textual-pad-right (textual textual?) (len integer?) (char char?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-pad-right (textual textual?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ text?
Returns a text of length len comprised of the characters drawn from the given subrange of textual, padded on the left (right) by as many occurrences of the character char as needed. If textual has more than len chars, it is truncated on the left (right) to length len. char defaults to #\space.
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by these procedures. If textual is a text, implementations are encouraged to return a result that shares storage with that text whenever sharing would be space-efficient.
(srfi 135) procedure (textual-trim (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-trim (textual textual?) (pred procedure?) ) ⟹ text?
(srfi 135) procedure (textual-trim (textual textual?) (pred procedure?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-trim (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
(srfi 135) procedure (textual-trim-right (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-trim-right (textual textual?) (pred procedure?) ) ⟹ text?
(srfi 135) procedure (textual-trim-right (textual textual?) (pred procedure?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-trim-right (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
(srfi 135) procedure (textual-trim-both (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-trim-both (textual textual?) (pred procedure?) ) ⟹ text?
(srfi 135) procedure (textual-trim-both (textual textual?) (pred procedure?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-trim-both (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
Returns a text obtained from the given subrange of textual by skipping over all characters on the left / on the right / on both sides that satisfy the second argument pred: pred defaults to char-whitespace?.
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by these procedures. If textual is a text, implementations are encouraged to return a result that shares storage with that text whenever sharing would be space-efficient.
(srfi 135) procedure (textual-replace (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ text?
(srfi 135) procedure (textual-replace (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ text?
(srfi 135) procedure (textual-replace (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ text?
Returns
(textual-append (subtextual textual1 0 start1)
(subtextual textual2 start2 end2)
(subtextual textual1 end1 (textual-length textual1)))
That is, the segment of characters in textual1 from start1 to end1 is replaced by the segment of characters in textual2 from start2 to end2. If start1=end1, this simply splices the characters drawn from textual2 into textual1 at that position.
(srfi 135) procedure (textual=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
Returns #t if all the texts have the same length and contain exactly the same characters in the same positions; otherwise returns #f.
(srfi 135) procedure (textual<? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(srfi 135) procedure (textual>? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(srfi 135) procedure (textual<=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(srfi 135) procedure (textual>=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
These procedures return #t if their arguments are (respectively): monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically non-increasing.
These comparison predicates are required to be transitive.
These procedures compare texts in an implementation-defined way. One approach is to make them the lexicographic extensions to texts of the corresponding orderings on characters. In that case, text<? would be the lexicographic ordering on texts induced by the ordering char<? on characters, and if two texts differ in length but are the same up to the length of the shorter text, the shorter text would be considered to be lexicographically less than the longer string. However, implementations are also allowed to use more sophisticated locale-specific orderings.
In all cases, a pair of texts must satisfy exactly one of textual<?, textual=?, and textual>?, must satisfy textual<=? if and only if they do not satisfy textual>?, and must satisfy textual>=? if and only if they do not satisfy textual<?.
(srfi 135) procedure (textual-ci=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
Returns #t if, after calling textual-foldcase on each of the arguments, all of the case-folded texts would have the same length and contain the same characters in the same positions; otherwise returns #f.
(srfi 135) procedure (textual-ci<? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(srfi 135) procedure (textual-ci>? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(srfi 135) procedure (textual-ci<=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
(srfi 135) procedure (textual-ci>=? (textual1 textual?) (textual2 textual?) (textual3 textual?) ... ) ⟹ boolean?
These procedures behave as though they had called textual-foldcase on their arguments before applying the corresponding procedures without "-ci".
(srfi 135) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) ) ⟹ integer?
(srfi 135) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ integer?
(srfi 135) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 135) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 135) procedure (textual-prefix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
(srfi 135) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) ) ⟹ integer?
(srfi 135) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ integer?
(srfi 135) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 135) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 135) procedure (textual-suffix-length (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
Return the length of the longest common prefix/suffix of textual1 and textual2. For prefixes, this is equivalent to their "mismatch index" (relative to the start indexes).
The optional start/end indexes restrict the comparison to the indicated subtexts of textual1 and textual2.
(srfi 135) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) ) ⟹ boolean?
(srfi 135) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ boolean?
(srfi 135) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 135) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 135) procedure (textual-prefix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
(srfi 135) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) ) ⟹ boolean?
(srfi 135) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ boolean?
(srfi 135) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 135) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 135) procedure (textual-suffix? (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Is textual1 a prefix/suffix of textual2?
The optional start/end indexes restrict the comparison to the indicated subtexts of textual1 and textual2.
(srfi 135) procedure (textual-index (textual textual?) (pred procedure?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-index (textual textual?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-index (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
(srfi 135) procedure (textual-index-right (textual textual?) (pred procedure?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-index-right (textual textual?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-index-right (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
(srfi 135) procedure (textual-skip (textual textual?) (pred procedure?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-skip (textual textual?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-skip (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
(srfi 135) procedure (textual-skip-right (textual textual?) (pred procedure?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-skip-right (textual textual?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-skip-right (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
textual-index searches through the given subtext or substring from the left, returning the index of the leftmost character satisfying the predicate pred. textual-index-right searches from the right, returning the index of the rightmost character satisfying the predicate pred. If no match is found, these procedures return #f.
Rationale: The SRFI 130 analogues of these procedures return cursors, even when no match is found, and SRFI 130's string-index-right returns the successor of the cursor for the first character that satisfies the predicate. As there are no cursors in this SRFI, it seems best to follow the more intuitive and long-standing precedent set by SRFI 13.
The start and end arguments specify the beginning and end of the search; the valid indexes relevant to the search include start but exclude end. Beware of "fencepost" errors: when searching right-to-left, the first index considered is (- end 1), whereas when searching left-to-right, the first index considered is start. That is, the start/end indexes describe the same half-open interval [start,end) in these procedures that they do in all other procedures specified by this SRFI.
The skip functions are similar, but use the complement of the criterion: they search for the first char that doesn't satisfy pred.
(srfi 135) procedure (textual-contains (textual1 textual?) (textual2 textual?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-contains (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-contains (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-contains (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-contains (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) (start1 integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ #f / integer? /
(srfi 135) procedure (textual-contains-right (textual1 textual?) (textual2 textual?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ #f / integer? /
Does the subtext of textual1 specified by start1 and end1 contain the sequence of characters given by the subtext of textual2 specified by start2 and end2?
Returns #f if there is no match. If start2 = end2, textual-contains returns start1 but textual-contains-right returns end1. Otherwise returns the index in textual1 for the first character of the first/last match; that index lies within the half-open interval [start1,end1), and the match lies entirely within the [start1,end1) range of textual1.
(srfi 135) procedure (textual-upcase (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-downcase (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-foldcase (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-titlecase (textual textual?) ) ⟹ text?
These procedures return the text obtained by applying Unicode's full uppercasing, lowercasing, case-folding, or title-casing algorithms to their argument. In some cases, the length of the result may be different from the length of the argument. Note that language-sensitive mappings and foldings are not used.
(srfi 135) procedure (textual-append (textual textual?) ... ) ⟹ text?
Returns a text whose sequence of characters is the concatenation of the sequences of characters in the given arguments.
(srfi 135) procedure (textual-concatenate (textual-list list?) ) ⟹ text?
Concatenates the elements of textual-list together into a single text.
If any elements of textual-list are strings, then those strings do not share any storage with the result, so subsequent mutation of those string will not affect the text returned by this procedure. Implementations are encouraged to return a result that shares storage with some of the texts in the list if that sharing would be space-efficient.
Rationale: Some implementations of Scheme limit the number of arguments that may be passed to an n-ary procedure, so the (apply textual-append textual-list) idiom, which is otherwise equivalent to using this procedure, is not as portable.
(srfi 135) procedure (textual-concatenate-reverse (textual-list list?) ) ⟹ text?
(srfi 135) procedure (textual-concatenate-reverse (textual-list list?) (final-textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-concatenate-reverse (textual-list list?) (final-textual textual?) (end integer?) ) ⟹ text?
With no optional arguments, calling this procedure is equivalent to
(textual-concatenate (reverse textual-list))
If the optional argument final-textual is specified, it is effectively consed onto the beginning of textual-list before performing the list-reverse and textual-concatenate operations.
If the optional argument end is given, only the characters up to but not including end in final-textual are added to the result, thus producing
(textual-concatenate
(reverse (cons (subtext final-textual 0 end)
textual-list)))
(srfi 135) procedure (textual-join (textual-list list?) ) ⟹ text?
(srfi 135) procedure (textual-join (textual-list list?) (delimiter textual?) ) ⟹ text?
(srfi 135) procedure (textual-join (textual-list list?) (delimiter textual?) (grammar symbol?) ) ⟹ text?
This procedure is a simple unparser; it pastes texts together using the delimiter text.
textual-list is a list of texts and/or strings. delimiter is a text or a string. The grammar argument is a symbol that determines how the delimiter is used, and defaults to 'infix. It is an error for grammar to be any symbol other than these four:
'infix means an infix or separator grammar: insert the delimiter between list elements. An empty list will produce an empty text.
'strict-infix means the same as 'infix if the textual-list is non-empty, but will signal an error if given an empty list. (This avoids an ambiguity shown in the examples below.)
'suffix means a suffix or terminator grammar: insert the delimiter after every list element.
'prefix means a prefix grammar: insert the delimiter before every list element.
The delimiter is the text used to delimit elements; it defaults to a single space " ".
(srfi 135) procedure (textual-fold (kons procedure?) knil (textual textual?) ) ⟹ *
(srfi 135) procedure (textual-fold (kons procedure?) knil (textual textual?) (start integer?) ) ⟹ *
(srfi 135) procedure (textual-fold (kons procedure?) knil (textual textual?) (start integer?) (end integer?) ) ⟹ *
(kons (char char?) state ) ⟹ *
(srfi 135) procedure (textual-fold-right (kons procedure?) knil (textual textual?) ) ⟹ *
(srfi 135) procedure (textual-fold-right (kons procedure?) knil (textual textual?) (start integer?) ) ⟹ *
(srfi 135) procedure (textual-fold-right (kons procedure?) knil (textual textual?) (start integer?) (end integer?) ) ⟹ *
(kons (char char?) state ) ⟹ *
These are the fundamental iterators for texts.
The textual-fold procedure maps the kons procedure across the given text or string from left to right:
(... (kons textual[2] (kons textual[1] (kons textual[0] knil))))
The textual-fold-right procedure maps kons across the given text or string from right to left:
(kons textual[0]
(... (kons textual[end-3]
(kons textual[end-2]
(kons textual[end-1]
knil)))))
(srfi 135) procedure (textual-map (proc procedure?) (textual1 textual?) (textual2 textual?) ... ) ⟹ text?
(proc (char1 char?) (char2 char?) ... ) ⟹ textual? / char? /
It is an error if proc does not accept as many arguments as the number of textual arguments passed to textual-map, does not accept characters as arguments, or returns a value that is not a character, string, or text.
The textual-map procedure applies proc element-wise to the characters of the textual arguments, converts each value returned by proc to a text, and returns the concatenation of those texts. If more than one textual argument is given and not all have the same length, then textual-map terminates when the shortest textual argument runs out. The dynamic order in which proc is called on the characters of the textual arguments is unspecified, as is the dynamic order in which the coercions are performed. If any strings returned by proc are mutated after they have been returned and before the call to textual-map has returned, then textual-map returns a text with unspecified contents; the textual-map procedure itself does not mutate those strings.
(srfi 135) procedure (textual-for-each (proc procedure?) (textual1 textual?) (textual2 textual?) ... ) ⟹ undefined
(proc (char1 char?) (char2 char?) ... ) ⟹ undefined
It is an error if proc does not accept as many arguments as the number of textual arguments passed to textual-map or does not accept characters as arguments.
The textual-for-each procedure applies proc element-wise to the characters of the textual arguments, going from left to right. If more than one textual argument is given and not all have the same length, then textual-for-each terminates when the shortest textual argument runs out.
(srfi 135) procedure (textual-map-index (proc procedure?) (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-map-index (proc procedure?) (textual textual?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-map-index (proc procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ text?
(proc (char char?) ) ⟹ textual? / char? /
Calls proc on each valid index of the specified subtext or substring, converts the results of those calls into texts, and returns the concatenation of those texts. It is an error for proc to return anything other than a character, string, or text. The dynamic order in which proc is called on the indexes is unspecified, as is the dynamic order in which the coercions are performed. If any strings returned by proc are mutated after they have been returned and before the call to textual-map-index has returned, then textual-map-index returns a text with unspecified contents; the textual-map-index procedure itself does not mutate those strings.
(srfi 135) procedure (textual-for-each-index (proc procedure?) (textual textual?) ) ⟹ undefined
(srfi 135) procedure (textual-for-each-index (proc procedure?) (textual textual?) (start integer?) ) ⟹ undefined
(srfi 135) procedure (textual-for-each-index (proc procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ undefined
(proc (char char?) ) ⟹ undefined
Calls proc on each valid index of the specified subtext or substring, in increasing order, discarding the results of those calls. This is simply a safe and correct way to loop over a subtext or substring.
(srfi 135) procedure (textual-count (textual textual?) (pred procedure?) ) ⟹ integer?
(srfi 135) procedure (textual-count (textual textual?) (pred procedure?) (start integer?) ) ⟹ integer?
(srfi 135) procedure (textual-count (textual textual?) (pred procedure?) (start integer?) (end integer?) ) ⟹ integer?
(pred (char char?) ) ⟹ boolean?
Returns a count of the number of characters in the specified subtext of textual that satisfy the given predicate.
(srfi 135) procedure (textual-filter (pred procedure?) (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-filter (pred procedure?) (textual textual?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-filter (pred procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
(srfi 135) procedure (textual-remove (pred procedure?) (textual textual?) ) ⟹ text?
(srfi 135) procedure (textual-remove (pred procedure?) (textual textual?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-remove (pred procedure?) (textual textual?) (start integer?) (end integer?) ) ⟹ text?
(pred (char char?) ) ⟹ boolean?
Filter the given subtext of textual, retaining only those characters that satisfy / do not satisfy pred.
If textual is a string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the text returned by these procedures. If textual is a text, implementations are encouraged to return a result that shares storage with that text whenever sharing would be space-efficient.
(srfi 135) procedure (textual-replicate (textual textual?) (from integer?) (to integer?) ) ⟹ text?
(srfi 135) procedure (textual-replicate (textual textual?) (from integer?) (to integer?) (start integer?) ) ⟹ text?
(srfi 135) procedure (textual-replicate (textual textual?) (from integer?) (to integer?) (start integer?) (end integer?) ) ⟹ text?
This is an "extended subtext" procedure that implements replicated copying of a subtext or substring.
textual is a text or string; start and end are optional arguments that specify a subtext of textual, defaulting to 0 and the length of textual. This subtext is conceptually replicated both up and down the index space, in both the positive and negative directions. textual-replicate returns the subtext of this text beginning at index from, and ending at to. It is an error if from is greater than to.
Note that
It is an error if start=end, unless from=to, which is allowed as a special case.
(srfi 135) procedure (textual-split (textual textual?) (delimiter textual?) ) ⟹ list?
(srfi 135) procedure (textual-split (textual textual?) (delimiter textual?) (grammar symbol?) ) ⟹ list?
(srfi 135) procedure (textual-split (textual textual?) (delimiter textual?) (grammar symbol?) (limit (or #finteger?)) ) ⟹ list?
(srfi 135) procedure (textual-split (textual textual?) (delimiter textual?) (grammar symbol?) (limit (or #finteger?)) (start integer?) ) ⟹ list?
(srfi 135) procedure (textual-split (textual textual?) (delimiter textual?) (grammar symbol?) (limit (or #finteger?)) (start integer?) (end integer?) ) ⟹ list?
Returns a list of texts representing the words contained in the subtext of textual from start (inclusive) to end (exclusive). The delimiter is a text or string to be used as the word separator. This will often be a single character, but multiple characters are allowed for use cases such as splitting on "\r\n". The returned list will have one more item than the number of non-overlapping occurrences of the delimiter in the text. If delimiter is an empty text, then the returned list contains a list of texts, each of which contains a single character.
The grammar is a symbol with the same meaning as in the textual-join procedure. If it is infix, which is the default, processing is done as described above, except an empty textual produces the empty list; if grammar is strict-infix, then an empty textual signals an error. The values prefix and suffix cause a leading/trailing empty text in the result to be suppressed.
If limit is a non-negative exact integer, at most that many splits occur, and the remainder of textual is returned as the final element of the list (so the result will have at most limit+1 elements). If limit is not specified or is #f, then as many splits as possible are made. It is an error if limit is any other value.
library (srfi 137)
(srfi 137) procedure (make-type type-payload ) ⟹ (values procedure?procedure?procedure?procedure?procedure?)
(make-type type-payload) → type-accessor constructor predicate accessor make-subtype
Calling make-type on type-payload, which can be any Scheme object, returns five values, all of which are procedures. They are distinct (in the sense of eqv?) from each other and from any other procedures returned by other calls to make-type. In brief, the five functions:
return type-payload
return newly allocated objects of a disjoint type known as instances, each associated with an instance payload
return #t iff an object is an instance of this type
return the instance payload
return five more procedures associated with a subtype of this type
The type payload might contain metadata (such as field names or class variables) associated with the type as a whole.
For the purposes of this section, we will suppose that
(define-values (reia-metadata make-reia reia? reia-ref make-reia-subtype) (make-type 'reia))
has been evaluated, and document each of the five variables that it binds. "Reia" is an acronym for "remarkably 'evil' in appearance", and has no particular significance. Fnord!
(reia-metadata) → object
Returns the symbol reia.
(make-reia instance-payload)→ reia
Returns a newly allocated instance associated with instance-payload. This association is single and immutable, but it is possible to make use of an appropriate container payload in order to effectively associate the instance with more than one value. To make the association effectively mutable, use a mutable payload such as a box, list or vector. Instances belong to a type that is disjoint from any existing Scheme type, including types created by other calls to make-type.
(reia? object)→ boolean
Returns #t iff object was returned by a call to make-reia or any constructor created as part of a direct or indirect subtype of the reia type.
(reia-ref reia)→ object
Returns the instance payload of reia. It is an error if reia does not satisfy reia?.
(make-reia-subtype type-payload)→ type-accessor constructor predicate accessor make-subtype
Returns five new procedures with the same semantics as make-type, such that the objects returned by constructor satisfy reia? and their payload can be accessed using reia-ref.
library (srfi 139)
(srfi 139) syntax (define-syntax-parameter () ((_ keyword transformer-spec)) )
Binds <keyword> to the transformer obtained by evaluating <transformer spec>. The transformer provides the default expansion for the syntax parameter, and in the absence of syntax-parameterize, is functionally equivalent to define-syntax.
(srfi 139) syntax (syntax-parameterize () ((_ ((keyword transformer-spec) ...) body)) )
Adjusts the <keyword>s to use the transformer obtained by evaluating the corresponding <transformer>s in the expansion of the <body>. Each keyword must be bound to a syntax parameter. syntax-parameterize differs from let-syntax in that the binding is not shadowed, but adjusted, and so uses of the keyword in the expansion of <body> use the new transformers. This is somewhat similar to how parameterize adjusts the values of regular parameters, rather than creating new bindings.
library (srfi 140)
(srfi 140) procedure (string? obj ) ⟹ boolean?
Is obj a string? Must return true if istring? returns true. Must execute in O(1) time.
(srfi 140) procedure (istring? obj ) ⟹ boolean?
Is obj an immutable string, with guaranteed O(1) performance for string-ref and string-length? Must execute in O(1) time.
(srfi 140) procedure (string-null? (string string?) ) ⟹ boolean?
Is string the empty string? Same result as (= (string-length string) 0) but must execute in O(1) time.
(srfi 140) procedure (string-every (pred procedure?) (string string?) ) ⟹ *
(srfi 140) procedure (string-every (pred procedure?) (string string?) (start integer?) ) ⟹ *
(srfi 140) procedure (string-every (pred procedure?) (string string?) (start integer?) (end integer?) ) ⟹ *
(pred (c char?) ) ⟹ boolean?
(srfi 140) procedure (string-any (pred procedure?) (string string?) ) ⟹ *
(srfi 140) procedure (string-any (pred procedure?) (string string?) (start integer?) ) ⟹ *
(srfi 140) procedure (string-any (pred procedure?) (string string?) (start integer?) (end integer?) ) ⟹ *
(pred (c char?) ) ⟹ boolean?
Checks to see if every/any character in string satisfies pred, proceeding from left (index start) to right (index end). These procedures are short-circuiting: if pred returns false, string-every does not call pred on subsequent characters; if pred returns true, string-any does not call pred on subsequent characters. Both procedures are "witness-generating":
Note: The names of these procedures do not end with a question mark. This indicates a general value is returned instead of a simple boolean (#t or #f).
(srfi 140) procedure (string->vector (string string?) ) ⟹ vector?
(srfi 140) procedure (string->vector (string string?) (start integer?) ) ⟹ vector?
(srfi 140) procedure (string->vector (string string?) (start integer?) (end integer?) ) ⟹ vector?
return ⟹ (vector (char char?) )
(srfi 140) procedure (string->list (string string?) ) ⟹ list?
(srfi 140) procedure (string->list (string string?) (start integer?) ) ⟹ list?
(srfi 140) procedure (string->list (string string?) (start integer?) (end integer?) ) ⟹ list?
return ⟹ (list (char char?) )
string->vector, and string->list return a newly allocated (unless empty) vector, or list of the characters that make up the given substring.
(srfi 140) procedure (vector->string (char-vector vector?) ) ⟹ istring?
(srfi 140) procedure (vector->string (char-vector vector?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (vector->string (char-vector vector?) (start integer?) (end integer?) ) ⟹ istring?
char-vector ⟹ (vector (char char?) )
(srfi 140) procedure (list->string (char-list list?) ) ⟹ istring?
(srfi 140) procedure (list->string (char-list list?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (list->string (char-list list?) (start integer?) (end integer?) ) ⟹ istring?
char-list ⟹ (list (char char?) )
These procedures return an istring containing the characters of the given subvector or sublist. The behavior of the result will not be affected by subsequent mutation of the vector or list.
(srfi 140) procedure (reverse-list->string (char-list list?) ) ⟹ istring?
char-list ⟹ (list (char char?) )
An efficient implementation of (compose list->string reverse):
(reverse-list->string '(#\a #\B #\c)) → "cBa"
This is a common idiom in the epilogue of string-processing loops that accumulate their result using a list in reverse order. (See also string-concatenate-reverse for the "chunked" variant.)
(srfi 140) procedure (string->utf8 (string string?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf8 (string string?) (start integer?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf8 (string string?) (start integer?) (end integer?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf16 (string string?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf16 (string string?) (start integer?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf16 (string string?) (start integer?) (end integer?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf16be (string string?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf16be (string string?) (start integer?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf16be (string string?) (start integer?) (end integer?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf16le (string string?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf16le (string string?) (start integer?) ) ⟹ bytevector?
(srfi 140) procedure (string->utf16le (string string?) (start integer?) (end integer?) ) ⟹ bytevector?
These procedures return a newly allocated (unless empty) bytevector containing a UTF-8 or UTF-16 encoding of the given substring.
The bytevectors returned by string->utf8, string->utf16be, and string->utf16le do not contain a byte-order mark (BOM). string->utf16be returns a big-endian encoding, while string->utf16le returns a little-endian encoding.
The bytevectors returned by string->utf16 begin with a BOM that declares an implementation-dependent endianness. The latter should match the big-endian or little-endian identifier returned by the R7RS features procedure. The bytevector elements following that BOM encode the given substring using that endianness.
Rationale: These procedures are consistent with the Unicode standard. Unicode suggests UTF-16 should default to big-endian, but Microsoft prefers little-endian.
(srfi 140) procedure (utf8->string (bytevector bytevector?) ) ⟹ istring?
(srfi 140) procedure (utf8->string (bytevector bytevector?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (utf8->string (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ istring?
(srfi 140) procedure (utf16->string (bytevector bytevector?) ) ⟹ istring?
(srfi 140) procedure (utf16->string (bytevector bytevector?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (utf16->string (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ istring?
(srfi 140) procedure (utf16be->string (bytevector bytevector?) ) ⟹ istring?
(srfi 140) procedure (utf16be->string (bytevector bytevector?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (utf16be->string (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ istring?
(srfi 140) procedure (utf16le->string (bytevector bytevector?) ) ⟹ istring?
(srfi 140) procedure (utf16le->string (bytevector bytevector?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (utf16le->string (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ istring?
These procedures interpret their bytevector argument as a UTF-8 or UTF-16 encoding of a sequence of characters, and return a string containing that sequence.
The bytevector subrange given to utf16->string may begin with a byte order mark (BOM); if so, that BOM determines whether the rest of the subrange is to be interpreted as big-endian or little-endian; in either case, the BOM will not become a character in the returned string. If the subrange does not begin with a BOM, it is decoded using the same implementation-dependent endianness used by string->utf16.
The utf16be->string and utf16le->string procedures interpret their inputs as big-endian or little-endian, respectively. If a BOM is present, it is treated as a normal character and will become part of the result.
It is an error if the bytevector subrange given to utf8->string contains invalid UTF-8 byte sequences. For the other three procedures, it is an error if (- end start) is odd, or if the bytevector subrange contains invalid UTF-16 byte sequences.
(srfi 140) procedure (string (char char?) ... ) ⟹ istring?
Returns a string consisting of the given characters.
(srfi 140) procedure (string-tabulate (proc procedure?) (len integer?) ) ⟹ istring?
(proc (index integer?) ) ⟹ char?
Proc is a procedure that accepts an exact integer as its argument and returns a character. Constructs a string of size len by calling proc on each value from 0 (inclusive) to len (exclusive) to produce the corresponding element of the string. The order in which proc is called on those indexes is not specified.
Rationale: Although string-unfold is more general, string-tabulate is likely to run faster for the common special case it implements.
(srfi 140) procedure (string-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ istring?
(srfi 140) procedure (string-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base (or char?string?)) ) ⟹ istring?
(srfi 140) procedure (string-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base (or char?string?)) (make-final procedure?) ) ⟹ istring?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char? / string? /
(successor seed ) ⟹ *
(make-final seed ) ⟹ char? / string? /
(srfi 140) procedure (string-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ istring?
(srfi 140) procedure (string-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base (or char?string?)) ) ⟹ istring?
(srfi 140) procedure (string-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base (or char?string?)) (make-final procedure?) ) ⟹ istring?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char? / string? /
(successor seed ) ⟹ *
(make-final seed ) ⟹ char? / string? /
This is a fundamental constructor for strings.
string-unfold-right is the same as string-unfold except the results of mapper are assembled into the string in right-to-left order, base is the optional rightmost portion of the constructed string, and make-final produces the leftmost portion of the constructed string. If mapper returns a string, the string is prepended to the constructed string (without reversal).
(srfi 140) procedure (string-length (string string?) ) ⟹ integer?
Returns the number of characters in the given string. If the string is an istring, must execute in constant time.
(srfi 140) 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. If the string is an istring, must execute in constant time.
(srfi 140) procedure (substring (string string?) (start integer?) (end integer?) ) ⟹ istring?
This procedure returns a istring containing the characters of string starting with index start (inclusive) and ending with index end (exclusive).
If string is a mutable string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the result returned by substring. When the first argument is an istring, implementations are encouraged to return a result that shares storage with that istring, to whatever extent sharing is possible while maintaining some small fixed bound on the ratio of storage used by the shared representation divided by the storage that would be used by an unshared representation. In particular, these procedures should just return their first argument when that argument is an istring, start is 0, and end is the length of that string.
For the functionality of substring with guaranteed no sharing use xsubstring for an immutable result, or string-copy for a mutable result.
(srfi 140) procedure (string-take (string string?) (nchars integer?) ) ⟹ istring?
(srfi 140) procedure (string-drop (string string?) (nchars integer?) ) ⟹ istring?
(srfi 140) procedure (string-take-right (string string?) (nchars integer?) ) ⟹ istring?
(srfi 140) procedure (string-drop-right (string string?) (nchars integer?) ) ⟹ istring?
string-take returns an immutable string containing the first nchars of string; string-drop returns a string containing all but the first nchars of string. string-take-right returns a string containing the last nchars of string; string-drop-right returns a string containing all but the last nchars of string.
Subsequent mutation of the argument string will not affect the istring returned by these procedures. If string is an istring, implementations are encouraged to return a result that shares storage with that string (which is easily accomplished by using substring to create the result).
(srfi 140) procedure (string-pad (string string?) (len integer?) ) ⟹ istring?
(srfi 140) procedure (string-pad (string string?) (len integer?) (char char?) ) ⟹ istring?
(srfi 140) procedure (string-pad (string string?) (len integer?) (char char?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (string-pad (string string?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ istring?
(srfi 140) procedure (string-pad-right (string string?) (len integer?) ) ⟹ istring?
(srfi 140) procedure (string-pad-right (string string?) (len integer?) (char char?) ) ⟹ istring?
(srfi 140) procedure (string-pad-right (string string?) (len integer?) (char char?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (string-pad-right (string string?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ istring?
Returns an istring of length len comprised of the characters drawn from the given subrange of string. The result is padded on the left (right) by as many occurrences of the character char (which defaults to #\space) as needed. If string has more than len chars, it is truncated on the left (right) to length len.
(srfi 140) procedure (string-trim (string string?) ) ⟹ istring?
(srfi 140) procedure (string-trim (string string?) (pred procedure?) ) ⟹ istring?
(srfi 140) procedure (string-trim (string string?) (pred procedure?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (string-trim (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ istring?
(pred (char char?) ) ⟹ boolean?
(srfi 140) procedure (string-trim-right (string string?) ) ⟹ istring?
(srfi 140) procedure (string-trim-right (string string?) (pred procedure?) ) ⟹ istring?
(srfi 140) procedure (string-trim-right (string string?) (pred procedure?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (string-trim-right (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ istring?
(pred (char char?) ) ⟹ boolean?
(srfi 140) procedure (string-trim-both (string string?) ) ⟹ istring?
(srfi 140) procedure (string-trim-both (string string?) (pred procedure?) ) ⟹ istring?
(srfi 140) procedure (string-trim-both (string string?) (pred procedure?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (string-trim-both (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ istring?
(pred (char char?) ) ⟹ boolean?
Returns a string obtained from the given subrange of string by skipping over all characters on the left / on the right / on both sides that satisfy the second argument pred: pred defaults to char-whitespace?.
(srfi 140) procedure (string-replace (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ istring?
(srfi 140) procedure (string-replace (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ istring?
(srfi 140) procedure (string-replace (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ istring?
Returns
(string-append (substring string1 0 start1)
(substring string2 start2 end2)
(substring string1 end1 (string-length string1)))
That is, the segment of characters in string1 from start1 to end1 is replaced by the segment of characters in string2 from start2 to end2. If start1=end1, this simply splices the characters drawn from string2 into string1 at that position.
(srfi 140) procedure (string=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 140) procedure (string<? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 140) procedure (string>? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 140) procedure (string<=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 140) procedure (string>=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 140) procedure (string-ci=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 140) procedure (string-ci<? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 140) procedure (string-ci>? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 140) procedure (string-ci<=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 140) procedure (string-ci>=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
As in R7RS
(srfi 140) procedure (string-prefix-length (string1 string?) (string2 string?) ) ⟹ integer?
(srfi 140) procedure (string-prefix-length (string1 string?) (string2 string?) (start1 integer?) ) ⟹ integer?
(srfi 140) procedure (string-prefix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 140) procedure (string-prefix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 140) procedure (string-prefix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
(srfi 140) procedure (string-suffix-length (string1 string?) (string2 string?) ) ⟹ integer?
(srfi 140) procedure (string-suffix-length (string1 string?) (string2 string?) (start1 integer?) ) ⟹ integer?
(srfi 140) procedure (string-suffix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 140) procedure (string-suffix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 140) procedure (string-suffix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
Return the length of the longest common prefix/suffix of string1 and string2. For prefixes, this is equivalent to their "mismatch index" (relative to the start indexes).
The optional start/end indexes restrict the comparison to the indicated substrings of string1 and string2.
(srfi 140) procedure (string-prefix? (string1 string?) (string2 string?) ) ⟹ boolean?
(srfi 140) procedure (string-prefix? (string1 string?) (string2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 140) procedure (string-prefix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 140) procedure (string-prefix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 140) procedure (string-prefix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
(srfi 140) procedure (string-suffix? (string1 string?) (string2 string?) ) ⟹ boolean?
(srfi 140) procedure (string-suffix? (string1 string?) (string2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 140) procedure (string-suffix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 140) procedure (string-suffix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 140) procedure (string-suffix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Is string1 a prefix/suffix of string2?
The optional start/end indexes restrict the comparison to the indicated substrings of string1 and string2.
(srfi 140) procedure (string-index (string string?) (pred procedure?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-index (string string?) (pred procedure?) (start integer?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-index (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ integer? / #f /
(pred (char char?) ) ⟹ boolean?
(srfi 140) procedure (string-index-right (string string?) (pred procedure?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-index-right (string string?) (pred procedure?) (start integer?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-index-right (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ integer? / #f /
(pred (char char?) ) ⟹ boolean?
(srfi 140) procedure (string-skip (string string?) (pred procedure?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-skip (string string?) (pred procedure?) (start integer?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-skip (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ integer? / #f /
(pred (char char?) ) ⟹ boolean?
(srfi 140) procedure (string-skip-right (string string?) (pred procedure?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-skip-right (string string?) (pred procedure?) (start integer?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-skip-right (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ integer? / #f /
(pred (char char?) ) ⟹ boolean?
string-index searches through the given substring from the left, returning the index of the leftmost character satisfying the predicate pred. string-index-right searches from the right, returning the index of the rightmost character satisfying the predicate pred. If no match is found, these procedures return #f.
Rationale: The SRFI 130 analogues of these procedures return cursors, even when no match is found, and SRFI 130's string-index-right returns the successor of the cursor for the first character that satisfies the predicate. As there are no cursors in this SRFI, it seems best to follow the more intuitive and long-standing precedent set by SRFI 13.
The start and end arguments specify the beginning and end of the search; the valid indexes relevant to the search include start but exclude end. Beware of "fencepost" errors: when searching right-to-left, the first index considered is (- end 1), whereas when searching left-to-right, the first index considered is start. That is, the start/end indexes describe the same half-open interval [start,end) in these procedures that they do in all other procedures specified by this SRFI.
The skip functions are similar, but use the complement of the criterion: they search for the first char that doesn't satisfy pred. To skip over initial whitespace, for example, say
(substring string
(or (string-skip string char-whitespace?)
(string-length string))
(string-length string))
These functions can be trivially composed with string-take and string-drop to produce take-while, drop-while, span, and break procedures without loss of efficiency.
(srfi 140) procedure (string-contains (string1 string?) (string2 string?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-contains (string1 string?) (string2 string?) (start1 integer?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-contains (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-contains (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-contains-right (string1 string?) (string2 string?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-contains-right (string1 string?) (string2 string?) (start1 integer?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-contains-right (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer? / #f /
(srfi 140) procedure (string-contains-right (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer? / #f /
Does the substring of string1 specified by start1 and end1 contain the sequence of characters given by the substring of string2 specified by start2 and end2?
Returns #f if there is no match. If start2 = end2, string-contains returns start1 but string-contains-right returns end1. Otherwise returns the index in string1 for the first character of the first/last match; that index lies within the half-open interval [start1,end1), and the match lies entirely within the [start1,end1) range of string1.
(srfi 140) procedure (string-upcase (string string?) ) ⟹ istring?
(srfi 140) procedure (string-downcase (string string?) ) ⟹ istring?
(srfi 140) procedure (string-foldcase (string string?) ) ⟹ istring?
(srfi 140) procedure (string-titlecase (string string?) ) ⟹ istring?
These procedures return the string obtained by applying Unicode's full uppercasing, lowercasing, case-folding, or title-casing algorithms to their argument. In some cases, the length of the result may be different from the length of the argument. If the result is equal to the argument in the sense of string=?, and the argument is immutable, then that argument may be returned. Note that language-sensitive mappings and foldings are not used.
The results are the same as the R7RS procedures, but as immutable strings.
(srfi 140) procedure (string-append (string string?) ... ) ⟹ istring?
Returns a string whose sequence of characters is the concatenation of the sequences of characters in the given arguments.
(srfi 140) procedure (string-concatenate (string-list list?) ) ⟹ istring?
string-list ⟹ (list (string string?) )
Concatenates the elements of string-list together into a single string.
If any elements of string-list are mutable strings, then those strings do not share any storage with the result, so subsequent mutation of those string will not affect the string returned by this procedure. Implementations are encouraged to return a result that shares storage with some of the strings in the list if that sharing would be space-efficient.
Rationale: Some implementations of Scheme limit the number of arguments that may be passed to an n-ary procedure, so the (apply string-append string-list) idiom, which is otherwise equivalent to using this procedure, is not as portable.
(srfi 140) procedure (string-concatenate-reverse (string-list list?) ) ⟹ istring?
(srfi 140) procedure (string-concatenate-reverse (string-list list?) (final-string string?) ) ⟹ istring?
(srfi 140) procedure (string-concatenate-reverse (string-list list?) (final-string string?) (end integer?) ) ⟹ istring?
string-list ⟹ (list (string string?) )
With no optional arguments, calling this procedure is equivalent to
(string-concatenate (reverse string-list))
If the optional argument final-string is specified, it is effectively consed onto the beginning of string-list before performing the list-reverse and string-concatenate operations.
If the optional argument end is given, only the characters up to but not including end in final-string are added to the result, thus producing
(string-concatenate
(reverse (cons (substring final-string 0 end)
string-list)))
(srfi 140) procedure (string-join (string-list list?) ) ⟹ istring?
(srfi 140) procedure (string-join (string-list list?) (delimiter string?) ) ⟹ istring?
(srfi 140) procedure (string-join (string-list list?) (delimiter string?) (grammar symbol?) ) ⟹ istring?
This procedure is a simple unparser; it pastes strings together using the delimiter string.
The string-list is a list of strings. The delimiter is the string used to delimit elements; it defaults to a single space " ". The grammar argument is a symbol that determines how the delimiter is used, and defaults to 'infix. It is an error for grammar to be any symbol other than these four:
(srfi 140) procedure (string-fold (kons procedure?) knil (string string?) ) ⟹ *
(srfi 140) procedure (string-fold (kons procedure?) knil (string string?) (start integer?) ) ⟹ *
(srfi 140) procedure (string-fold (kons procedure?) knil (string string?) (start integer?) (end integer?) ) ⟹ *
(kons (char char?) value ) ⟹ *
(srfi 140) procedure (string-fold-right (kons procedure?) knil (string string?) ) ⟹ *
(srfi 140) procedure (string-fold-right (kons procedure?) knil (string string?) (start integer?) ) ⟹ *
(srfi 140) procedure (string-fold-right (kons procedure?) knil (string string?) (start integer?) (end integer?) ) ⟹ *
(kons (char char?) value ) ⟹ *
These are the fundamental iterators for strings.
The string-fold procedure maps the kons procedure across the given string from left to right:
(... (kons string[2] (kons string[1] (kons string[0] knil))))
The string-fold-right procedure maps kons across the given string or string from right to left:
(kons string[0]
(... (kons string[end-3]
(kons string[end-2]
(kons string[end-1]
knil)))))
(srfi 140) procedure (string-map (proc procedure?) (string1 string?) (string2 string?) ... ) ⟹ istring?
(proc (char1 char?) ... ) ⟹ char? / string? /
As in R7RS, except the result is an immutable string. As an extension, the result from proc may be a string (not just a character).
(srfi 140) procedure (string-for-each (proc procedure?) (string1 string?) (string2 string?) ... ) ⟹ undefined
(proc (char1 char?) ... ) ⟹ undefined
As in R7RS.
(srfi 140) procedure (string-map-index (proc procedure?) (string string?) ) ⟹ istring?
(srfi 140) procedure (string-map-index (proc procedure?) (string string?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (string-map-index (proc procedure?) (string string?) (start integer?) (end integer?) ) ⟹ istring?
(proc (index integer?) ) ⟹ string? / char? /
Calls proc on each valid index of the specified substring, converts the results of those calls into strings, and returns the concatenation of those strings. It is an error for proc to return anything other than a character or string. The dynamic order in which proc is called on the indexes is unspecified, as is the dynamic order in which the coercions are performed. If any strings returned by proc are mutated after they have been returned and before the call to string-map-index has returned, then string-map-index returns a string with unspecified contents; the string-map-index procedure itself does not mutate those strings.
(srfi 140) procedure (string-for-each-index (proc procedure?) (string string?) ) ⟹ undefined
(srfi 140) procedure (string-for-each-index (proc procedure?) (string string?) (start integer?) ) ⟹ undefined
(srfi 140) procedure (string-for-each-index (proc procedure?) (string string?) (start integer?) (end integer?) ) ⟹ undefined
(proc (index integer?) ) ⟹ undefined
Calls proc on each valid index of the specified substring, in increasing order, discarding the results of those calls. This is simply a safe and correct way to loop over a substring.
(srfi 140) procedure (string-count (string string?) (pred procedure?) ) ⟹ integer?
(srfi 140) procedure (string-count (string string?) (pred procedure?) (start integer?) ) ⟹ integer?
(srfi 140) procedure (string-count (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ integer?
(pred (char char?) ) ⟹ boolean?
Returns a count of the number of characters in the specified substring of string that satisfy the given predicate.
(srfi 140) procedure (string-filter (pred procedure?) (string string?) ) ⟹ istring?
(srfi 140) procedure (string-filter (pred procedure?) (string string?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (string-filter (pred procedure?) (string string?) (start integer?) (end integer?) ) ⟹ istring?
(pred (char char?) ) ⟹ boolean?
(srfi 140) procedure (string-remove (pred procedure?) (string string?) ) ⟹ istring?
(srfi 140) procedure (string-remove (pred procedure?) (string string?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (string-remove (pred procedure?) (string string?) (start integer?) (end integer?) ) ⟹ istring?
(pred (char char?) ) ⟹ boolean?
Filter the given substring of string, retaining only those characters that satisfy / do not satisfy pred.
If string is a mutable string, then that string does not share any storage with the result, so subsequent mutation of that string will not affect the string returned by these procedures. If string is an immutable string, implementations are encouraged to return a result that shares storage with that string whenever sharing would be space-efficient.
(srfi 140) procedure (string-repeat (string-or-char (or string?char?)) (len integer?) ) ⟹ istring?
Create a string by repeating the first argument len times. If the first argument is a character, it is as if it were wrapped with the string constructor.
(srfi 140) procedure (xsubstring (string string?) ) ⟹ istring?
(srfi 140) procedure (xsubstring (string string?) (from integer?) ) ⟹ istring?
(srfi 140) procedure (xsubstring (string string?) (from integer?) (to integer?) ) ⟹ istring?
(srfi 140) procedure (xsubstring (string string?) (from integer?) (to integer?) (start integer?) ) ⟹ istring?
(srfi 140) procedure (xsubstring (string string?) (from integer?) (to integer?) (start integer?) (end integer?) ) ⟹ istring?
This is an "extended substring" procedure that implements replicated copying of a substring.
string is a string; start and end are optional arguments that specify a substring of string, defaulting to 0 and the length of string. This substring is conceptually replicated both up and down the index space, in both the positive and negative directions.
xsubstring returns the substring of this string beginning at index from, and ending at to. It is an error if from is greater than to.
If from and to are missing they default to 0 and from+(end-start), respectively. This variant is a generalization of using substring, but unlike substring never shares substructures that would retain characters or sequences of characters that are substructures of its first argument or previously allocated objects. (Hence it is equivalent to SRFI-135's string-copy.)
Note that
It is an error if start=end, unless from=to, which is allowed as a special case.
(srfi 140) procedure (string-split (string string?) (delimiter string?) ) ⟹ list?
(srfi 140) procedure (string-split (string string?) (delimiter string?) (grammar symbol?) ) ⟹ list?
(srfi 140) procedure (string-split (string string?) (delimiter string?) (grammar symbol?) (limit integer?) ) ⟹ list?
(srfi 140) procedure (string-split (string string?) (delimiter string?) (grammar symbol?) (limit integer?) (start integer?) ) ⟹ list?
(srfi 140) procedure (string-split (string string?) (delimiter string?) (grammar symbol?) (limit integer?) (start integer?) (end integer?) ) ⟹ list?
return ⟹ (list (str istring?) )
Returns a list of strings representing the words contained in the substring of string from start (inclusive) to end (exclusive). The delimiter is a string to be used as the word separator. This will often be a single character, but multiple characters are allowed for use cases such as splitting on "\r\n". The returned list will have one more item than the number of non-overlapping occurrences of the delimiter in the string. If delimiter is an empty string, then the returned list contains a list of strings, each of which contains a single character.
The grammar is a symbol with the same meaning as in the string-join procedure. If it is infix, which is the default, processing is done as described above, except an empty string produces the empty list; if grammar is strict-infix, then an empty string signals an error. The values prefix and suffix cause a leading/trailing empty string in the result to be suppressed.
If limit is a non-negative exact integer, at most that many splits occur, and the remainder of string is returned as the final element of the list (so the result will have at most limit+1 elements). If limit is not specified or is #f, then as many splits as possible are made. It is an error if limit is any other value.
(srfi 140) procedure (make-string ) ⟹ string?
(srfi 140) procedure (make-string (k integer?) ) ⟹ string?
(srfi 140) procedure (make-string (k integer?) (char char?) ) ⟹ string?
Return a new allocated mutable string of length k, where k defaults to 0. If char is given, then all the characters of the string are initialized to char, otherwise the contents of the string are unspecified. The 1-argument version is deprecated as poor style, except when k is 0.
To return an immutable string that repeats k times a character char use string-repeat.
This is as R7RS, except the result is variable-size and we allow leaving out k when it is zero.
(srfi 140) procedure (string-copy (string string?) ) ⟹ string?
(srfi 140) procedure (string-copy (string string?) (start integer?) ) ⟹ string?
(srfi 140) 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.
(srfi 140) 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.
(srfi 140) procedure (string-fill! (string string?) (fill char?) ) ⟹ undefined
(srfi 140) procedure (string-fill! (string string?) (fill char?) (start integer?) ) ⟹ undefined
(srfi 140) 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.
(srfi 140) procedure (string-copy! (to string?) (at integer?) (from string?) ) ⟹ undefined
(srfi 140) procedure (string-copy! (to string?) (at integer?) (from string?) (start integer?) ) ⟹ undefined
(srfi 140) 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.
(srfi 140) procedure (string-append! (string string?) (value (or char?string?)) ... ) ⟹ undefined
The string must be a variable-size mutable string. The string-append! procedure extends string by appending each value (in order) to the end of string. A value can be a character or a string.
Using a string port in this situation is probably preferable: It is more portable, and you can expect decent performance in most implementations. Using string-append! may be slighly more efficient on some implementations, due to lower overhead, but that depends on the strategy used by string-append! when the allocated buffer is too small. The string-append! function is most useful when using (reading) a string is interleaved with growing it, or when also using string-replace!.
(srfi 140) procedure (string-replace! (dst string?) (dst-start integer?) (dst-end integer?) (src string?) ) ⟹ undefined
(srfi 140) procedure (string-replace! (dst string?) (dst-start integer?) (dst-end integer?) (src string?) (src-start integer?) ) ⟹ undefined
(srfi 140) procedure (string-replace! (dst string?) (dst-start integer?) (dst-end integer?) (src string?) (src-start integer?) (src-end integer?) ) ⟹ undefined
Replaces the characters of the variable-size string dst (between dst-start and dst-end) with the characters of the string src (between src-start and src-end). The number of characters from src may be different than the number replaced in dst, so the string may grow or contract. The special case where dst-start is equal to dst-end corresponds to insertion; the case where src-start is equal to src-end corresponds to deletion. 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.)
When value is a string then (string-append! dst value) is equivalent to (string-replace! dst (string-length dst) (string-length dst) value).
library (srfi 141)
(srfi 141) procedure (floor/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(srfi 141) procedure (floor-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(srfi 141) procedure (floor-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
q = floor(n/d)
Thus a nonzero r is negative iff d is negative.
(srfi 141) procedure (ceiling/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(srfi 141) procedure (ceiling-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(srfi 141) procedure (ceiling-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
q = ceiling(n/d)
Thus a nonzero r is negative iff d is non-negative.
If denominator is the number of units in a block, and numerator; is some number of units, then (ceiling-quotient numerator denominator) gives the number of blocks needed to cover numerator units. For example, denominator might be the number of bytes in a disk sector, and numerator the number of bytes in a file; then the quotient is the number of disk sectors needed to store the contents of the file. For another example, denominator might be the number of octets in the output of a cryptographic hash function, and numerator the number of octets desired in a key for a symmetric cipher, to be derived using the cryptographic hash function; then the quotient is the number of hash values needed to concatenate to make a key.
(srfi 141) procedure (truncate/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(srfi 141) procedure (truncate-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(srfi 141) procedure (truncate-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
q = truncate(n/d)
Thus a nonzero r is negative iff n is negative. With the truncate operator pair, the quotient of +1, 0, or -1 by any non-unit denominator is 0; that is, three contiguous numerators divided by a common denominator share a common quotient. Of the other division operator pairs, only the round pair exhibits this property.
(srfi 141) procedure (round/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(srfi 141) procedure (round-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(srfi 141) procedure (round-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
q = round(n/d)
The round function rounds to the nearest integer, breaking ties by choosing the nearest even integer. Nothing general can be said about the sign of r. Like the truncate operator pair, the quotient of +1, 0, or -1 by any non-unit denominator is 0, so that three contiguous numerators by a common denominator share a common quotient.
(srfi 141) procedure (euclidean/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(srfi 141) procedure (euclidean-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(srfi 141) procedure (euclidean-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
If d > 0, q = floor(n/d); if d < 0, q = ceiling(n/d).
This division operator pair satisfies the stronger property
0 <= r < |d|,
used often in mathematics. Thus, for example, (euclidean-remainder numerator denominator) is always a valid index into a vector whose length is at least the absolute value of denominator. This division operator pair is so named because it is the subject of the Euclidean division algorithm.
(srfi 141) procedure (balanced/ (numerator integer?) (denominator integer?) ) ⟹ (values integer?integer?)
(srfi 141) procedure (balanced-quotient (numerator integer?) (denominator integer?) ) ⟹ integer?
(srfi 141) procedure (balanced-remainder (numerator integer?) (denominator integer?) ) ⟹ integer?
This division operator pair satisfies the property
-|d/2| <= r < |d/2|.
When d is a power of 2, say 2k for some k, this reduces to
-2(k - 1) <= r < 2(k - 1).
Computer scientists will immediately recognize this as the interval of integers representable in two's-complement with k bits.
library (srfi 143)
fx-width ⟹ integer?
Bound to the value w that specifies the implementation-defined range. (R6RS fixnum-width is a procedure that always returns this value.)
fx-greatest ⟹ fixnum?
Bound to the value 2^(w-1)-1, the largest representable fixnum. (R6RS greatest-fixnum is a procedure that always returns this value.)
fx-least ⟹ fixnum?
Bound to the value -2^(w-1), the smallest representable fixnum. (R6RS least-fixnum is a procedure that always returns this value.)
(srfi 143) procedure (fixnum? obj ) ⟹ boolean?
Returns #t if obj is an exact integer within the fixnum range, and #f otherwise.
(srfi 143) procedure (fx=? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to =.
(srfi 143) procedure (fx<? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to <.
(srfi 143) procedure (fx>? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to >.
(srfi 143) procedure (fx<=? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to <=.
(srfi 143) procedure (fx>=? (i fixnum?) ... ) ⟹ boolean?
Semantically equivalent to >=.
(srfi 143) procedure (fxzero? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to zero?.
(srfi 143) procedure (fxpositive? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to positive?.
(srfi 143) procedure (fxnegative? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to negative?.
(srfi 143) procedure (fxodd? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to odd?.
(srfi 143) procedure (fxeven? (i fixnum?) ) ⟹ boolean?
Semantically equivalent to even?.
(srfi 143) procedure (fxmax (i fixnum?) (j fixnum?) ... ) ⟹ fixnum?
Semantically equivalent to max.
(srfi 143) procedure (fxmin (i fixnum?) (j fixnum?) ... ) ⟹ fixnum?
Semantically equivalent to min.
(srfi 143) procedure (fx+ (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to +, but accepts exactly two arguments.
(srfi 143) procedure (fx- (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to -, but accepts exactly two arguments.
(srfi 143) procedure (fxneg (i fixnum?) ) ⟹ fixnum?
Semantically equivalent to -, but accepts exactly one argument.
(srfi 143) procedure (fx* (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to *, but accepts exactly two arguments.
(srfi 143) procedure (fxquotient (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to quotient.
(srfi 143) procedure (fxremainder (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to remainder.
(srfi 143) procedure (fxabs (i fixnum?) ) ⟹ fixnum?
Semantically equivalent to abs. In accordance with the fixnum rule, has undefined results when applied to fx-least.
(srfi 143) procedure (fxsquare (i fixnum?) ) ⟹ fixnum?
Semantically equivalent to square.
(srfi 143) procedure (fxsqrt (i fixnum?) ) ⟹ fixnum?
Semantically equivalent to exact-integer-sqrt (not sqrt).
(srfi 143) procedure (fx+/carry (i fixnum?) (j fixnum?) (k fixnum?) ) ⟹ (values fixnum?fixnum?)
Returns the two fixnum results of the following computation:
(let*-values (((s) (+ i j k))
((q r) (balanced/ s (expt 2 fx-width))))
(values r q))
(srfi 143) procedure (fx-/carry (i fixnum?) (j fixnum?) (k fixnum?) ) ⟹ (values fixnum?fixnum?)
Returns the two fixnum results of the following computation:
(let*-values (((d) (- i j k))
((q r) (balanced/ d (expt 2 fx-width))))
(values r q))
(srfi 143) procedure (fx*/carry (i fixnum?) (j fixnum?) (k fixnum?) ) ⟹ (values fixnum?fixnum?)
Returns the two fixnum results of the following computation:
(let*-values (((s) (+ (* i j) k))
((q r) (balanced/ s (expt 2 fx-width))))
(values r q))
(srfi 143) procedure (fxnot (i integer?) ) ⟹ integer?
Semantically equivalent to bitwise-not.
(srfi 143) procedure (fxand (i integer?) ... ) ⟹ integer?
Semantically equivalent to bitwise-and.
(srfi 143) procedure (fxior (i integer?) ... ) ⟹ integer?
Semantically equivalent to bitwise-ior.
(srfi 143) procedure (fxxor (i integer?) ... ) ⟹ integer?
Semantically equivalent to bitwise-xor.
(srfi 143) procedure (fxarithmetic-shift (i fixnum?) (count integer?) ) ⟹ fixnum?
Semantically equivalent to arithmetic-shift, except that it is an error for the absolute value of count to exceed w-1.
(srfi 143) procedure (fxarithmetic-shift-left (i fixnum?) (count integer?) ) ⟹ fixnum?
The same as fxarithmetic-shift except that a negative value of count is an error. This is provided for additional efficiency.
(srfi 143) procedure (fxarithmetic-shift-right (i fixnum?) (count integer?) ) ⟹ fixnum?
The same as fxarithmetic-shift except that a non-negative value of count specifies the number of bits to shift right, and a negative value is an error. This is provided for additional efficiency.
(srfi 143) procedure (fxbit-count (i fixnum?) ) ⟹ integer?
Semantically equivalent to SRFI 151 bit-count.
(srfi 143) procedure (fxlength (i fixnum?) ) ⟹ integer?
Semantically equivalent to integer-length.
(srfi 143) procedure (fxif (mask fixnum?) (i fixnum?) (j fixnum?) ) ⟹ fixnum?
Semantically equivalent to bitwise-if. It can be implemented as (fxior (fxand mask i) (fxand (fxnot mask) j))).
(srfi 143) procedure (fxbit-set? (index integer?) (i fixnum?) ) ⟹ boolean?
Semantically equivalent to SRFI 151 bit-set?, except that it is an error for index to be larger than or equal to fx-width.
(srfi 143) procedure (fxcopy-bit (index integer?) (i fixnum?) (boolean boolean?) ) ⟹ fixnum?
Semantically equivalent to SRFI 151 copy-bit, except that it is an error for index to be larger than or equal to fx-width.
(srfi 143) procedure (fxfirst-set-bit (i fixnum?) ) ⟹ integer?
Semantically equivalent to first-set-bit.
(srfi 143) procedure (fxbit-field (i fixnum?) (start integer?) (end integer?) ) ⟹ fixnum?
Semantically equivalent to bit-field.
(srfi 143) procedure (fxbit-field-rotate (i fixnum?) (count integer?) (start integer?) (end integer?) ) ⟹ fixnum?
Semantically equivalent to SRFI 151 bit-field-rotate.
(srfi 143) procedure (bit-field-reverse (i fixnum?) (start integer?) (end integer?) ) ⟹ fixnum?
Semantically equivalent to bit-field-reverse.
library (srfi 144)
fl-e ⟹ flonum?
Bound to the mathematical constant e. (C99 M_E)
fl-1/e ⟹ flonum?
Bound to 1/e. (C99 M_E)
fl-e-2 ⟹ flonum?
Bound to e^2.
fl-e-pi/4 ⟹ flonum?
Bound to e^(pi/4).
fl-log2-e ⟹ flonum?
Bound to log2 e. (C99 M_LOG2E)
fl-log10-e ⟹ flonum?
Bound to log10 e. (C99 M_LOG10E)
fl-log-2 ⟹ flonum?
Bound to loge 2. (C99 M_LN2)
fl-1/log-2 ⟹ flonum?
Bound to 1/(loge 2)
fl-log-3 ⟹ flonum?
Bound to loge 3.
fl-log-pi ⟹ flonum?
Bound to loge pi.
fl-log-10 ⟹ flonum?
Bound to loge 10. (C99 M_LN10)
fl-1/log-10 ⟹ flonum?
Bound to 1/(loge 10). (C99 M_LN10)
fl-pi ⟹ flonum?
Bound to the mathematical constant pi. (C99 M_PI)
fl-1/pi ⟹ flonum?
Bound to 1/pi. (C99 M_1_PI)
fl-2pi ⟹ flonum?
Bound to 2pi.
fl-pi/2 ⟹ flonum?
Bound to pi/2. (C99 M_PI_2)
fl-pi/4 ⟹ flonum?
Bound to pi/4. (C99 M_PI_4)
fl-pi-squared ⟹ flonum?
Bound to pi^2.
fl-degree ⟹ flonum?
Bound to pi/180, the number of radians in a degree.
fl-2/pi ⟹ flonum?
Bound to 2/pi. (C99 M_2_PI)
fl-2/sqrt-pi ⟹ flonum?
Bound to 2/(pi^0.5). (C99 M_2_SQRTPI)
fl-sqrt-2 ⟹ flonum?
Bound to 2^0.5. (C99 M_SQRT2)
fl-sqrt-3 ⟹ flonum?
Bound to 3^0.5.
fl-sqrt-5 ⟹ flonum?
Bound to 5^0.5.
fl-sqrt-10 ⟹ flonum?
Bound to 10^0.5.
fl-1/sqrt-2 ⟹ flonum?
Bound to 1/(2^0.5). (C99 M_SQRT1_2)
fl-cbrt-2 ⟹ flonum?
Bound to 2^(1/3).
fl-cbrt-3 ⟹ flonum?
Bound to 3^(1/3).
fl-4thrt-2 ⟹ flonum?
Bound to 2^(1/4).
fl-phi ⟹ flonum?
Bound to the mathematical constant φ.
fl-log-phi ⟹ flonum?
Bound to log(φ).
fl-1/log-phi ⟹ flonum?
Bound to 1/log(φ).
fl-euler ⟹ flonum?
Bound to the mathematical constant γ (Euler's constant).
fl-e-euler ⟹ flonum?
Bound to e^γ.
fl-sin-1 ⟹ flonum?
Bound to sin 1.
fl-cos-1 ⟹ flonum?
Bound to cos 1.
fl-gamma-1/2 ⟹ flonum?
Bound to Γ(1/2).
fl-gamma-1/3 ⟹ flonum?
Bound to Γ(1/3).
fl-gamma-2/3 ⟹ flonum?
Bound to Γ(2/3).
fl-greatest ⟹ flonum?
Bound to the largest positive finite flonum. (C99 DBL_MAX)
fl-least ⟹ flonum?
Bound to the smallest positive finite flonum. (C99 DBL_TRUE_MIN)
fl-epsilon ⟹ flonum?
Bound to the appropriate machine epsilon for the hardware representation of flonums. (C99 DBL_EPSILON in <float.h>)
fl-fast-fl+* ⟹ boolean?
Bound to #t if (fl+* x y z) executes about as fast as, or faster than, (fl+ (fl* x y) z); bound to #f otherwise. (C99 FP_FAST_FMA)
So that the value of this variable can be determined at compile time, R7RS implementations and other implementations that provide a features function should provide the feature fl-fast-fl+* if this variable is true, and not if it is false or the value is unknown at compile time.
fl-integer-exponent-zero ⟹ integer?
Bound to whatever exact integer is returned by (flinteger-exponent 0.0). (C99 FP_ILOGB0)
fl-integer-exponent-nan ⟹ integer?
Bound to whatever exact integer is returned by (flinteger-exponent +nan.0). (C99 FP_ILOGBNAN)
(srfi 144) procedure (flonum (number real?) ) ⟹ flonum?
If number is an inexact real number and there exists a flonum that is the same (in the sense of =) to number, returns that flonum. If number is a negative zero, an infinity, or a NaN, return its flonum equivalent. If such a flonum does not exist, returns the nearest flonum, where "nearest" is implementation-dependent. If number is not a real number, it is an error. If number is exact, applies inexact or exact->inexact to number first.
(srfi 144) procedure (fladjacent (x flonum?) (y flonum?) ) ⟹ flonum?
Returns a flonum adjacent to x in the direction of y. Specifically: if x < y, returns the smallest flonum larger than x; if x > y, returns the largest flonum smaller than x; if x = y, returns x. (C99 nextafter)
(srfi 144) procedure (flcopysign (x flonum?) (y flonum?) ) ⟹ flonum?
Returns a flonum whose magnitude is the magnitude of x and whose sign is the sign of y. (C99 copysign)
(srfi 144) procedure (make-flonum (x flonum?) (n integer?) ) ⟹ flonum?
Returns x * 2^n, where n is an integer with an implementation-dependent range. (C99 ldexp)
(srfi 144) procedure (flinteger-fraction (x flonum?) ) ⟹ (values flonum?flonum?)
Returns two values, the integral part of x as a flonum and the fractional part of x as a flonum. (C99 modf)
(srfi 144) procedure (flexponent (x flonum?) ) ⟹ flonum?
Returns the exponent of x. (C99 logb)
(srfi 144) procedure (flinteger-exponent (x flonum?) ) ⟹ integer?
Returns the same as flexponent truncated to an exact integer. If x is zero, returns fl-integer-exponent-zero; if x is a NaN, returns fl-integer-exponent-nan; if x is infinite, returns a large implementation-dependent exact integer. (C99 ilogb)
(srfi 144) procedure (flnormalized-fraction-exponent (x flonum?) ) ⟹ (values flonum?integer?)
Returns two values, a correctly signed fraction y whose absolute value is between 0.5 (inclusive) and 1.0 (exclusive), and an exact integer exponent n such that x = y(2^n). (C99 frexp)
(srfi 144) procedure (flsign-bit (x flonum?) ) ⟹ integer?
Returns 0 for positive flonums and 1 for negative flonums and -0.0. The value of (flsign-bit +nan.0) is implementation-dependent, reflecting the sign bit of the underlying representation of NaNs. (C99 signbit)
(srfi 144) procedure (flonum? obj ) ⟹ boolean?
Returns #t if obj is a flonum and #f otherwise.
(srfi 144) procedure (fl=? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
(srfi 144) procedure (fl<? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
(srfi 144) procedure (fl>? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
(srfi 144) procedure (fl<=? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
(srfi 144) procedure (fl>=? (x flonum?) (y flonum?) (z flonum?) ... ) ⟹ boolean?
These procedures return #t if their arguments are (respectively): equal, monotonically increasing, monotonically decreasing, monotonically nondecreasing, or monotonically nonincreasing; they return #f otherwise. These predicates must be transitive. (C99 =, <, > <=, >= operators respectively)
(srfi 144) procedure (flunordered? (x flonum?) (y flonum?) ) ⟹ boolean?
Returns #t if x and y are unordered according to IEEE rules. This means that one of them is a NaN.
(srfi 144) procedure (flinteger? (x flonum?) ) ⟹ boolean?
Tests whether x is an integral flonum.
(srfi 144) procedure (flzero? (x flonum?) ) ⟹ boolean?
Tests whether x is zero. Beware of roundoff errors.
(srfi 144) procedure (flpositive? (x flonum?) ) ⟹ boolean?
Tests whether x is positive.
(srfi 144) procedure (flnegative? (x flonum?) ) ⟹ boolean?
Tests whether x is negative. Note that (flnegative? -0.0) must return #f; otherwise it would lose the correspondence with (fl<? -0.0 0.0), which is #f according to IEEE 754.
(srfi 144) procedure (flodd? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is odd. It is an error if x is not an integer.
(srfi 144) procedure (fleven? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is even. It is an error if x is not an integer.
(srfi 144) procedure (flfinite? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is finite. (C99 isfinite)
(srfi 144) procedure (flinfinite? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is infinite. (C99 isinf)
(srfi 144) procedure (flnan? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is NaN. (C99 isnan)
(srfi 144) procedure (flnormalized? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is normalized. (C11 isnormal; in C99, use fpclassify(x) == FP_NORMAL)
(srfi 144) procedure (fldenormalized? (x flonum?) ) ⟹ boolean?
Tests whether the flonum x is denormalized. (C11 issubnormal; in C99, use fpclassify(x) == FP_SUBNORMAL)
(srfi 144) procedure (flmax (x flonum?) ... ) ⟹ flonum?
(srfi 144) procedure (flmin (x flonum?) ... ) ⟹ flonum?
Return the maximum/minimum argument. If there are no arguments, these procedures return -inf.0 or +inf.0 if the implementation provides these numbers, and (fl- fl-greatest) or fl-greatest otherwise. (C99 fmax fmin)
(srfi 144) procedure (fl+ (x flonum?) ... ) ⟹ flonum?
(srfi 144) procedure (fl* (x flonum?) ... ) ⟹ flonum?
Return the flonum sum or product of their flonum arguments. (C99 + * operators respectively)
(srfi 144) procedure (fl+* (x flonum?) (y flonum?) (z flonum?) ) ⟹ flonum?
Returns xy + z as if to infinite precision and rounded only once. The boolean constant fl-fast-fl+* indicates whether this procedure executes about as fast as, or faster than, a multiply and an add of flonums. (C99 fma)
(srfi 144) procedure (fl- (x flonum?) (y flonum?) ... ) ⟹ flonum?
(srfi 144) procedure (fl/ (x flonum?) (y flonum?) ... ) ⟹ flonum?
With two or more arguments, these procedures return the difference or quotient of their arguments, associating to the left. With one argument, however, they return the additive or multiplicative inverse of their argument. (C99 - / operators respectively)
(srfi 144) procedure (flabs (x flonum?) ) ⟹ flonum?
Returns the absolute value of x. (C99 fabs)
(srfi 144) procedure (flabsdiff (x flonum?) (y flonum?) ) ⟹ flonum?
Returns |x - y|.
(srfi 144) procedure (flposdiff (x flonum?) (y flonum?) ) ⟹ flonum?
Returns the difference of x and y if it is non-negative, or zero if the difference is negative. (C99 fdim)
(srfi 144) procedure (flsgn (x flonum?) ) ⟹ flonum?
Returns (flcopysign 1.0 x).
(srfi 144) procedure (flnumerator (x flonum?) ) ⟹ flonum?
(srfi 144) procedure (fldenominator (x flonum?) ) ⟹ flonum?
Returns the numerator/denominator of x as a flonum; the result is computed as if x was represented as a fraction in lowest terms. The denominator is always positive. The numerator of an infinite flonum is itself. The denominator of an infinite or zero flonum is 1.0. The numerator and denominator of a NaN is a NaN.
(srfi 144) procedure (flfloor (x flonum?) ) ⟹ flonum?
Returns the largest integral flonum not larger than x. (C99 floor)
(srfi 144) procedure (flceiling (x flonum?) ) ⟹ flonum?
Returns the smallest integral flonum not smaller than x. (C99 ceil)
(srfi 144) procedure (flround (x flonum?) ) ⟹ flonum?
Returns the closest integral flonum to x, rounding to even when x represents a number halfway between two integers. (Not the same as C99 round, which rounds away from zero)
(srfi 144) procedure (fltruncate (x flonum?) ) ⟹ flonum?
Returns the closest integral flonum to x whose absolute value is not larger than the absolute value of x (C99 trunc)
(srfi 144) procedure (flexp (x flonum?) ) ⟹ flonum?
Returns e^x. (C99 exp)
(srfi 144) procedure (flexp2 (x flonum?) ) ⟹ flonum?
Returns 2^x. (C99 exp2)
(srfi 144) procedure (flexp-1 (x flonum?) ) ⟹ flonum?
Returns e^x - 1, but is much more accurate than flexp for very small values of x. It is recommended for use in algorithms where accuracy is important. (C99 expm1)
(srfi 144) procedure (flsquare (x flonum?) ) ⟹ flonum?
Returns x^2.
(srfi 144) procedure (flsqrt (x flonum?) ) ⟹ flonum?
Returns x^0.5. For -0.0, flsqrt should return -0.0. (C99 sqrt)
(srfi 144) procedure (flcbrt (x flonum?) ) ⟹ flonum?
Returns x^(1/3). (C99 cbrt)
(srfi 144) procedure (flhypot (x flonum?) (y flonum?) ) ⟹ flonum?
Returns the length of the hypotenuse of a right triangle whose sides are of length |x| and |y|. (C99 hypot)
(srfi 144) procedure (flexpt (x flonum?) (y flonum?) ) ⟹ flonum?
Returns x^y. If x is zero, then the result is zero. (C99 pow)
(srfi 144) procedure (fllog (x flonum?) ) ⟹ flonum?
Returns loge x. (C99 log)
(srfi 144) procedure (fllog1+ (x flonum?) ) ⟹ flonum?
Returns loge (x+ 1), but is much more accurate than fllog for values of x near 0. It is recommended for use in algorithms where accuracy is important. (C99 log1p)
(srfi 144) procedure (fllog2 (x flonum?) ) ⟹ flonum?
Returns log2 x. (C99 log2)
(srfi 144) procedure (fllog10 (x flonum?) ) ⟹ flonum?
Returns log10 x. (C99 log10)
(srfi 144) procedure (make-fllog-base (base flonum?) ) ⟹ procedure?
(return (x flonum?) ) ⟹ flonum?
Returns a procedure that calculates the base-x logarithm of its argument. If x is 1.0 or less than 1.0, it is an error.
(srfi 144) procedure (flsin (x flonum?) ) ⟹ flonum?
Returns sin x. (C99 sin)
(srfi 144) procedure (flcos (x flonum?) ) ⟹ flonum?
Returns cos x. (C99 cos)
(srfi 144) procedure (fltan (x flonum?) ) ⟹ flonum?
Returns tan x. (C99 tan)
(srfi 144) procedure (flasin (x flonum?) ) ⟹ flonum?
Returns arcsin x. (C99 asin)
(srfi 144) procedure (flacos (x flonum?) ) ⟹ flonum?
Returns arccos x. (C99 acos)
(srfi 144) procedure (flatan (x flonum?) ) ⟹ flonum?
(srfi 144) procedure (flatan (y flonum?) (x flonum?) ) ⟹ flonum?
Returns arctan x. (C99 atan)
With two arguments, returns arctan(y/x). in the range [-π,π], using the signs of x and y to choose the correct quadrant for the result. (C99 atan2)
(srfi 144) procedure (flsinh (x flonum?) ) ⟹ flonum?
Returns sinh x. (C99 sinh)
(srfi 144) procedure (flcosh (x flonum?) ) ⟹ flonum?
Returns cosh x. (C99 cosh)
(srfi 144) procedure (fltanh (x flonum?) ) ⟹ flonum?
Returns tanh x. (C99 tanh)
(srfi 144) procedure (flasinh (x flonum?) ) ⟹ flonum?
Returns arcsinh x. (C99 asinh)
(srfi 144) procedure (flacosh (x flonum?) ) ⟹ flonum?
Returns arccosh x. (C99 acosh)
(srfi 144) procedure (flatanh (x flonum?) ) ⟹ flonum?
Returns arctanh x. (C99 atanh)
(srfi 144) procedure (flquotient (x flonum?) (y flonum?) ) ⟹ flonum?
Returns the quotient of x/y as an integral flonum, truncated towards zero.
(srfi 144) procedure (flremainder (x flonum?) (y flonum?) ) ⟹ flonum?
Returns the truncating remainder of x/y as an integral flonum.
(srfi 144) procedure (flremquo (x flonum?) (y flonum?) ) ⟹ (values flonum?integer?)
Returns two values, the rounded remainder of x/y and the low-order n bits (as a correctly signed exact integer) of the rounded quotient. The value of n is implementation-dependent but at least 3. This procedure can be used to reduce the argument of the inverse trigonometric functions, while preserving the correct quadrant or octant. (C99 remquo)
(srfi 144) procedure (flgamma (x flonum?) ) ⟹ flonum?
Returns Γ(x), the gamma function applied to x. This is equal to (x-1)! for integers. (C99 tgamma)
(srfi 144) procedure (flloggamma (x flonum?) ) ⟹ flonum?
Returns two values, log |Γ(x)| without internal overflow, and the sign of Γ(x) as 1.0 if it is positive and -1.0 if it is negative. (C99 lgamma)
(srfi 144) procedure (flfirst-bessel (n integer?) (x flonum?) ) ⟹ flonum?
Returns the nth order Bessel function of the first kind applied to x, Jn(x). (jn, which is an XSI Extension of C99)
(srfi 144) procedure (flsecond-bessel (n integer?) (x flonum?) ) ⟹ flonum?
Returns the nth order Bessel function of the second kind applied to x, Yn(x). (yn, which is an XSI Extension of C99)
(srfi 144) procedure (flerf (x flonum?) ) ⟹ flonum?
Returns the error function erf(x). (C99 erf)
(srfi 144) procedure (flerfc (x flonum?) ) ⟹ flonum?
Returns the complementary error function, 1 - erf(x). (C99 erfc)
library (srfi 145)
(srfi 145) syntax (assume () ((_ obj message) * ) )
This special form is an expression that evaluates to the value of obj if obj evaluates to a true value. It is an error if obj evaluates to a false value. In this case, implementations are encouraged to report this error together with the messages to the user, at least when the implementation is in debug or non-optimizing mode. In case of reporting the error, an implementation is also encouraged to report the source location of the source of the error.
library (srfi 146)
(srfi 146) procedure (mapping (comparator comparator?) arg ... ) ⟹ mapping?
Returns a newly allocated mapping. The comparator argument is a SRFI 128 comparator, which is used to control and distinguish the keys of the mapping. The args alternate between keys and values and are used to initialize the mapping. In particular, the number of args has to be even. Earlier associations with equal keys take precedence over later arguments.
(srfi 146) procedure (mapping-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (comparator comparator?) ) ⟹ mapping?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ (values **)
(successor seed ) ⟹ *
Create a newly allocated mapping as if by mapping using comparator. If the result of applying the predicate stop? to seed is true, return the mapping. Otherwise, apply the procedure mapper to seed. Mapper returns two values which are added to the mapping as the key and the value, respectively. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm. Associations earlier in the list take precedence over those that come later.
(srfi 146) procedure (mapping? obj ) ⟹ boolean?
Returns #t if obj is a mapping, and #f otherwise.
(srfi 146) procedure (mapping-contains? (mapping mapping?) key ) ⟹ boolean?
Returns #t if key is the key of an association of mapping and #f otherwise.
(srfi 146) procedure (mapping-empty? (mapping mapping?) ) ⟹ boolean?
Returns #t if mapping has no associations and #f otherwise.
(srfi 146) procedure (mapping-disjoint? (mapping1 mapping?) (mapping2 mapping?) ) ⟹ boolean?
Returns #t if mapping1 and mapping2 have no keys in common and #f otherwise.
(srfi 146) procedure (mapping-ref (mapping mapping?) key ) ⟹ *
(srfi 146) procedure (mapping-ref (mapping mapping?) key (failure procedure?) ) ⟹ *
(srfi 146) procedure (mapping-ref (mapping mapping?) key (failure procedure?) (success procedure?) ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Extracts the value associated to key in the mapping mapping, invokes the procedure success in tail context on it, and returns its result; if success is not provided, then the value itself is returned. If key is not contained in mapping and failure is supplied, then failure is invoked in tail context on no arguments and its values are returned. Otherwise, it is an error.
(srfi 146) procedure (mapping-ref/default (mapping mapping?) key default ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(mapping-ref mapping key (lambda () default))
(srfi 146) procedure (mapping-key-comparator (mapping mapping?) ) ⟹ comparator?
Returns the comparator used to compare the keys of the mapping mapping.
(srfi 146) procedure (mapping-adjoin (mapping mapping?) key1 value1 ... ) ⟹ mapping?
The mapping-adjoin procedure returns a newly allocated mapping that uses the same comparator as the mapping mapping and contains all the associations of mapping, and in addition new associations by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, the previous association prevails and the new association is skipped. It is an error to add an association to mapping whose key that does not return #t when passed to the type test procedure of the comparator.
(srfi 146) procedure (mapping-adjoin! (mapping mapping?) key1 value1 ... ) ⟹ mapping?
The mapping-adjoin! procedure is the same as mapping-adjoin, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(srfi 146) procedure (mapping-set (mapping mapping?) key1 value1 ... ) ⟹ mapping?
The mapping-set procedure returns a newly allocated mapping that uses the same comparator as the mapping mapping and contains all the associations of mapping, and in addition new associations by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, it is deleted. It is an error to add an association to mapping whose key that does not return #t when passed to the type test procedure of the comparator.
(srfi 146) procedure (mapping-set! (mapping mapping?) key1 value1 ... ) ⟹ mapping?
The mapping-set! procedure is the same as mapping-set, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(srfi 146) procedure (mapping-replace (mapping mapping?) key value ) ⟹ mapping?
The mapping-replace procedure returns a newly allocated mapping that uses the same comparator as the mapping mapping and contains all the associations of mapping except as follows: If key is equal (in the sense of mapping's comparator) to an existing key of mapping, then the association for that key is omitted and replaced the association defined by the pair key and value. If there is no such key in mapping, then mapping is returned unchanged.
(srfi 146) procedure (mapping-replace! (mapping mapping?) key value ) ⟹ mapping?
The mapping-replace! procedure is the same as mapping-replace, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(srfi 146) procedure (mapping-delete (mapping mapping?) key ... ) ⟹ mapping?
(srfi 146) procedure (mapping-delete! (mapping mapping?) key ... ) ⟹ mapping?
(srfi 146) procedure (mapping-delete-all (mapping mapping?) (keys list?) ) ⟹ mapping?
(srfi 146) procedure (mapping-delete-all! (mapping mapping?) (keys list?) ) ⟹ mapping?
The mapping-delete procedure returns a newly allocated mapping containing all the associations of the mapping mapping except for any whose keys are equal (in the sense of mapping's comparator) to one or more of the keys. Any key that is not equal to some key of the mapping is ignored.
The mapping-delete! procedure is the same as mapping-delete, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
The mapping-delete-all and mapping-delete-all! procedures are the same as mapping-delete and mapping-delete!, respectively, except that they accept a single argument which is a list of keys whose associations are to be deleted.
(srfi 146) procedure (mapping-intern (mapping mapping?) key (failure procedure?) ) ⟹ (values mapping?*)
(failure ) ⟹ *
Extracts the value associated to key in the mapping mapping, and returns mapping and the value as two values. If key is not contained in mapping, failure is invoked on no arguments. The procedure then returns two values, a newly allocated mapping that uses the same comparator as the mapping and contains all the associations of mapping, and in addition a new association mapping key to the result of invoking failure, and the result of invoking failure.
(srfi 146) procedure (mapping-intern! (mapping mapping?) key (failure procedure?) ) ⟹ (values mapping?*)
(failure ) ⟹ *
The mapping-intern! procedure is the same as mapping-intern, except that it is permitted to mutate and return the mapping argument as its first value rather than allocating a new mapping.
(srfi 146) procedure (mapping-update (mapping mapping?) key (updater procedure?) ) ⟹ mapping?
(srfi 146) procedure (mapping-update (mapping mapping?) key (updater procedure?) (failure procedure?) ) ⟹ mapping?
(srfi 146) procedure (mapping-update (mapping mapping?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ mapping?
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code
(mapping-set mapping key (updater (mapping-ref mapping key failure success)))
(srfi 146) procedure (mapping-update! (mapping mapping?) key (updater procedure?) ) ⟹ mapping?
(srfi 146) procedure (mapping-update! (mapping mapping?) key (updater procedure?) (failure procedure?) ) ⟹ mapping?
(srfi 146) procedure (mapping-update! (mapping mapping?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ mapping?
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
The mapping-update! procedure is the same as mapping-update, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(srfi 146) procedure (mapping-update/default (mapping mapping?) key (updater procedure?) default ) ⟹ mapping?
(updater value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code
(mapping-set mapping key (updater (mapping-ref/default mapping key default)))
(srfi 146) procedure (mapping-update!/default (mapping mapping?) key (updater procedure?) default ) ⟹ mapping?
(updater value ) ⟹ *
The mapping-update!/default procedure is the same as mapping-update/default, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(srfi 146) procedure (mapping-pop (mapping mapping?) ) ⟹ (values mapping?**)
(srfi 146) procedure (mapping-pop (mapping mapping?) (failure procedure?) ) ⟹ (values mapping?**)
(failure ) ⟹ (values mapping?**)
The mapping-pop procedure exported from (srfi 146) chooses the association with the least key from mapping and returns three values, a newly allocated mapping that uses the same comparator as mapping and contains all associations of mapping except the chosen one, and the key and the value of the chosen association. If mapping contains no association and failure is supplied, then failure is invoked in tail context on no arguments and its values returned. Otherwise, it is an error.
(srfi 146) procedure (mapping-pop! (mapping mapping?) ) ⟹ (values mapping?**)
(srfi 146) procedure (mapping-pop! (mapping mapping?) (failure procedure?) ) ⟹ (values mapping?**)
(failure ) ⟹ (values mapping?**)
The mapping-pop! procedure is the same as mapping-pop, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(srfi 146) procedure (mapping-search (mapping mapping?) key (failure procedure?) (success procedure?) ) ⟹ (values mapping?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert value obj ) ⟹ *
(ignore obj ) ⟹ *
(success key value (update procedure?) (remove procedure?) ) ⟹ *
(update new-key new-value obj ) ⟹ *
(remove obj ) ⟹ *
The mapping mapping is searched in order (that is in the order of the stored keys) for an association with key key. If it is not found, then the failure procedure is tail-called with two continuation arguments, insert and ignore, and is expected to tail-call one of them. If an association with key key is found, then the success procedure is tail-called with the matching key of mapping, the associated value, and two continuations, update and remove, and is expected to tail-call one of them.
It is an error if the continuation arguments are invoked, but not in tail position in the failure and success procedures. It is also an error if the failure and success procedures return to their implicit continuation without invoking one of their continuation arguments.
The effects of the continuations are as follows (where obj is any Scheme object):
In all cases, two values are returned: the possibly newly allocated mapping and obj.
(srfi 146) procedure (mapping-search! (mapping mapping?) key (failure procedure?) (success procedure?) ) ⟹ (values mapping?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert value obj ) ⟹ *
(ignore obj ) ⟹ *
(success key value (update procedure?) (remove procedure?) ) ⟹ *
(update new-key new-value obj ) ⟹ *
(remove obj ) ⟹ *
The mapping-search! procedure is the same as mapping-search, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(srfi 146) procedure (mapping-size (mapping mapping?) ) ⟹ integer?
Returns the number of associations in mapping as an exact integer.
(srfi 146) procedure (mapping-find (predicate procedure?) (mapping mapping?) (failure procedure?) ) ⟹ (values **)
(predicate key value ) ⟹ boolean?
(failure ) ⟹ *
Returns the association with the least key of the mapping mapping consisting of a key and value as two values such that predicate returns a true value when invoked with key and value as arguments, or the result of tail-calling failure with no arguments if there is none. There are no guarantees how many times and with which keys and values predicate is invoked.
(srfi 146) procedure (mapping-count (predicate procedure?) (mapping mapping?) ) ⟹ integer?
(predicate key value ) ⟹ boolean?
Returns the number of associations of the mapping mapping that satisfy predicate (in the sense of mapping-find) as an exact integer. There are no guarantees how many times and with which keys and values predicate is invoked.
(srfi 146) procedure (mapping-any? (predicate procedure?) (mapping mapping?) ) ⟹ boolean?
(predicate key value ) ⟹ boolean?
Returns #t if any association of the mapping mapping satisfies predicate (in the sense of mapping-find), or #f otherwise. There are no guarantees how many times and with which keys and values predicate is invoked.
(srfi 146) procedure (mapping-every? (predicate procedure?) (mapping mapping?) ) ⟹ boolean?
(predicate key value ) ⟹ boolean?
Returns #t if every association of the mapping mapping satisfies predicate (in the sense of mapping-find), or #f otherwise. There are no guarantees how many times and with which keys and values predicate is invoked.
(srfi 146) procedure (mapping-keys (mapping mapping?) ) ⟹ list?
Returns a newly allocated list of all the keys in increasing order in the mapping mapping.
(srfi 146) procedure (mapping-values (mapping mapping?) ) ⟹ list?
Returns a newly allocated list of all the values in increasing order of the keys in the mapping mapping.
(srfi 146) procedure (mapping-entries (mapping mapping?) ) ⟹ (values list?list?)
Returns two values, a newly allocated list of all the keys in the mapping mapping, and a newly allocated list of all the values in the mapping mapping in increasing order of the keys.
(srfi 146) procedure (mapping-map (proc procedure?) (comparator comparator?) (mapping mapping?) ) ⟹ mapping?
(proc key value ) ⟹ (values **)
Applies proc, which returns two values, on two arguments, the key and value of each association of mapping in increasing order of the keys and returns a newly allocated mapping that uses the comparator comparator, and which contains the results of the applications inserted as keys and values.
Note that, when proc defines a mapping that is not 1:1 between the keys, some of the mapped objects may be equivalent in the sense of the comparator's equality predicate, and in this case duplicate associations are omitted as in the mapping constructor. It is unpredictable which one will be preserved in the result.
(srfi 146) procedure (mapping-for-each (proc procedure?) (comparator comparator?) (mapping mapping?) ) ⟹ undefined
(proc key value ) ⟹ undefined
Invokes proc for every association in the mapping mapping in increasing order of the keys, discarding the returned values, with two arguments: the key of the association and the value of the association. Returns an unspecified value.
(srfi 146) procedure (mapping-fold (proc procedure?) nil (mapping mapping?) ) ⟹ *
(proc key value state ) ⟹ *
Invokes proc for each association of the mapping mapping in increasing order of the keys with three arguments: the key of the association, the value of the association, and an accumulated result of the previous invocation. For the first invocation, nil is used as the third argument. Returns the result of the last invocation, or nil if there was no invocation.
(srfi 146) procedure (mapping-map->list (proc procedure?) (mapping mapping?) ) ⟹ list?
(proc key value ) ⟹ *
Calls proc for every association in increasing order of the keys in the mapping mapping with two arguments: the key of the association and the value of the association. The values returned by the invocations of proc are accumulated into a list, which is returned.
(srfi 146) procedure (mapping-filter (predicate procedure?) (mapping mapping?) ) ⟹ mapping?
(predicate key value ) ⟹ boolean?
Returns a newly allocated mapping with the same comparator as the mapping mapping, containing just the associations of mapping that satisfy predicate (in the sense of mapping-find).
(srfi 146) procedure (mapping-filter! (predicate procedure?) (mapping mapping?) ) ⟹ mapping?
(predicate key value ) ⟹ boolean?
A linear update procedure that returns a mapping containing just the associations of mapping that satisfy predicate.
(srfi 146) procedure (mapping-remove (predicate procedure?) (mapping mapping?) ) ⟹ mapping?
(predicate key value ) ⟹ boolean?
Returns a newly allocated mapping with the same comparator as the mapping mapping, containing just the associations of mapping that do not satisfy predicate (in the sense of mapping-find).
(srfi 146) procedure (mapping-remove! (predicate procedure?) (mapping mapping?) ) ⟹ mapping?
(predicate key value ) ⟹ boolean?
A linear update procedure that returns a mapping containing just the associations of mapping that do not satisfy predicate.
(srfi 146) procedure (mapping-partition (predicate procedure?) (mapping mapping?) ) ⟹ (values mapping?mapping?)
(predicate key value ) ⟹ boolean?
Returns two values: a newly allocated mapping with the same comparator as the mapping mapping that contains just the associations of mapping that satisfy predicate (in the sense of mapping-find), and another newly allocated mapping, also with the same comparator, that contains just the associations of mapping that do not satisfy predicate.
(srfi 146) procedure (mapping-partition! (predicate procedure?) (mapping mapping?) ) ⟹ (values mapping?mapping?)
(predicate key value ) ⟹ boolean?
A linear update procedure that returns two mappings containing the associations of mapping that do and do not, respectively, satisfy predicate.
(srfi 146) procedure (mapping-copy (mapping mapping?) ) ⟹ mapping?
Returns a newly allocated mapping containing the associations of the mapping mapping, and using the same comparator.
(srfi 146) procedure (mapping->alist (mapping mapping?) ) ⟹ list?
Returns a newly allocated association list containing the associations of the mapping in increasing order of the keys. Each association in the list is a pair whose car is the key and whose cdr is the associated value.
(srfi 146) procedure (alist->mapping (comparator comparator?) (alist list?) ) ⟹ mapping?
Returns a newly allocated mapping, created as if by mapping using the comparator comparator, that contains the associations in the list, which consist of a pair whose car is the key and whose cdr is the value. Associations earlier in the list take precedence over those that come later.
(srfi 146) procedure (alist->mapping! (mapping mapping?) (alist list?) ) ⟹ mapping?
A linear update procedure that returns a mapping that contains the associations of both mapping and alist. Associations in the mapping and those earlier in the list take precedence over those that come later.
(srfi 146) procedure (mapping=? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if each mapping mapping contains the same associations, and #f otherwise.
Furthermore, it is explicitly not an error if mapping=? is invoked on mappings that do not share the same (key) comparator. In that case, #f is returned.
(srfi 146) procedure (mapping<? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if the set of associations of each mapping mapping other than the last is a proper subset of the following mapping, and #f otherwise.
(srfi 146) procedure (mapping>? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if the set of associations of each mapping mapping other than the last is a proper superset of the following mapping, and #f otherwise.
(srfi 146) procedure (mapping<=? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if the set of associations of each mapping mapping other than the last is a subset of the following mapping, and #f otherwise.
(srfi 146) procedure (mapping>=? (comparator comparator?) (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ boolean?
Returns #t if the set of associations of each mapping mapping other than the last is a superset of the following mapping, and #f otherwise.
(srfi 146) procedure (mapping-union (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(srfi 146) procedure (mapping-intersection (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(srfi 146) procedure (mapping-difference (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(srfi 146) procedure (mapping-xor (mapping1 mapping?) (mapping2 mapping?) ) ⟹ mapping?
Return a newly allocated mapping whose set of associations is the union, intersection, asymmetric difference, or symmetric difference of the sets of associations of the mappings mappings. Asymmetric difference is extended to more than two mappings by taking the difference between the first mapping and the union of the others. Symmetric difference is not extended beyond two mappings. When comparing associations, only the keys are compared. In case of duplicate keys (in the sense of the mappings comparators), associations in the result mapping are drawn from the first mapping in which they appear.
(srfi 146) procedure (mapping-union! (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(srfi 146) procedure (mapping-intersection! (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(srfi 146) procedure (mapping-difference! (mapping1 mapping?) (mapping2 mapping?) ... ) ⟹ mapping?
(srfi 146) procedure (mapping-xor! (mapping1 mapping?) (mapping2 mapping?) ) ⟹ mapping?
These procedures are the linear update analogs of the corresponding pure functional procedures above.
(srfi 146) procedure (mapping/ordered (comparator comparator?) arg ... ) ⟹ mapping?
(srfi 146) procedure (mapping-unfold/ordered (stop? procedure?) (mapper procedure?) (successor procedure?) seed (comparator comparator?) ) ⟹ mapping?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ (values **)
(successor seed ) ⟹ *
These are the same as mapping and mapping-unfold, except that it is an error if the keys are not in order, and they may be more efficient.
(srfi 146) procedure (alist->mapping/ordered (comparator comparator?) (alist list?) ) ⟹ mapping?
(srfi 146) procedure (alist->mapping/ordered! (mapping mapping?) (alist list?) ) ⟹ mapping?
These are the same as alist->mapping and alist->mapping!, except that it is an error if the keys are not in order, and they may be more efficient.
(srfi 146) procedure (mapping-min-key (mapping mapping?) ) ⟹ *
(srfi 146) procedure (mapping-max-key (mapping mapping?) ) ⟹ *
Returns the least/greatest key contained in the mapping mapping. It is an error for mapping to be empty.
(srfi 146) procedure (mapping-min-value (mapping mapping?) ) ⟹ *
(srfi 146) procedure (mapping-max-value (mapping mapping?) ) ⟹ *
Returns the value associated with the least/greatest key contained in the mapping mapping. It is an error for mapping to be empty.
(srfi 146) procedure (mapping-min-entry (mapping mapping?) ) ⟹ (values **)
(srfi 146) procedure (mapping-max-entry (mapping mapping?) ) ⟹ (values **)
Returns the entry associated with the least/greatest key contained in the mapping mapping as two values, the key and its associated value. It is an error for mapping to be empty.
(srfi 146) procedure (mapping-key-predecessor (mapping mapping?) obj (failure procedure?) ) ⟹ *
(failure ) ⟹ *
(srfi 146) procedure (mapping-key-successor (mapping mapping?) obj (failure procedure?) ) ⟹ *
(failure ) ⟹ *
Returns the key contained in the mapping mapping that immediately precedes/succeeds obj in the mapping's order of keys. If no such key is contained in mapping (because obj is the minimum/maximum key, or because mapping is empty), returns the result of tail-calling the thunk failure.
(srfi 146) procedure (mapping-range= (mapping mapping?) obj ) ⟹ mapping?
(srfi 146) procedure (mapping-range< (mapping mapping?) obj ) ⟹ mapping?
(srfi 146) procedure (mapping-range> (mapping mapping?) obj ) ⟹ mapping?
(srfi 146) procedure (mapping-range<= (mapping mapping?) obj ) ⟹ mapping?
(srfi 146) procedure (mapping-range>= (mapping mapping?) obj ) ⟹ mapping?
Returns a mapping containing only the associations of the mapping whose keys are equal to, less than, greater than, less than or equal to, or greater than or equal to obj.
(srfi 146) procedure (mapping-range=! (mapping mapping?) obj ) ⟹ mapping?
(srfi 146) procedure (mapping-range<! (mapping mapping?) obj ) ⟹ mapping?
(srfi 146) procedure (mapping-range>! (mapping mapping?) obj ) ⟹ mapping?
(srfi 146) procedure (mapping-range<=! (mapping mapping?) obj ) ⟹ mapping?
(srfi 146) procedure (mapping-range>=! (mapping mapping?) obj ) ⟹ mapping?
Linear update procedures returning a mapping containing only the associations of the mapping whose keys are equal to, less than, greater than, less than or equal to, or greater than or equal to obj.
(srfi 146) procedure (mapping-split (mapping mapping?) obj ) ⟹ (values mapping?mapping?mapping?mapping?mapping?)
Returns five values, equivalent to the results of invoking (mapping-range< mapping obj), (mapping-range<= mapping obj), (mapping-range= mapping obj), (mapping-range>= mapping obj), and (mapping-range> mapping obj), but may be more efficient.
(srfi 146) procedure (mapping-split! (mapping mapping?) obj ) ⟹ (values mapping?mapping?mapping?mapping?mapping?)
The mapping-split! procedure is the same as mapping-split, except that it is permitted to mutate and return the mapping rather than allocating a new mapping.
(srfi 146) procedure (mapping-catenate (mapping1 mapping?) key value (mapping2 mapping?) ) ⟹ mapping?
Returns a newly allocated mapping using the comparator comparator whose set of associations is the union of the sets of associations of the mapping mapping1, the association mapping key to value, and the associations of mapping2. It is an error if the keys contained in mapping1 in their natural order, the key key, and the keys contained in mapping2 in their natural order (in that order) do not form a strictly monotone sequence with respect to the ordering of comparator.
(srfi 146) procedure (mapping-catenate! (mapping1 mapping?) key value (mapping2 mapping?) ) ⟹ mapping?
The mapping-catenate! procedure is the same as mapping-catenate, except that it is permitted to mutate and return one of the mappings rather than allocating a new mapping.
(srfi 146) procedure (mapping-map/monotone (proc procedure?) (comparator comparator?) (mapping mapping?) ) ⟹ mapping?
(proc key value ) ⟹ (values **)
Equivalent to (mapping-map proc comparator mapping), but it is an error if proc does not induce a strictly monotone mapping between the keys with respect to the ordering of the comparator of mapping and the ordering of comparator. Maybe be implemented more efficiently than mapping-map.
(srfi 146) procedure (mapping-map/monotone! (proc procedure?) (comparator comparator?) (mapping mapping?) ) ⟹ mapping?
(proc key value ) ⟹ (values **)
The mapping-map/monotone! procedure is the same as mapping-map/monotone, except that it is permitted to mutate and return the mapping argument rather than allocating a new mapping.
(srfi 146) procedure (mapping-fold/reverse (proc procedure?) nil (mapping mapping?) ) ⟹ *
(proc key value state ) ⟹ *
Equivalent to (mapping-fold proc nil mapping) except that the associations are processed in reverse order with respect to the natural ordering of the keys.
(srfi 146) procedure (comparator? obj ) ⟹ boolean?
Type predicate for comparators as exported by (srfi 128).
(srfi 146) procedure (make-mapping-comparator (comparator comparator?) ) ⟹ comparator?
Returns a comparator for mappings that is compatible with the equality predicate (mapping=? comparator mapping1 mapping2). It provides a (partial) ordering predicate that is applicable to pairs of mappings with the same (key) comparator. The lexicographic ordering with respect to the keys (and, in case a tiebreak is necessary, with respect to the ordering of the values) is used for mappings sharing a comparator. The existence of comparators returned by make-mapping-comparator allows mappings whose keys are mappings themselves, and it allows to compare mappings whose values are mappings.
mapping-comparator ⟹ comparator?
mapping-comparator is constructed by invoking make-mapping-comparator on (make-default-comparator).
library (srfi 146 hash)
(srfi 146 hash) procedure (hashmap (comparator comparator?) arg ... ) ⟹ hashmap?
Returns a newly allocated hashmap. The comparator argument is a SRFI 128 comparator, which is used to control and distinguish the keys of the hashmap. The args alternate between keys and values and are used to initialize the hashmap. In particular, the number of args has to be even. Earlier associations with equal keys take precedence over later arguments.
(srfi 146 hash) procedure (hashmap-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (comparator comparator?) ) ⟹ hashmap?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ (values **)
(successor seed ) ⟹ *
Create a newly allocated hashmap as if by hashmap using comparator. If the result of applying the predicate stop? to seed is true, return the hashmap. Otherwise, apply the procedure mapper to seed. Mapper returns two values which are added to the hashmap as the key and the value, respectively. Then get a new seed by applying the procedure successor to seed, and repeat this algorithm. Associations earlier in the list take precedence over those that come later.
(srfi 146 hash) procedure (hashmap? obj ) ⟹ boolean?
Returns #t if obj is a hashmap, and #f otherwise.
(srfi 146 hash) procedure (hashmap-contains? (hashmap hashmap?) key ) ⟹ boolean?
Returns #t if key is the key of an association of hashmap and #f otherwise.
(srfi 146 hash) procedure (hashmap-empty? (hashmap hashmap?) ) ⟹ boolean?
Returns #t if hashmap has no associations and #f otherwise.
(srfi 146 hash) procedure (hashmap-disjoint? (hashmap1 hashmap?) (hashmap2 hashmap?) ) ⟹ boolean?
Returns #t if hashmap1 and hashmap2 have no keys in common and #f otherwise.
(srfi 146 hash) procedure (hashmap-ref (hashmap hashmap?) key ) ⟹ *
(srfi 146 hash) procedure (hashmap-ref (hashmap hashmap?) key (failure procedure?) ) ⟹ *
(srfi 146 hash) procedure (hashmap-ref (hashmap hashmap?) key (failure procedure?) (success procedure?) ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Extracts the value associated to key in the hashmap hashmap, invokes the procedure success in tail context on it, and returns its result; if success is not provided, then the value itself is returned. If key is not contained in hashmap and failure is supplied, then failure is invoked in tail context on no arguments and its values are returned. Otherwise, it is an error.
(srfi 146 hash) procedure (hashmap-ref/default (hashmap hashmap?) key default ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code:
(hashmap-ref hashmap key (lambda () default))
(srfi 146 hash) procedure (hashmap-key-comparator (hashmap hashmap?) ) ⟹ comparator?
Returns the comparator used to compare the keys of the hashmap hashmap.
(srfi 146 hash) procedure (hashmap-adjoin (hashmap hashmap?) key1 value1 ... ) ⟹ hashmap?
The hashmap-adjoin procedure returns a newly allocated hashmap that uses the same comparator as the hashmap hashmap and contains all the associations of hashmap, and in addition new associations by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, the previous association prevails and the new association is skipped. It is an error to add an association to hashmap whose key that does not return #t when passed to the type test procedure of the comparator.
(srfi 146 hash) procedure (hashmap-adjoin! (hashmap hashmap?) key1 value1 ... ) ⟹ hashmap?
The hashmap-adjoin! procedure is the same as hashmap-adjoin, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(srfi 146 hash) procedure (hashmap-set (hashmap hashmap?) key1 value1 ... ) ⟹ hashmap?
The hashmap-set procedure returns a newly allocated hashmap that uses the same comparator as the hashmap hashmap and contains all the associations of hashmap, and in addition new associations by processing the arguments from left to right. The args alternate between keys and values. Whenever there is a previous association for a key, it is deleted. It is an error to add an association to hashmap whose key that does not return #t when passed to the type test procedure of the comparator.
(srfi 146 hash) procedure (hashmap-set! (hashmap hashmap?) key1 value1 ... ) ⟹ hashmap?
The hashmap-set! procedure is the same as hashmap-set, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(srfi 146 hash) procedure (hashmap-replace (hashmap hashmap?) key value ) ⟹ hashmap?
The hashmap-replace procedure returns a newly allocated hashmap that uses the same comparator as the hashmap hashmap and contains all the associations of hashmap except as follows: If key is equal (in the sense of hashmap's comparator) to an existing key of hashmap, then the association for that key is omitted and replaced the association defined by the pair key and value. If there is no such key in hashmap, then hashmap is returned unchanged.
(srfi 146 hash) procedure (hashmap-replace! (hashmap hashmap?) key value ) ⟹ hashmap?
The hashmap-replace! procedure is the same as hashmap-replace, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(srfi 146 hash) procedure (hashmap-delete (hashmap hashmap?) key ... ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-delete! (hashmap hashmap?) key ... ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-delete-all (hashmap hashmap?) (keys list?) ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-delete-all! (hashmap hashmap?) (keys list?) ) ⟹ hashmap?
The hashmap-delete procedure returns a newly allocated hashmap containing all the associations of the hashmap hashmap except for any whose keys are equal (in the sense of hashmap's comparator) to one or more of the keys. Any key that is not equal to some key of the hashmap is ignored.
The hashmap-delete! procedure is the same as hashmap-delete, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
The hashmap-delete-all and hashmap-delete-all! procedures are the same as hashmap-delete and hashmap-delete!, respectively, except that they accept a single argument which is a list of keys whose associations are to be deleted.
(srfi 146 hash) procedure (hashmap-intern (hashmap hashmap?) key (failure procedure?) ) ⟹ (values hashmap?*)
(failure ) ⟹ *
Extracts the value associated to key in the hashmap hashmap, and returns hashmap and the value as two values. If key is not contained in hashmap, failure is invoked on no arguments. The procedure then returns two values, a newly allocated hashmap that uses the same comparator as the hashmap and contains all the associations of hashmap, and in addition a new association hashmap key to the result of invoking failure, and the result of invoking failure.
(srfi 146 hash) procedure (hashmap-intern! (hashmap hashmap?) key (failure procedure?) ) ⟹ (values hashmap?*)
(failure ) ⟹ *
The hashmap-intern! procedure is the same as hashmap-intern, except that it is permitted to mutate and return the hashmap argument as its first value rather than allocating a new hashmap.
(srfi 146 hash) procedure (hashmap-update (hashmap hashmap?) key (updater procedure?) ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-update (hashmap hashmap?) key (updater procedure?) (failure procedure?) ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-update (hashmap hashmap?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ hashmap?
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code
(hashmap-set hashmap key (updater (hashmap-ref hashmap key failure success)))
(srfi 146 hash) procedure (hashmap-update! (hashmap hashmap?) key (updater procedure?) ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-update! (hashmap hashmap?) key (updater procedure?) (failure procedure?) ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-update! (hashmap hashmap?) key (updater procedure?) (failure procedure?) (success procedure?) ) ⟹ hashmap?
(updater value ) ⟹ *
(failure ) ⟹ *
(success value ) ⟹ *
The hashmap-update! procedure is the same as hashmap-update, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(srfi 146 hash) procedure (hashmap-update/default (hashmap hashmap?) key (updater procedure?) default ) ⟹ hashmap?
(updater value ) ⟹ *
Semantically equivalent to, but may be more efficient than, the following code
(hashmap-set hashmap key (updater (hashmap-ref/default hashmap key default)))
(srfi 146 hash) procedure (hashmap-update!/default (hashmap hashmap?) key (updater procedure?) default ) ⟹ hashmap?
(updater value ) ⟹ *
The hashmap-update!/default procedure is the same as hashmap-update/default, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(srfi 146 hash) procedure (hashmap-pop (hashmap hashmap?) ) ⟹ (values hashmap?**)
(srfi 146 hash) procedure (hashmap-pop (hashmap hashmap?) (failure procedure?) ) ⟹ (values hashmap?**)
(failure ) ⟹ (values hashmap?**)
The hashmap-pop procedure exported from (srfi 146 hash) chooses arbitrary association from hashmap and returns three values, a newly allocated hashmap that uses the same comparator as hashmap and contains all associations of hashmap except the chosen one, and the key and the value of the chosen association. If hashmap contains no association and failure is supplied, then failure is invoked in tail context on no arguments and its values returned. Otherwise, it is an error.
(srfi 146 hash) procedure (hashmap-pop! (hashmap hashmap?) ) ⟹ (values hashmap?**)
(srfi 146 hash) procedure (hashmap-pop! (hashmap hashmap?) (failure procedure?) ) ⟹ (values hashmap?**)
(failure ) ⟹ (values hashmap?**)
The hashmap-pop! procedure is the same as hashmap-pop, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(srfi 146 hash) procedure (hashmap-search (hashmap hashmap?) key (failure procedure?) (success procedure?) ) ⟹ (values hashmap?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert value obj ) ⟹ *
(ignore obj ) ⟹ *
(success key value (update procedure?) (remove procedure?) ) ⟹ *
(update new-key new-value obj ) ⟹ *
(remove obj ) ⟹ *
The hashmap hashmap is searched in arbitrary order for an association with key key. If it is not found, then the failure procedure is tail-called with two continuation arguments, insert and ignore, and is expected to tail-call one of them. If an association with key key is found, then the success procedure is tail-called with the matching key of hashmap, the associated value, and two continuations, update and remove, and is expected to tail-call one of them.
It is an error if the continuation arguments are invoked, but not in tail position in the failure and success procedures. It is also an error if the failure and success procedures return to their implicit continuation without invoking one of their continuation arguments.
The effects of the continuations are as follows (where obj is any Scheme object):
In all cases, two values are returned: the possibly newly allocated hashmap and obj.
(srfi 146 hash) procedure (hashmap-search! (hashmap hashmap?) key (failure procedure?) (success procedure?) ) ⟹ (values hashmap?*)
(failure (insert procedure?) (ignore procedure?) ) ⟹ *
(insert value obj ) ⟹ *
(ignore obj ) ⟹ *
(success key value (update procedure?) (remove procedure?) ) ⟹ *
(update new-key new-value obj ) ⟹ *
(remove obj ) ⟹ *
The hashmap-search! procedure is the same as hashmap-search, except that it is permitted to mutate and return the hashmap argument rather than allocating a new hashmap.
(srfi 146 hash) procedure (hashmap-size (hashmap hashmap?) ) ⟹ integer?
Returns the number of associations in hashmap as an exact integer.
(srfi 146 hash) procedure (hashmap-find (predicate procedure?) (hashmap hashmap?) (failure procedure?) ) ⟹ (values **)
(predicate key value ) ⟹ boolean?
(failure ) ⟹ *
Returns arbitrary association of the hashmap hashmap consisting of a key and value as two values such that predicate returns a true value when invoked with key and value as arguments, or the result of tail-calling failure with no arguments if there is none. There are no guarantees how many times and with which keys and values predicate is invoked.
(srfi 146 hash) procedure (hashmap-count (predicate procedure?) (hashmap hashmap?) ) ⟹ integer?
(predicate key value ) ⟹ boolean?
Returns the number of associations of the hashmap hashmap that satisfy predicate (in the sense of hashmap-find) as an exact integer. There are no guarantees how many times and with which keys and values predicate is invoked.
(srfi 146 hash) procedure (hashmap-any? (predicate procedure?) (hashmap hashmap?) ) ⟹ boolean?
(predicate key value ) ⟹ boolean?
Returns #t if any association of the hashmap hashmap satisfies predicate (in the sense of hashmap-find), or #f otherwise. There are no guarantees how many times and with which keys and values predicate is invoked.
(srfi 146 hash) procedure (hashmap-every? (predicate procedure?) (hashmap hashmap?) ) ⟹ boolean?
(predicate key value ) ⟹ boolean?
Returns #t if every association of the hashmap hashmap satisfies predicate (in the sense of hashmap-find), or #f otherwise. There are no guarantees how many times and with which keys and values predicate is invoked.
(srfi 146 hash) procedure (hashmap-keys (hashmap hashmap?) ) ⟹ list?
Returns a newly allocated list of all the keys in arbitrary order in the hashmap hashmap.
(srfi 146 hash) procedure (hashmap-values (hashmap hashmap?) ) ⟹ list?
Returns a newly allocated list of all the values in arbitrary order of the keys in the hashmap hashmap.
(srfi 146 hash) procedure (hashmap-entries (hashmap hashmap?) ) ⟹ (values list?list?)
Returns two values, a newly allocated list of all the keys in the hashmap hashmap, and a newly allocated list of all the values in the hashmap hashmap in arbitrary but consistent order.
(srfi 146 hash) procedure (hashmap-map (proc procedure?) (comparator comparator?) (hashmap hashmap?) ) ⟹ hashmap?
(proc key value ) ⟹ (values **)
Applies proc, which returns two values, on two arguments, the key and value of each association of hashmap in arbitrary order and returns a newly allocated hashmap that uses the comparator comparator, and which contains the results of the applications inserted as keys and values.
Note that, when proc defines a hashmap that is not 1:1 between the keys, some of the mapped objects may be equivalent in the sense of the comparator's equality predicate, and in this case duplicate associations are omitted as in the hashmap constructor. It is unpredictable which one will be preserved in the result.
(srfi 146 hash) procedure (hashmap-for-each (proc procedure?) (comparator comparator?) (hashmap hashmap?) ) ⟹ undefined
(proc key value ) ⟹ undefined
Invokes proc for every association in the hashmap hashmap in arbitrary order, discarding the returned values, with two arguments: the key of the association and the value of the association. Returns an unspecified value.
(srfi 146 hash) procedure (hashmap-fold (proc procedure?) nil (hashmap hashmap?) ) ⟹ *
(proc key value state ) ⟹ *
Invokes proc for each association of the hashmap hashmap in arbitrary order with three arguments: the key of the association, the value of the association, and an accumulated result of the previous invocation. For the first invocation, nil is used as the third argument. Returns the result of the last invocation, or nil if there was no invocation.
(srfi 146 hash) procedure (hashmap-map->list (proc procedure?) (hashmap hashmap?) ) ⟹ list?
(proc key value ) ⟹ *
Calls proc for every association in arbitrary order in the hashmap hashmap with two arguments: the key of the association and the value of the association. The values returned by the invocations of proc are accumulated into a list, which is returned.
(srfi 146 hash) procedure (hashmap-filter (predicate procedure?) (hashmap hashmap?) ) ⟹ hashmap?
(predicate key value ) ⟹ boolean?
Returns a newly allocated hashmap with the same comparator as the hashmap hashmap, containing just the associations of hashmap that satisfy predicate (in the sense of hashmap-find).
(srfi 146 hash) procedure (hashmap-filter! (predicate procedure?) (hashmap hashmap?) ) ⟹ hashmap?
(predicate key value ) ⟹ boolean?
A linear update procedure that returns a hashmap containing just the associations of hashmap that satisfy predicate.
(srfi 146 hash) procedure (hashmap-remove (predicate procedure?) (hashmap hashmap?) ) ⟹ hashmap?
(predicate key value ) ⟹ boolean?
Returns a newly allocated hashmap with the same comparator as the hashmap hashmap, containing just the associations of hashmap that do not satisfy predicate (in the sense of hashmap-find).
(srfi 146 hash) procedure (hashmap-remove! (predicate procedure?) (hashmap hashmap?) ) ⟹ hashmap?
(predicate key value ) ⟹ boolean?
A linear update procedure that returns a hashmap containing just the associations of hashmap that do not satisfy predicate.
(srfi 146 hash) procedure (hashmap-partition (predicate procedure?) (hashmap hashmap?) ) ⟹ (values hashmap?hashmap?)
(predicate key value ) ⟹ boolean?
Returns two values: a newly allocated hashmap with the same comparator as the hashmap hashmap that contains just the associations of hashmap that satisfy predicate (in the sense of hashmap-find), and another newly allocated hashmap, also with the same comparator, that contains just the associations of hashmap that do not satisfy predicate.
(srfi 146 hash) procedure (hashmap-partition! (predicate procedure?) (hashmap hashmap?) ) ⟹ (values hashmap?hashmap?)
(predicate key value ) ⟹ boolean?
A linear update procedure that returns two hashmaps containing the associations of hashmap that do and do not, respectively, satisfy predicate.
(srfi 146 hash) procedure (hashmap-copy (hashmap hashmap?) ) ⟹ hashmap?
Returns a newly allocated hashmap containing the associations of the hashmap hashmap, and using the same comparator.
(srfi 146 hash) procedure (hashmap->alist (hashmap hashmap?) ) ⟹ list?
Returns a newly allocated association list containing the associations of the hashmap in arbitrary order. Each association in the list is a pair whose car is the key and whose cdr is the associated value.
(srfi 146 hash) procedure (alist->hashmap (comparator comparator?) (alist list?) ) ⟹ hashmap?
Returns a newly allocated hashmap, created as if by hashmap using the comparator comparator, that contains the associations in the list, which consist of a pair whose car is the key and whose cdr is the value. Associations earlier in the list take precedence over those that come later.
(srfi 146 hash) procedure (alist->hashmap! (hashmap hashmap?) (alist list?) ) ⟹ hashmap?
A linear update procedure that returns a hashmap that contains the associations of both hashmap and alist. Associations in the hashmap and those earlier in the list take precedence over those that come later.
(srfi 146 hash) procedure (hashmap=? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if each hashmap hashmap contains the same associations, and #f otherwise.
Furthermore, it is explicitly not an error if hashmap=? is invoked on hashmaps that do not share the same (key) comparator. In that case, #f is returned.
(srfi 146 hash) procedure (hashmap<? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if the set of associations of each hashmap hashmap other than the last is a proper subset of the following hashmap, and #f otherwise.
(srfi 146 hash) procedure (hashmap>? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if the set of associations of each hashmap hashmap other than the last is a proper superset of the following hashmap, and #f otherwise.
(srfi 146 hash) procedure (hashmap<=? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if the set of associations of each hashmap hashmap other than the last is a subset of the following hashmap, and #f otherwise.
(srfi 146 hash) procedure (hashmap>=? (comparator comparator?) (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ boolean?
Returns #t if the set of associations of each hashmap hashmap other than the last is a superset of the following hashmap, and #f otherwise.
(srfi 146 hash) procedure (hashmap-union (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-intersection (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-difference (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-xor (hashmap1 hashmap?) (hashmap2 hashmap?) ) ⟹ hashmap?
Return a newly allocated hashmap whose set of associations is the union, intersection, asymmetric difference, or symmetric difference of the sets of associations of the hashmaps hashmaps. Asymmetric difference is extended to more than two hashmaps by taking the difference between the first hashmap and the union of the others. Symmetric difference is not extended beyond two hashmaps. When comparing associations, only the keys are compared. In case of duplicate keys (in the sense of the hashmaps comparators), associations in the result hashmap are drawn from the first hashmap in which they appear.
(srfi 146 hash) procedure (hashmap-union! (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-intersection! (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-difference! (hashmap1 hashmap?) (hashmap2 hashmap?) ... ) ⟹ hashmap?
(srfi 146 hash) procedure (hashmap-xor! (hashmap1 hashmap?) (hashmap2 hashmap?) ) ⟹ hashmap?
These procedures are the linear update analogs of the corresponding pure functional procedures above.
(srfi 146 hash) procedure (comparator? obj ) ⟹ boolean?
Type predicate for comparators as exported by (srfi 128).
(srfi 146 hash) procedure (make-hashmap-comparator (comparator comparator?) ) ⟹ comparator?
Returns a comparator for hashmaps that is compatible with the equality predicate (hashmap=? comparator hashmap1 hashmap2). It provides an implementation-dependent hash function. The existence of comparators returned by make-hashmap-comparator allows hashmaps whose keys are hashmaps themselves, and it allows to compare hashmaps whose values are hashmaps.
hashmap-comparator ⟹ comparator?
hashmap-comparator is constructed by invoking make-hashmap-comparator on (make-default-comparator).
library (srfi 151)
(srfi 151) procedure (bitwise-not (i integer?) ) ⟹ integer?
Returns the bitwise complement of i; that is, all 1 bits are changed to 0 bits and all 0 bits to 1 bits.
(srfi 151) procedure (bitwise-and (i integer?) ... ) ⟹ integer?
(srfi 151) procedure (bitwise-ior (i integer?) ... ) ⟹ integer?
(srfi 151) procedure (bitwise-xor (i integer?) ... ) ⟹ integer?
(srfi 151) procedure (bitwise-eqv (i integer?) ... ) ⟹ integer?
For each function, the corresponding bitwise operator maps that function across a pair of bitstrings in a bit-wise fashion. These operations are associative. When passed no arguments, the procedures return the identity values -1, 0, 0, and -1 respectively.
(srfi 151) procedure (bitwise-nand (i integer?) (j integer?) ) ⟹ integer?
(srfi 151) procedure (bitwise-nor (i integer?) (j integer?) ) ⟹ integer?
(srfi 151) procedure (bitwise-andc1 (i integer?) (j integer?) ) ⟹ integer?
(srfi 151) procedure (bitwise-andc2 (i integer?) (j integer?) ) ⟹ integer?
(srfi 151) procedure (bitwise-orc1 (i integer?) (j integer?) ) ⟹ integer?
(srfi 151) procedure (bitwise-orc2 (i integer?) (j integer?) ) ⟹ integer?
For each function, the corresponding bitwise operator maps that function across a pair of bitstrings in a bit-wise fashion. These operations are not associative.
(srfi 151) procedure (arithmetic-shift (i integer?) (count integer?) ) ⟹ integer?
Returns the arithmetic left shift when count>0; right shift when count<0.
(srfi 151) procedure (bit-count (i integer?) ) ⟹ integer?
Returns the population count of 1's (i >= 0) or 0's (i < 0). The result is always non-negative.
(srfi 151) procedure (integer-length (i integer?) ) ⟹ integer?
The number of bits needed to represent i
(srfi 151) procedure (bitwise-if (mask integer?) (i integer?) (j integer?) ) ⟹ integer?
Merge the bitstrings i and j, with bitstring mask determining from which string to take each bit. That is, if the kth bit of mask is 1, then the kth bit of the result is the kth bit of i, otherwise the kth bit of j.
(srfi 151) procedure (bit-set? (index integer?) (i integer?) ) ⟹ boolean?
Is bit index set in bitstring i (where index is a non-negative exact integer)?
(srfi 151) procedure (copy-bit (index integer?) (i integer?) (boolean boolean?) ) ⟹ integer?
Returns an integer the same as i except in the indexth bit, which is 1 if boolean is #t and 0 if boolean is #f.
(srfi 151) procedure (bit-swap (index1 integer?) (index2 integer?) (i integer?) ) ⟹ integer?
Returns an integer the same as i except that the index1th bit and the index2th bit have been exchanged.
(srfi 151) procedure (any-bit-set? (test-bits integer?) (i integer?) ) ⟹ boolean?
(srfi 151) procedure (every-bit-set? (test-bits integer?) (i integer?) ) ⟹ boolean?
Determines if any/all of the bits set in bitstring test-bits are set in bitstring i. I.e., returns (not (zero? (bitwise-and test-bits i))) and (= test-bits (bitwise-and test-bits i))) respectively.
(srfi 151) procedure (first-set-bit (i integer?) ) ⟹ integer?
Return the index of the first (smallest index) 1 bit in bitstring i. Return -1 if i contains no 1 bits (i.e., if i is zero).
(srfi 151) procedure (bit-field (i integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns the field from i, shifted down to the least-significant position in the result.
(srfi 151) procedure (bit-field-any? (i integer?) (start integer?) (end integer?) ) ⟹ boolean?
Returns true if any of the field's bits are set in bitstring i, and false otherwise.
(srfi 151) procedure (bit-field-every? (i integer?) (start integer?) (end integer?) ) ⟹ boolean?
Returns false if any of the field's bits are not set in bitstring i, and true otherwise.
(srfi 151) procedure (bit-field-clear (i integer?) (start integer?) (end integer?) ) ⟹ integer?
(srfi 151) procedure (bit-field-set (i integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns i with the field's bits set to all 0s/1s.
(srfi 151) procedure (bit-field-replace (dest integer?) (source integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns dest with the field replaced by the least-significant end-start bits in source.
(srfi 151) procedure (bit-field-replace-same (dest integer?) (source integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns dest with its field replaced by the corresponding field in source.
(srfi 151) procedure (bit-field-rotate (i integer?) (count integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns i with the field cyclically permuted by count bits towards high-order.
(srfi 151) procedure (bit-field-reverse (i integer?) (start integer?) (end integer?) ) ⟹ integer?
Returns i with the order of the bits in the field reversed.
(srfi 151) procedure (bits->list (i integer?) ) ⟹ list?
(srfi 151) procedure (bits->list (i integer?) (len integer?) ) ⟹ list?
return ⟹ (list (b boolean?) )
(srfi 151) procedure (bits->vector (i integer?) ) ⟹ vector?
(srfi 151) procedure (bits->vector (i integer?) (len integer?) ) ⟹ vector?
return ⟹ (vector (b boolean?) )
Returns a list/vector of len booleans corresponding to each bit of the non-negative integer i, returning bit #0 as the first element, bit #1 as the second, and so on. #t is returned for each 1; #f for 0.
(srfi 151) procedure (list->bits (list list?) ) ⟹ integer?
list ⟹ (list (b boolean?) )
(srfi 151) procedure (vector->bits (vector vector?) ) ⟹ integer?
vector ⟹ (vector (b boolean?) )
Returns an integer formed from the booleans in list/vector, using the first element as bit #0, the second element as bit #1, and so on. It is an error if list/vector contains non-booleans. A 1 bit is coded for each #t; a 0 bit for #f. Note that the result is never a negative integer.
(srfi 151) procedure (bits (bool boolean?) ... ) ⟹ integer?
Returns the integer coded by the bool arguments. The first argument is bit #0, the second argument is bit #1, and so on. Note that the result is never a negative integer.
(srfi 151) procedure (bitwise-fold (proc procedure?) seed (i integer?) ) ⟹ *
(proc (bit boolean?) state ) ⟹ *
For each bit b of i from bit #0 (inclusive) to bit (integer-length i) (exclusive), proc is called as (proc b r), where r is the current accumulated result. The initial value of r is seed, and the value returned by proc becomes the next accumulated result. When the last bit has been processed, the final accumulated result becomes the result of bitwise-fold.
(srfi 151) procedure (bitwise-for-each (proc procedure?) (i integer?) ) ⟹ undefined
(proc (bit boolean?) ) ⟹ undefined
Repeatedly applies proc to the bits of i starting with bit #0 (inclusive) and ending with bit (integer-length i) (exclusive). The values returned by proc are discarded. Returns an unspecified value.
(srfi 151) procedure (bitwise-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ integer?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ boolean?
(successor seed ) ⟹ *
Generates a non-negative integer bit by bit, starting with bit 0. If the result of applying stop? to the current state (whose initial value is seed) is true, return the currently accumulated bits as an integer. Otherwise, apply mapper to the current state to obtain the next bit of the result by interpreting a true value as a 1 bit and a false value as a 0 bit. Then get a new state by applying successor to the current state, and repeat this algorithm.
(srfi 151) procedure (make-bitwise-generator (i integer?) ) ⟹ procedure?
(return ) ⟹ boolean?
Returns a SRFI 121 generator that generates all the bits of i starting with bit #0. Note that the generator is infinite.
library (srfi 152)
(srfi 152) procedure (string? obj ) ⟹ boolean?
(srfi 152) procedure (string? obj ) ⟹ boolean?
Is obj a string?
(srfi 152) procedure (string-null? (string string?) ) ⟹ boolean?
Is string the empty string?
(srfi 152) procedure (string-every (pred procedure?) (string string?) ) ⟹ *
(srfi 152) procedure (string-every (pred procedure?) (string string?) (start integer?) ) ⟹ *
(srfi 152) procedure (string-every (pred procedure?) (string string?) (start integer?) (end integer?) ) ⟹ *
(pred (char char?) ) ⟹ *
(srfi 152) procedure (string-any (pred procedure?) (string string?) ) ⟹ *
(srfi 152) procedure (string-any (pred procedure?) (string string?) (start integer?) ) ⟹ *
(srfi 152) procedure (string-any (pred procedure?) (string string?) (start integer?) (end integer?) ) ⟹ *
(pred (char char?) ) ⟹ *
Checks to see if every/any character in string satisfies pred, proceeding from left (index start) to right (index end). These procedures are short-circuiting: if pred returns false, string-every does not call pred on subsequent characters; if pred returns true, string-any does not call pred on subsequent characters; Both procedures are "witness-generating":
(srfi 152) procedure (make-string (len integer?) (char char?) ) ⟹ string?
Returns a string of the given length filled with the given character.
(srfi 152) procedure (string (char char?) ... ) ⟹ string?
Returns a string consisting of the given characters.
(srfi 152) procedure (string-tabulate (proc procedure?) (len integer?) ) ⟹ string?
(proc (k integer?) ) ⟹ char?
Proc is a procedure that accepts an exact integer as its argument and returns a character. Constructs a string of size len by calling proc on each value from 0 (inclusive) to len (exclusive) to produce the corresponding element of the string. The order in which proc is called on those indexes is not specified.
(srfi 152) procedure (string-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ string?
(srfi 152) procedure (string-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base string?) ) ⟹ string?
(srfi 152) procedure (string-unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base string?) (make-final procedure?) ) ⟹ string?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char? / string? /
(success seed ) ⟹ *
(make-final seed ) ⟹ char? / string? /
This is a fundamental constructor for strings.
(srfi 152) procedure (string-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ string?
(srfi 152) procedure (string-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base string?) ) ⟹ string?
(srfi 152) procedure (string-unfold-right (stop? procedure?) (mapper procedure?) (successor procedure?) seed (base string?) (make-final procedure?) ) ⟹ string?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ char? / string? /
(success seed ) ⟹ *
(make-final seed ) ⟹ char? / string? /
This is a fundamental constructor for strings. It is the same as string-unfold except the results of mapper are assembled into the string in right-to-left order, base is the optional rightmost portion of the constructed string, and make-final produces the leftmost portion of the constructed string. If mapper returns a string, the string is prepended to the constructed string (without reversal).
(srfi 152) procedure (string->vector (string string?) ) ⟹ vector?
(srfi 152) procedure (string->vector (string string?) (start integer?) ) ⟹ vector?
(srfi 152) procedure (string->vector (string string?) (start integer?) (end integer?) ) ⟹ vector?
return ⟹ (vector char? )
(srfi 152) procedure (string->list (string string?) ) ⟹ list?
(srfi 152) procedure (string->list (string string?) (start integer?) ) ⟹ list?
(srfi 152) procedure (string->list (string string?) (start integer?) (end integer?) ) ⟹ list?
return ⟹ (list char? )
These procedures return a newly allocated (unless empty) vector or list of the characters that make up the given substring.
(srfi 152) procedure (vector->string (vector vector?) ) ⟹ string?
(srfi 152) procedure (vector->string (vector vector?) (start integer?) ) ⟹ string?
(srfi 152) procedure (vector->string (vector vector?) (start integer?) (end integer?) ) ⟹ string?
vector ⟹ (vector char? )
(srfi 152) procedure (list->string (list list?) ) ⟹ string?
list ⟹ (list char? )
These procedures return a string containing the characters of the given (sub)vector or list. The behavior of the string will not be affected by subsequent mutation of the given vector or list.
(srfi 152) procedure (reverse-list->string (char-list list?) ) ⟹ string?
char-list ⟹ (list char? )
Semantically equivalent to (compose list->string reverse):
(reverse-list->string '(#\a #\B #\c)) => "cBa"
This is a common idiom in the epilogue of string-processing loops that accumulate their result using a list in reverse order. (See also string-concatenate-reverse for the "chunked" variant.)
(srfi 152) procedure (string-length (string string?) ) ⟹ integer?
Returns the number of characters within the given string.
(srfi 152) procedure (string-ref (string string?) (idx integer?) ) ⟹ char?
Returns character string[idx], using 0-origin indexing.
(srfi 152) procedure (substring (string string?) (start integer?) (end integer?) ) ⟹ string?
(srfi 152) procedure (string-copy (string string?) ) ⟹ string?
(srfi 152) procedure (string-copy (string string?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-copy (string string?) (start integer?) (end integer?) ) ⟹ string?
These procedures return a string containing the characters of string beginning with index start (inclusive) and ending with index end (exclusive). The only difference is that substring requires all three arguments, whereas string-copy requires only one.
(srfi 152) procedure (string-take (string string?) (nchars integer?) ) ⟹ string?
(srfi 152) procedure (string-drop (string string?) (nchars integer?) ) ⟹ string?
(srfi 152) procedure (string-take-right (string string?) (nchars integer?) ) ⟹ string?
(srfi 152) procedure (string-drop-right (string string?) (nchars integer?) ) ⟹ string?
string-take returns a string containing the first nchars of string; string-drop returns a string containing all but the first nchars of string. string-take-right returns a string containing the last nchars of string; string-drop-right returns a string containing all but the last nchars of string.
(srfi 152) procedure (string-pad (string string?) (len integer?) ) ⟹ string?
(srfi 152) procedure (string-pad (string string?) (len integer?) (char char?) ) ⟹ string?
(srfi 152) procedure (string-pad (string string?) (len integer?) (char char?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-pad (string string?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ string?
(srfi 152) procedure (string-pad-right (string string?) (len integer?) ) ⟹ string?
(srfi 152) procedure (string-pad-right (string string?) (len integer?) (char char?) ) ⟹ string?
(srfi 152) procedure (string-pad-right (string string?) (len integer?) (char char?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-pad-right (string string?) (len integer?) (char char?) (start integer?) (end integer?) ) ⟹ string?
Returns a string of length len comprised of the characters drawn from the given subrange of string, padded on the left (right) by as many occurrences of the character char as needed. If string has more than len chars, it is truncated on the left (right) to length len. char defaults to #\space.
(srfi 152) procedure (string-trim (string string?) ) ⟹ string?
(srfi 152) procedure (string-trim (string string?) (pred procedure?) ) ⟹ string?
(srfi 152) procedure (string-trim (string string?) (pred procedure?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-trim (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ string?
(pred (char char?) ) ⟹ boolean?
(srfi 152) procedure (string-trim-right (string string?) ) ⟹ string?
(srfi 152) procedure (string-trim-right (string string?) (pred procedure?) ) ⟹ string?
(srfi 152) procedure (string-trim-right (string string?) (pred procedure?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-trim-right (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ string?
(pred (char char?) ) ⟹ boolean?
(srfi 152) procedure (string-trim-both (string string?) ) ⟹ string?
(srfi 152) procedure (string-trim-both (string string?) (pred procedure?) ) ⟹ string?
(srfi 152) procedure (string-trim-both (string string?) (pred procedure?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-trim-both (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ string?
(pred (char char?) ) ⟹ boolean?
Returns a string obtained from the given subrange of string by skipping over all characters on the left side / on the right side / on both sides that satisfy the second argument pred: pred defaults to char-whitespace?.
(srfi 152) procedure (string-replace (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ string?
(srfi 152) procedure (string-replace (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ string?
(srfi 152) procedure (string-replace (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ string?
Returns
(string-append (substring string1 0 start1)
(substring string2 start2 end2)
(substring string1 end1 (string-length string1)))
That is, the segment of characters in string1 from start1 to end1 is replaced by the segment of characters in string2 from start2 to end2. If start1=end1, this simply splices the characters drawn from string2 into string1 at that position.
(srfi 152) procedure (string=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
Returns #t if all the strings have the same length and contain exactly the same characters in the same positions; otherwise returns #f.
(srfi 152) procedure (string<? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 152) procedure (string>? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 152) procedure (string<=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 152) procedure (string>=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
These procedures return #t if their arguments are (respectively): monotonically increasing, monotonically decreasing, monotonically non-decreasing, or monotonically non-increasing.
These comparison predicates are required to be transitive.
These procedures compare 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 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, implementations are also allowed to use more sophisticated locale-specific orderings.
In all cases, a pair of strings must satisfy exactly one of string<?, string=?, and string>?, must satisfy string<=? if and only if they do not satisfy string>?, and must satisfy string>=? if and only if they do not satisfy string<?.
(srfi 152) procedure (string-ci=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
Returns #t if, after calling string-foldcase on each of the arguments, all of the case-folded strings would have the same length and contain the same characters in the same positions; otherwise returns #f.
(srfi 152) procedure (string-ci<? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 152) procedure (string-ci>? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 152) procedure (string-ci<=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
(srfi 152) procedure (string-ci>=? (string1 string?) (string2 string?) (string3 string?) ... ) ⟹ boolean?
These procedures behave as though they had called string-foldcase on their arguments before applying the corresponding procedures without "-ci".
(srfi 152) procedure (string-prefix-length (string1 string?) (string2 string?) ) ⟹ integer?
(srfi 152) procedure (string-prefix-length (string1 string?) (string2 string?) (start1 integer?) ) ⟹ integer?
(srfi 152) procedure (string-prefix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 152) procedure (string-prefix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 152) procedure (string-prefix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
(srfi 152) procedure (string-suffix-length (string1 string?) (string2 string?) ) ⟹ integer?
(srfi 152) procedure (string-suffix-length (string1 string?) (string2 string?) (start1 integer?) ) ⟹ integer?
(srfi 152) procedure (string-suffix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ integer?
(srfi 152) procedure (string-suffix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ integer?
(srfi 152) procedure (string-suffix-length (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ integer?
Return the length of the longest common prefix/suffix of string1 and string2. For prefixes, this is equivalent to their "mismatch index" (relative to the start indexes).
The optional start/end indexes restrict the comparison to the indicated substrings of string1 and string2.
(srfi 152) procedure (string-prefix? (string1 string?) (string2 string?) ) ⟹ boolean?
(srfi 152) procedure (string-prefix? (string1 string?) (string2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 152) procedure (string-prefix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 152) procedure (string-prefix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 152) procedure (string-prefix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
(srfi 152) procedure (string-suffix? (string1 string?) (string2 string?) ) ⟹ boolean?
(srfi 152) procedure (string-suffix? (string1 string?) (string2 string?) (start1 integer?) ) ⟹ boolean?
(srfi 152) procedure (string-suffix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ boolean?
(srfi 152) procedure (string-suffix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ boolean?
(srfi 152) procedure (string-suffix? (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ boolean?
Is string1 a prefix/suffix of string2?
The optional start/end indexes restrict the comparison to the indicated substrings of string1 and string2.
(srfi 152) procedure (string-index (string string?) (pred procedure?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-index (string string?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-index (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
(srfi 152) procedure (string-index-right (string string?) (pred procedure?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-index-right (string string?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-index-right (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
(srfi 152) procedure (string-skip (string string?) (pred procedure?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-skip (string string?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-skip (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
(srfi 152) procedure (string-skip-right (string string?) (pred procedure?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-skip-right (string string?) (pred procedure?) (start integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-skip-right (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ #f / integer? /
(pred (char char?) ) ⟹ boolean?
string-index searches through the given substring from the left, returning the index of the leftmost character satisfying the predicate pred. string-index-right searches from the right, returning the index of the rightmost character satisfying the predicate pred. If no match is found, these procedures return #f.
The start and end arguments specify the beginning and end of the search; the valid indexes relevant to the search include start but exclude end. Beware of "fencepost" errors: when searching right-to-left, the first index considered is (- end 1), whereas when searching left-to-right, the first index considered is start. That is, the start/end indexes describe the same half-open interval [start,end) in these procedures that they do in all other procedures specified by this SRFI.
The skip functions are similar, but use the complement of the criterion: they search for the first char that doesn't satisfy pred.
(srfi 152) procedure (string-contains (string1 string?) (string2 string?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-contains (string1 string?) (string2 string?) (start1 integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-contains (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-contains (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-contains (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-contains-right (string1 string?) (string2 string?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-contains-right (string1 string?) (string2 string?) (start1 integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-contains-right (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-contains-right (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) ) ⟹ #f / integer? /
(srfi 152) procedure (string-contains-right (string1 string?) (string2 string?) (start1 integer?) (end1 integer?) (start2 integer?) (end2 integer?) ) ⟹ #f / integer? /
Does the substring of string1 specified by start1 and end1 contain the sequence of characters given by the substring of string2 specified by start2 and end2?
Returns #f if there is no match. If start2 = end2, string-contains returns start1 but string-contains-right returns end1. Otherwise returns the index in string1 for the first character of the first/last match; that index lies within the half-open interval [start1,end1), and the match lies entirely within the [start1,end1) range of string1.
(srfi 152) procedure (string-take-while (string string?) (pred procedure?) ) ⟹ string?
(srfi 152) procedure (string-take-while (string string?) (pred procedure?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-take-while (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ string?
(pred (c char?) ) ⟹ boolean?
(srfi 152) procedure (string-take-while-right (string string?) (pred procedure?) ) ⟹ string?
(srfi 152) procedure (string-take-while-right (string string?) (pred procedure?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-take-while-right (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ string?
(pred (c char?) ) ⟹ boolean?
Returns the longest initial prefix/suffix of the substring of string specified by start and end whose elements all satisfy the predicate pred. (Not SRFI 13 procedures.)
(srfi 152) procedure (string-drop-while (string string?) (pred procedure?) ) ⟹ string?
(srfi 152) procedure (string-drop-while (string string?) (pred procedure?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-drop-while (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ string?
(pred (c char?) ) ⟹ boolean?
(srfi 152) procedure (string-drop-while-right (string string?) (pred procedure?) ) ⟹ string?
(srfi 152) procedure (string-drop-while-right (string string?) (pred procedure?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-drop-while-right (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ string?
(pred (c char?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of the substring of string specified by start and end whose elements all satisfy the predicate pred, and returns the rest of the string.
These are the same as string-trim and string-trim-right, but with a different order of arguments. (Not SRFI 13 procedures.)
(srfi 152) procedure (string-span (string string?) (pred procedure?) ) ⟹ (values string?string)
(srfi 152) procedure (string-span (string string?) (pred procedure?) (start integer?) ) ⟹ (values string?string)
(srfi 152) procedure (string-span (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ (values string?string)
(pred (c char?) ) ⟹ boolean?
(srfi 152) procedure (string-break (string string?) (pred procedure?) ) ⟹ (values string?string)
(srfi 152) procedure (string-break (string string?) (pred procedure?) (start integer?) ) ⟹ (values string?string)
(srfi 152) procedure (string-break (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ (values string?string)
(pred (c char?) ) ⟹ boolean?
String-span splits the substring of string specified by start and end into the longest initial prefix whose elements all satisfy pred, and the remaining tail. String-break inverts the sense of the predicate: the tail commences with the first element of the input string that satisfies the predicate. (Not SRFI 13 procedures.)
In other words: span finds the initial span of elements satisfying pred, and break breaks the string at the first element satisfying pred.
(srfi 152) procedure (string-append (string string?) ... ) ⟹ string?
Returns a string whose sequence of characters is the concatenation of the sequences of characters in the given arguments.
(srfi 152) procedure (string-concatenate (string-list list?) ) ⟹ string?
Concatenates the elements of string-list together into a single string.
(srfi 152) procedure (string-concatenate-reverse (string-list list?) ) ⟹ string?
(srfi 152) procedure (string-concatenate-reverse (string-list list?) (final-string string?) ) ⟹ string?
(srfi 152) procedure (string-concatenate-reverse (string-list list?) (final-string string?) (end integer?) ) ⟹ string?
With no optional arguments, calling this procedure is equivalent to
(string-concatenate (reverse string-list))
If the optional argument final-string is specified, it is effectively consed onto the beginning of string-list before performing the list-reverse and string-concatenate operations.
If the optional argument end is given, only the characters up to but not including end in final-string are added to the result, thus producing
(string-concatenate
(reverse (cons (substring final-string 0 end)
string-list)))
(srfi 152) procedure (string-join (string-list list?) ) ⟹ string?
(srfi 152) procedure (string-join (string-list list?) (delimiter string?) ) ⟹ string?
(srfi 152) procedure (string-join (string-list list?) (delimiter string?) (grammar symbol?) ) ⟹ string?
This procedure is a simple unparser; it pastes strings together using the delimiter string.
string-list is a list of strings. delimiter is a string. The grammar argument is a symbol that determines how the delimiter is used, and defaults to 'infix. It is an error for grammar to be any symbol other than these four:
'infix means an infix or separator grammar: insert the delimiter between list elements. An empty list will produce an empty string.
'strict-infix means the same as 'infix if the string-list is non-empty, but will signal an error if given an empty list. (This avoids an ambiguity shown in the examples below.)
'suffix means a suffix or terminator grammar: insert the delimiter after every list element.
'prefix means a prefix grammar: insert the delimiter before every list element.
The delimiter is the string used to delimit elements; it defaults to a single space " ".
(srfi 152) procedure (string-fold (kons procedure?) knil (string string?) ) ⟹ *
(srfi 152) procedure (string-fold (kons procedure?) knil (string string?) (start integer?) ) ⟹ *
(srfi 152) procedure (string-fold (kons procedure?) knil (string string?) (start integer?) (end integer?) ) ⟹ *
(kons (char char?) state ) ⟹ *
(srfi 152) procedure (string-fold-right (kons procedure?) knil (string string?) ) ⟹ *
(srfi 152) procedure (string-fold-right (kons procedure?) knil (string string?) (start integer?) ) ⟹ *
(srfi 152) procedure (string-fold-right (kons procedure?) knil (string string?) (start integer?) (end integer?) ) ⟹ *
(kons (char char?) state ) ⟹ *
These are the fundamental iterators for strings.
The string-fold procedure maps the kons procedure across the given string from left to right:
(... (kons string[2] (kons string[1] (kons string[0] knil))))
In other words, string-fold obeys the (tail) recursion
(string-fold kons knil string start end)
= (string-fold kons (kons string[start] knil) start+1 end)
The string-fold-right procedure maps kons across the given string from right to left:
(kons string[0]
(... (kons string[end-3]
(kons string[end-2]
(kons string[end-1]
knil)))))
obeying the (tail) recursion
(string-fold-right kons knil string start end)
= (string-fold-right kons (kons string[end-1] knil) start end-1)
(srfi 152) procedure (string-map (proc procedure?) (string1 string?) (string2 string?) ... ) ⟹ string?
(proc (char1 char?) (char2 char?) ... ) ⟹ string? / char? /
It is an error if proc does not accept as many arguments as the number of string arguments passed to string-map, does not accept characters as arguments, or returns a value that is not a character or string.
The string-map procedure applies proc element-wise to the characters of the string arguments, converts each value returned by proc to a string, and returns the concatenation of those strings. If more than one string argument is given and not all have the same length, then string-map terminates when the shortest string argument runs out. The dynamic order in which proc is called on the characters of the string arguments is unspecified, as is the dynamic order in which the coercions are performed. If any strings returned by proc are mutated after they have been returned and before the call to string-map has returned, then string-map returns a string with unspecified contents; the string-map procedure itself does not mutate those strings.
(srfi 152) procedure (string-for-each (proc procedure?) (string1 string?) (string2 string?) ... ) ⟹ undefined
(proc (char1 char?) (char2 char?) ... ) ⟹ undefined
It is an error if proc does not accept as many arguments as the number of string arguments passed to string-map or does not accept characters as arguments.
The string-for-each procedure applies proc element-wise to the characters of the string arguments, going from left to right. If more than one string argument is given and not all have the same length, then string-for-each terminates when the shortest string argument runs out.
(srfi 152) procedure (string-count (string string?) (pred procedure?) ) ⟹ integer?
(srfi 152) procedure (string-count (string string?) (pred procedure?) (start integer?) ) ⟹ integer?
(srfi 152) procedure (string-count (string string?) (pred procedure?) (start integer?) (end integer?) ) ⟹ integer?
(pred (char char?) ) ⟹ boolean?
Returns a count of the number of characters in the specified substring of string that satisfy the given predicate.
(srfi 152) procedure (string-filter (pred procedure?) (string string?) ) ⟹ string?
(srfi 152) procedure (string-filter (pred procedure?) (string string?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-filter (pred procedure?) (string string?) (start integer?) (end integer?) ) ⟹ string?
(pred (char char?) ) ⟹ boolean?
(srfi 152) procedure (string-remove (pred procedure?) (string string?) ) ⟹ string?
(srfi 152) procedure (string-remove (pred procedure?) (string string?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-remove (pred procedure?) (string string?) (start integer?) (end integer?) ) ⟹ string?
(pred (char char?) ) ⟹ boolean?
Filter the given substring of string, retaining only those characters that satisfy / do not satisfy pred.
Compatibility note: In SRFI 13, string-remove is called string-delete. This is inconsistent with SRFI 1 and other SRFIs.
(srfi 152) procedure (string-replicate (string string?) (from integer?) (to integer?) ) ⟹ string?
(srfi 152) procedure (string-replicate (string string?) (from integer?) (to integer?) (start integer?) ) ⟹ string?
(srfi 152) procedure (string-replicate (string string?) (from integer?) (to integer?) (start integer?) (end integer?) ) ⟹ string?
This is an "extended substring" procedure that implements replicated copying of a substring.
string is a string; start and end are optional arguments that specify a substring of string, defaulting to 0 and the length of string. This substring is conceptually replicated both up and down the index space, in both the positive and negative directions. For example, if string is "abcdefg", start is 3, and end is 6, then we have the conceptual bidirectionally-infinite string
... d e f d e f d e f d e f d e f d e f d ...
-9 -8 -7 -6 -5 -4 -3 -2 -1 0 +1 +2 +3 +4 +5 +6 +7 +8 +9
string-replicate returns the substring of this string beginning at index from, and ending at to. It is an error if from is greater than to.
It is an error if start=end, unless from=to, which is allowed as a special case.
(srfi 152) procedure (string-segment (string string?) (k integer?) ) ⟹ list?
Returns a list of strings representing the consecutive substrings of length k. The last string may be shorter than k. (Not a SRFI 13 procedure.)
(srfi 152) procedure (string-split (string string?) (delimiter string?) ) ⟹ list?
(srfi 152) procedure (string-split (string string?) (delimiter string?) (grammar symbol?) ) ⟹ list?
(srfi 152) procedure (string-split (string string?) (delimiter string?) (grammar symbol?) (limit (or #finteger?)) ) ⟹ list?
(srfi 152) procedure (string-split (string string?) (delimiter string?) (grammar symbol?) (limit (or #finteger?)) (start integer?) ) ⟹ list?
(srfi 152) procedure (string-split (string string?) (delimiter string?) (grammar symbol?) (limit (or #finteger?)) (start integer?) (end integer?) ) ⟹ list?
Returns a list of strings representing the words contained in the substring of string from start (inclusive) to end (exclusive). The delimiter is a string to be used as the word separator. This will often be a single character, but multiple characters are allowed for use cases such as splitting on "
". The returned list will have one more item than the number of non-overlapping occurrences of the delimiter in the string. If delimiter is an empty string, then the returned list contains a list of strings, each of which contains a single character. (Not a SRFI 13 procedure; replaces string-tokenize).
The grammar is a symbol with the same meaning as in the string-join procedure. If it is infix, which is the default, processing is done as described above, except an empty string produces the empty list; if grammar is strict-infix, then an empty string signals an error. The values prefix and suffix cause a leading/trailing empty string in the result to be suppressed.
If limit is a non-negative exact integer, at most that many splits occur, and the remainder of string is returned as the final element of the list (so the result will have at most limit+1 elements). If limit is not specified or is #f, then as many splits as possible are made. It is an error if limit is any other value.
To split on a regular expression, use SRFI 115's regexp-split procedure.
(srfi 152) procedure (read-string (k integer?) ) ⟹ eof-object? / string? /
(srfi 152) 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. The default port is the value of (current-input-port).
(srfi 152) procedure (write-string (string string?) ) ⟹ undefined
(srfi 152) procedure (write-string (string string?) (port output-port?) ) ⟹ undefined
(srfi 152) procedure (write-string (string string?) (port output-port?) (start integer?) ) ⟹ undefined
(srfi 152) procedure (write-string (string string?) (port output-port?) (start integer?) (end integer?) ) ⟹ undefined
Writes the characters of string from index start to index end onto textual output port port. The default port is the value of (current-output-port).
(srfi 152) procedure (string-set! (string string?) (k integer?) (char char?) ) ⟹ undefined
The string-set! procedure stores char in element k of string.
(srfi 152) procedure (string-fill! (string string?) (fill char?) ) ⟹ undefined
(srfi 152) procedure (string-fill! (string string?) (fill char?) (start integer?) ) ⟹ undefined
(srfi 152) procedure (string-fill! (string string?) (fill char?) (start integer?) (end integer?) ) ⟹ undefined
The string-fill! procedure stores fill in elements start through end of string.
(srfi 152) procedure (string-copy! (to string?) (at integer?) (from string?) ) ⟹ undefined
(srfi 152) procedure (string-copy! (to string?) (at integer?) (from string?) (start integer?) ) ⟹ undefined
(srfi 152) procedure (string-copy! (to string?) (at integer?) (from string?) (start integer?) (end integer?) ) ⟹ undefined
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.
library (srfi 154)
(srfi 154) procedure (dynamic-extent? obj ) ⟹ boolean?
The dynamic-extent? procedure returns #t if its argument is a dynamic extent, and #f otherwise. Note that dynamic extents are not necessarily disjoint from other Scheme types such as procedures.
(srfi 154) procedure (current-dynamic-extent ) ⟹ dynamic-extent?
The current-dynamic-extent procedure returns the current dynamic extent by capturing the dynamic extent of the call to current-dynamic-extent, which can be reinstated by the procedure with-dynamic-extent.
(srfi 154) procedure (with-dynamic-extent (dynamic-extent dynamic-extent?) (thunk procedure?) ) ⟹ *
(thunk ) ⟹ *
The with-dynamic-extent procedure calls the thunk and returns the values yielded by thunk. The call to thunk happens in the dynamic extent captured by the dynamic-extent.
(srfi 154) syntax (dynamic-lambda () ((_ formals body) procedure? ) )
(variable1 ...) variable (variable1 ... variable_n . variable_n+1)
A dynamic-lambda expression is equivalent to lambda expression except that not only the environment but also the dynamic extent in effect when the dynamic-lambda expression was evaluated is remembered. In other words, the expression (dynamic-lambda <formals> <body>) closes also over the dynamic extent.
library (srfi 156)
(srfi 156) syntax (is (_ ) ((is val1 predicate-or-comparator val2 ...) boolean? / procedure? / ) )
_ obj
predicate-or-comparator ⟹ procedure?
(srfi 156) syntax (isnt (_ ) ((isnt val1 predicate-or-comparator val2 ...) boolean? / procedure? / ) )
_ obj
predicate-or-comparator ⟹ procedure?
Infix relations
This document proposes to augment Scheme with a new syntactic form, is, so that, for example, the expression (is John taller-than? Tom) is expanded to (taller-than? John Tom).
In addition to improved code readability, the introduction of the is form gives an occasion to provide some convenient special behaviour in some particular cases. While some Schemers may find the lack of regularity and predictability of the is form repulsive, we believe that it actually allows us to express some common operations more succinctly.
Short-hand lambda expressions
For example, we decided to treat the _ (underscore) symbol differently than other symbols. (is _ taller-than? John) is expanded to (lambda (_) (taller-than? _ John)), thereby making the functionality of the is form partially overlap with the cut special form defined in the SRFI 26 document.
We chose the underscore symbol, although the cut macro uses the <> symbol, because it has been used as a special non-bindable symbol in various pattern matchers for Scheme (as well as in the Prolog language). It has also traditionally been used to name values that are meant to be ignored, so we believe that our choice should not be in conflict with existing practices.
However, the _ symbol should not be bound to a new transformer, but instead it should be imported from (scheme base) and re-exported, so that it can be renamed by the users who prefer to stick with the <> symbol from SRFI-26.
Multiple instances of underscore
If more than one instance of the underscore symbol appears in the argument position of the is and isnt macros, each occurrence counts as a separate argument (increasing the arity of the resulting lambda accordingly). For example, (is _ < _) is equivalent to (lambda (_1 _2) (< _1 _2)).
Negation
In addition to the is form, this SRFI provides an implementation of the isnt form, which negates the behavior of is. Although we didn't find that form particularly useful, we are certain that it may find its use, and if it were absent from the language, Schemers would come up with their own implementations. As a matter of fact, in our experiments with parroting the English language, we initially used the isn't symbol, which failed to work on some implementations.
Handling fewer arguments
The is and isnt macros could technically be passed fewer than three arguments. In particular, we interpret (isnt x prime?) as (not (prime? x)), and (isnt _ prime?) as (lambda (_) (not (prime? _))). For consistency, we interpret the usages of the is macro similarly, although it may not seem particularly useful. It is illegal to use the is and isnt macros with fewer than two arguments, and such attempts should raise a syntax error.
library (srfi 157)
(srfi 157) syntax (with-continuation-mark () ((_ key value expression)) )
The <key> expression is evaluated to obtain a key, the <value> expression is evaluated to obtain a value, the key is mapped to the value as a continuation mark in the current continuation's initial continuation (if the frame already has a mark for the key, the mark is replaced), and, finally, the <expression> is evaluated. The continuation for evaluating <expression> is the continuation of the with-continuation-mark expression (so the result of the <expression> is the result of the with-continuation-mark expression, and the <expression> is in tail context if the with-continuation-mark expression is).
(srfi 157) procedure (current-continuation-marks ) ⟹ continuation-marks?
Returns an object called a set of continuations marks, which at some point in the future can be asked (by the continuation-mark-set->list, continuation-mark-set->list* and continuation-mark-set-first procedures) to deliver the set of continuation marks of the continuation of the call to current-continuation-marks for a given key.
(srfi 157) procedure (continuation-marks? obj ) ⟹ boolean?
Returns #t if obj is a set of continuation marks, and #f otherwise. Note that sets of continuation marks are not necessarily disjoint from other Scheme types such as lists.
(srfi 157) procedure (continuation-mark-set->list (marks continuation-marks?) ) ⟹ list?
Returns a newly allocated list containing the marks for the key in the continuation mark set marks.
(srfi 157) procedure (continuation-mark-set->list* (marks continuation-marks?) list ) ⟹ list?
(srfi 157) procedure (continuation-mark-set->list* (marks continuation-marks?) list default ) ⟹ list?
return ⟹ (list vector? )
Returns a newly allocated list containing vectors of marks in the continuation mark set marks. The length of each vector in the result list is the same as the length of the key list, and a value in a particular vector position is the value for the corresponding key in list. Values for multiple keys appear in a single vector only when the marks are for the same continuation frame in the continuation mark set marks. The object default is used for vector elements to indicate the lack of a value.
(srfi 157) procedure (continuation-mark-set-first (marks continuation-marks?) key ) ⟹ *
(srfi 157) procedure (continuation-mark-set-first (marks continuation-marks?) key default ) ⟹ *
Returns the first element of the list that would be returned by (continuation-mark-set->list marks key), or default if the result would be the empty list.
Semantically equivalent to, but may be more efficient than:
(let ((lst (continuation-mark-set->list marks key))
(if (not (null? lst))
(car lst)
default)))
(srfi 157) procedure (call-with-immediate-continuation-mark key (proc procedure?) ) ⟹ *
(srfi 157) procedure (call-with-immediate-continuation-mark key (proc procedure?) default ) ⟹ *
(proc mark-value ) ⟹ *
Tail-calls proc with the value associated with key in the first frame of the current continuation (i.e., a value that would be replaced in the set of current continuation marks if the call to call-with-immediate-continuation-mark were replaced with a with-continuation-mark form using key as the key expression). If no such value exists in the first frame, default is passed to proc.
Semantically equivalent to, but may be more efficient than:
(let ((secret-key (vector #f)))
(with-continuation-mark secret-key #f
(let ((marks
(continuation-mark-set->list* (current-continuation-marks)
(list key secret-key)
default))
(proc (vector-ref (car marks) 0)))))
library (srfi 158)
(srfi 158) procedure (generator arg ... ) ⟹ procedure?
(return ) ⟹ *
The simplest finite generator. Generates each of its arguments in turn. When no arguments are provided, it returns an empty generator that generates no values.
(srfi 158) procedure (circular-generator arg ... ) ⟹ procedure?
(return ) ⟹ *
The simplest infinite generator. Generates each of its arguments in turn, then generates them again in turn, and so on forever.
(srfi 158) procedure (make-iota-generator (count integer?) ) ⟹ procedure?
(srfi 158) procedure (make-iota-generator (count integer?) (start real?) ) ⟹ procedure?
(srfi 158) procedure (make-iota-generator (count integer?) (start real?) (step real?) ) ⟹ procedure?
(return ) ⟹ real? / eof-object? /
Creates a finite generator of a sequence of count numbers. The sequence begins with start (which defaults to 0) and increases by step (which defaults to 1). If both start and step are exact, it generates exact numbers; otherwise it generates inexact numbers. The exactness of count doesn't affect the exactness of the results.
(srfi 158) procedure (make-range-generator (start real?) ) ⟹ procedure?
(srfi 158) procedure (make-range-generator (start real?) (end real?) ) ⟹ procedure?
(srfi 158) procedure (make-range-generator (start real?) (end real?) (step real?) ) ⟹ procedure?
(return ) ⟹ real? / eof-object? /
Creates a generator of a sequence of numbers. The sequence begins with start, increases by step (default 1), and continues while the number is less than end, or forever if end is omitted. If both start and step are exact, it generates exact numbers; otherwise it generates inexact numbers. The exactness of end doesn't affect the exactness of the results.
(srfi 158) procedure (make-coroutine-generator (proc procedure?) ) ⟹ procedure?
(proc (yield procedure?) ) ⟹ undefined
(yield value ) ⟹ undefined
(return ) ⟹ *
Creates a generator from a coroutine.
The proc argument is a procedure that takes one argument, yield. When called, make-coroutine-generator immediately returns a generator g. When g is called, proc runs until it calls yield. Calling yield causes the execution of proc to be suspended, and g returns the value passed to yield.
Whether this generator is finite or infinite depends on the behavior of proc. If proc returns, it is the end of the sequence — g returns an end-of-file object from then on. The return value of proc is ignored.
(srfi 158) procedure (list->generator (lis list?) ) ⟹ procedure?
(return ) ⟹ *
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(srfi 158) procedure (vector->generator (vec vector?) ) ⟹ procedure?
(srfi 158) procedure (vector->generator (vec vector?) (start integer?) ) ⟹ procedure?
(srfi 158) procedure (vector->generator (vec vector?) (start integer?) (end integer?) ) ⟹ procedure?
(return ) ⟹ *
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(srfi 158) procedure (reverse-vector->generator (vec vector?) ) ⟹ procedure?
(srfi 158) procedure (reverse-vector->generator (vec vector?) (start integer?) ) ⟹ procedure?
(srfi 158) procedure (reverse-vector->generator (vec vector?) (start integer?) (end integer?) ) ⟹ procedure?
(return ) ⟹ *
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(srfi 158) procedure (string->generator (str string?) ) ⟹ procedure?
(srfi 158) procedure (string->generator (str string?) (start integer?) ) ⟹ procedure?
(srfi 158) procedure (string->generator (str string?) (start integer?) (end integer?) ) ⟹ procedure?
(return ) ⟹ char? / eof-object? /
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(srfi 158) procedure (bytevector->generator (bytevector bytevector?) ) ⟹ procedure?
(srfi 158) procedure (bytevector->generator (bytevector bytevector?) (start integer?) ) ⟹ procedure?
(srfi 158) procedure (bytevector->generator (bytevector bytevector?) (start integer?) (end integer?) ) ⟹ procedure?
(return ) ⟹ integer? / eof-object? /
Returns generator that yields each element of the given argument. Mutating the underlying object will affect the results of the generator.
(srfi 158) procedure (make-for-each-generator (for-each procedure?) obj ) ⟹ procedure?
(for-each element ) ⟹ undefined
(return ) ⟹ *
A generator constructor that converts any collection obj to a generator that returns its elements using a for-each procedure appropriate for obj. This must be a procedure that when called as (for-each proc obj) calls proc on each element of obj. Examples of such procedures are for-each, string-for-each, and vector-for-each from R7RS. The value returned by for-each is ignored. The generator is finite if the collection is finite, which would typically be the case.
The collections need not be conventional ones (lists, strings, etc.) as long as for-each can invoke a procedure on everything that counts as a member.
(srfi 158) procedure (make-unfold-generator (stop? procedure?) (mapper procedure?) (successor procedure?) seed ) ⟹ procedure?
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
(return ) ⟹ *
A generator constructor similar to SRFI 1's unfold.
The stop? predicate takes a seed value and determines whether to stop. The mapper procedure calculates a value to be returned by the generator from a seed value. The successor procedure calculates the next seed value from the current seed value.
For each call of the resulting generator, stop? is called with the current seed value. If it returns true, then the generator returns an end-of-file object. Otherwise, it applies mapper to the current seed value to get the value to return, and uses successor to update the seed value.
This generator is finite unless stop? never returns true.
(srfi 158) procedure (gcons* item ... (gen procedure?) ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ *
Returns a generator that adds items in front of gen. Once the items have been consumed, the generator is guaranteed to tail-call gen.
(srfi 158) procedure (gappend (gen procedure?) ... ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ *
Returns a generator that yields the items from the first given generator, and once it is exhausted, from the second generator, and so on.
(srfi 158) procedure (gflatten (gen procedure?) ... ) ⟹ procedure?
(gen ) ⟹ list?
(return ) ⟹ *
Returns a generator that yields the elements of the lists produced by the given generator.
(srfi 158) procedure (ggroup (gen procedure?) (k integer?) ) ⟹ procedure?
(srfi 158) procedure (ggroup (gen procedure?) (k integer?) padding ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ list? / eof-object? /
Returns a generator that yields lists of k items from the given generator. If fewer than k elements are available for the last list, and padding is absent, the short list is returned; otherwise, it is padded by padding to length k.
(srfi 158) procedure (gmerge (less-than procedure?) (gen1 procedure?) ... ) ⟹ procedure?
(less-than a b ) ⟹ boolean?
(gen ) ⟹ *
Returns a generator that yields the items from the given generators in the order dictated by less-than. If the items are equal, the leftmost item is used first. When all of given generators are exhausted, the returned generator is exhausted also.
As a special case, if only one generator is given, it is returned.
(srfi 158) procedure (gmap (proc procedure?) (gen1 procedure?) ... ) ⟹ procedure?
(proc el ) ⟹ *
(gen ) ⟹ *
When only one generator is given, returns a generator that yields the items from the given generator after invoking proc on them.
When more than one generator is given, each item of the resulting generator is a result of applying proc to the items from each generator. If any of input generator is exhausted, the resulting generator is also exhausted.
Note: This differs from generator-map->list, which consumes all values at once and returns the results as a list, while gmap returns a generator immediately without consuming input.
(srfi 158) procedure (gcombine (proc procedure?) seed (gen1 procedure?) (gen2 procedure?) ... ) ⟹ procedure?
(proc value1 value2 ... seed ) ⟹ (values **)
(gen ) ⟹ *
(return ) ⟹ *
A generator for mapping with state. It yields a sequence of sub-folds over proc.
The proc argument is a procedure that takes as many arguments as the input generators plus one. It is called as (proc v1 v2 … seed), where v1, v2, … are the values yielded from the input generators, and seed is the current seed value. It must return two values, the yielding value and the next seed. The result generator is exhausted when any of the genn generators is exhausted, at which time all the others are in an undefined state.
(srfi 158) procedure (gfilter (pred procedure?) (gen procedure?) ) ⟹ procedure?
(pred element ) ⟹ boolean?
(gen ) ⟹ *
(return ) ⟹ *
Returns generators that yield the items from the source generator, except those on which pred answers false.
(srfi 158) procedure (gremove (pred procedure?) (gen procedure?) ) ⟹ procedure?
(pred element ) ⟹ boolean?
(gen ) ⟹ *
(return ) ⟹ *
Returns generators that yield the items from the source generator, except those on which pred answers true.
(srfi 158) procedure (gstate-filter (proc procedure?) seed (gen procedure?) ) ⟹ procedure?
(proc item state ) ⟹ (values boolean?*)
(gen ) ⟹ *
(return ) ⟹ *
Returns a generator that obtains items from the source generator and passes an item and a state (whose initial value is seed) as arguments to proc. Proc in turn returns two values, a boolean and a new value of the state. If the boolean is true, the item is returned; otherwise, this algorithm is repeated until gen is exhausted, at which point the returned generator is also exhausted. The final value of the state is discarded.
(srfi 158) procedure (gtake (gen procedure?) (k integer?) ) ⟹ procedure?
(srfi 158) procedure (gtake (gen procedure?) (k integer?) padding ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ *
Gtake returns a generator that yields (at most) the first k items of the source generator.
The procedure won't complain if the source generator is exhausted before generating k items. By default, the generator returned by gtake terminates when the source generator does, but if you provide the padding argument, then the returned generator will yield exactly k items, using the padding value as needed to provide sufficient additional values.
(srfi 158) procedure (gdrop (gen procedure?) (k integer?) ) ⟹ procedure?
(gen ) ⟹ *
(return ) ⟹ *
Gdrop returns a generator that skips the first k items of the source generator. The procedure won't complain if the source generator is exhausted before generating k items.
(srfi 158) procedure (gtake-while (pred procedure?) (gen procedure?) ) ⟹ procedure?
(pred element ) ⟹ boolean?
(gen ) ⟹ *
(return ) ⟹ *
The generator returned from gtake-while yields items from the source generator as long as pred returns true for each.
(srfi 158) procedure (gdrop-while (pred procedure?) (gen procedure?) ) ⟹ procedure?
(pred element ) ⟹ boolean?
(gen ) ⟹ *
(return ) ⟹ *
The generator returned from gdrop-while first reads and discards values from the source generator while pred returns true for them, then starts yielding items returned by the source.
(srfi 158) procedure (gdelete item (gen procedure?) ) ⟹ procedure?
(srfi 158) procedure (gdelete item (gen procedure?) (= procedure?) ) ⟹ procedure?
(gen ) ⟹ *
(= a b ) ⟹ boolean?
(return ) ⟹ *
Creates a generator that returns whatever gen returns, except for any items that are the same as item in the sense of =, which defaults to equal?. The = predicate is passed exactly two arguments, of which the first is item and the second is an element generated by gen.
(srfi 158) procedure (gdelete-neighbor-dups (gen procedure?) ) ⟹ procedure?
(srfi 158) procedure (gdelete-neighbor-dups (gen procedure?) (= procedure?) ) ⟹ procedure?
(gen ) ⟹ *
(= a b ) ⟹ boolean?
(return ) ⟹ *
Creates a generator that returns whatever gen returns, except for any items that are equal to the preceding item in the sense of =, which defaults to equal?. The = predicate is passed exactly two arguments, of which the first was generated by gen before the second.
(srfi 158) procedure (gindex (value-gen procedure?) (index-gen procedure?) ) ⟹ procedure?
(value-gen ) ⟹ *
(index-gen ) ⟹ integer? / eof-object? /
(return ) ⟹ *
Creates a generator that returns elements of value-gen specified by the indices (non-negative exact integers) generated by index-gen. It is an error if the indices are not strictly increasing. The result generator is exhausted when either generator is exhausted, at which time the other is in an undefined state.
(srfi 158) procedure (gselect (value-gen procedure?) (truth-gen procedure?) ) ⟹ procedure?
(value-gen ) ⟹ *
(truth-gen ) ⟹ boolean? / eof-object? /
(return ) ⟹ *
Creates a generator that returns elements of value-gen that correspond to the values generated by truth-gen. If the current value of truth-gen is true, the current value of value-gen is generated, but otherwise not. The result generator is exhausted when either generator is exhausted, at which time the other is in an undefined state.
(srfi 158) procedure (generator->list (generator procedure?) ) ⟹ list?
(srfi 158) procedure (generator->list (generator procedure?) (k integer?) ) ⟹ list?
(generator ) ⟹ *
Reads items from generator and returns a newly allocated list of them. By default, it reads until the generator is exhausted.
If an optional argument k is given, it must be a non-negative integer, and the list ends when either k items are consumed, or generator is exhausted; therefore generator can be infinite in this case.
(srfi 158) procedure (generator->reverse-list (generator procedure?) ) ⟹ list?
(srfi 158) procedure (generator->reverse-list (generator procedure?) (k integer?) ) ⟹ list?
(generator ) ⟹ *
Reads items from generator and returns a newly allocated list of them in reverse order. By default, this reads until the generator is exhausted.
If an optional argument k is given, it must be a non-negative integer, and the list ends when either k items are read, or generator is exhausted; therefore generator can be infinite in this case.
(srfi 158) procedure (generator->vector (generator procedure?) ) ⟹ vector?
(srfi 158) procedure (generator->vector (generator procedure?) (k integer?) ) ⟹ vector?
(generator ) ⟹ *
Reads items from generator and returns a newly allocated vector of them. By default, it reads until the generator is exhausted.
If an optional argument k is given, it must be a non-negative integer, and the list ends when either k items are consumed, or generator is exhausted; therefore generator can be infinite in this case.
(srfi 158) procedure (generator->vector! (vector vector?) (at integer?) (generator procedure?) ) ⟹ integer?
(generator ) ⟹ *
Reads items from generator and puts them into vector starting at index at, until vector is full or generator is exhausted. Generator can be infinite. The number of elements generated is returned.
(srfi 158) procedure (generator->string (generator procedure?) ) ⟹ string?
(srfi 158) procedure (generator->string (generator procedure?) (k integer?) ) ⟹ string?
(generator ) ⟹ char? / eof-object? /
Reads items from generator and returns a newly allocated string of them. It is an error if the items are not characters. By default, it reads until the generator is exhausted.
If an optional argument k is given, it must be a non-negative integer, and the string ends when either k items are consumed, or generator is exhausted; therefore generator can be infinite in this case.
(srfi 158) procedure (generator-fold (proc procedure?) seed (gen1 procedure?) (gen2 procedure?) ... ) ⟹ procedure?
(proc val1 val2 ... state ) ⟹ *
(gen ) ⟹ *
Works like SRFI 1 fold on the values generated by the generator arguments.
When one generator is given, for each value v generated by gen, proc is called as (proc v r), where r is the current accumulated result; the initial value of the accumulated result is seed, and the return value from proc becomes the next accumulated result. When gen is exhausted, the accumulated result at that time is returned from generator-fold.
When more than one generator is given, proc is invoked on the values returned by all the generator arguments followed by the current accumulated result. The procedure terminates when any of the genn generators is exhausted, at which time all the others are in an undefined state.
(srfi 158) procedure (generator-for-each (proc procedure?) (gen1 procedure?) (gen2 procedure?) ... ) ⟹ undefined
(proc val1 val2 ... ) ⟹ undefined
(gen ) ⟹ *
A generator analogue of for-each that consumes generated values using side effects. Repeatedly applies proc on the values yielded by gen, gen2 … until any one of the generators is exhausted, at which time all the others are in an undefined state. The values returned from proc are discarded. Returns an unspecified value.
(srfi 158) procedure (generator-map->list (proc procedure?) (gen1 procedure?) (gen2 procedure?) ... ) ⟹ list?
(proc element ) ⟹ *
(generator ) ⟹ *
A generator analogue of map that consumes generated values, processes them through a mapping function, and returns a list of the mapped values. Repeatedly applies proc on the values yielded by gen, gen2 … until any one of the generators is exhausted, at which time all the others are in an undefined state. The values returned from proc are accumulated into a list, which is returned.
(srfi 158) procedure (generator-find (pred procedure?) (generator procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(generator ) ⟹ *
Applies pred to each item from gen. As soon as it yields a true value, the item is returned without consuming the rest of gen. If gen is exhausted, returns #f.
(srfi 158) procedure (generator-count (pred procedure?) (generator procedure?) ) ⟹ integer?
(pred element ) ⟹ boolean?
(generator ) ⟹ *
Returns the number of items available from the generator gen that satisfy the predicate pred.
(srfi 158) procedure (generator-any (pred procedure?) (generator procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(generator ) ⟹ *
Applies pred to each item from gen. As soon as it yields a true value, the value is returned without consuming the rest of gen. If gen is exhausted, returns #f.
(srfi 158) procedure (generator-every (pred procedure?) (generator procedure?) ) ⟹ *
(pred element ) ⟹ boolean?
(generator ) ⟹ *
Applies pred to each item from gen. As soon as it yields a false value, the value is returned without consuming the rest of gen. If gen is exhausted, returns the last value returned by pred, or #t if pred was never called.
(srfi 158) procedure (generator-unfold (gen procedure?) (unfold procedure?) arg ... ) ⟹ *
(gen ) ⟹ *
(unfold (stop? procedure?) (mapper procedure?) (successor procedure?) seed args ... ) ⟹ *
(stop? seed ) ⟹ boolean?
(mapper seed ) ⟹ *
(successor seed ) ⟹ *
Equivalent to (unfold eof-object? (lambda (x) x) (lambda (x) (gen)) (gen) arg ...). The values of gen are unfolded into the collection that unfold creates.
The signature of the unfold procedure is (unfold stop? mapper successor seed args ...). Note that the vector-unfold and vector-unfold-right of SRFI 43 and SRFI 133 do not have this signature and cannot be used with this procedure. To unfold into a vector, use SRFI 1's unfold and then apply list->vector to the result.
(srfi 158) procedure (make-accumulator (kons procedure?) knil (finalizer procedure?) ) ⟹ procedure?
(kons element state ) ⟹ *
(finalizer state ) ⟹ *
(return el ) ⟹ *
Returns an accumulator that, when invoked on an object other than an end-of-file object, invokes kons on its argument and the accumulator's current state, using the same order as a function passed to fold. It then sets the accumulator's state to the value returned by kons and returns an unspecified value. The initial state of the accumulator is set to knil. However, if an end-of-file object is passed to the accumulator, it returns the result of tail-calling the procedure finalizer on the state. Repeated calls with an end-of-file object will reinvoke finalizer.
(srfi 158) procedure (count-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / integer? /
Returns an accumulator that, when invoked on an object, adds 1 to a count inside the accumulator and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the count.
(srfi 158) procedure (list-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / list? /
Returns an accumulator that, when invoked on an object, adds that object to a list inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the list.
(srfi 158) procedure (reverse-list-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / list? /
Returns an accumulator that, when invoked on an object, adds that object to a list inside the accumulator in reverse order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the list.
(srfi 158) procedure (vector-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / vector? /
Returns an accumulator that, when invoked on an object, adds that object to a vector inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the vector.
(srfi 158) procedure (reverse-vector-accumulator ) ⟹ procedure?
(return el ) ⟹ undefined / vector? /
Returns an accumulator that, when invoked on an object, adds that object to a vector inside the accumulator in reverse order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the vector.
(srfi 158) procedure (vector-accumulator! (vector vector?) (at integer?) ) ⟹ procedure?
(return el ) ⟹ undefined / vector? /
Returns an accumulator that, when invoked on an object, adds that object to consecutive positions of vector starting at at in order of accumulation. It is an error to try to accumulate more objects than vector will hold. An unspecified value is returned. However, if an end-of-file object is passed, the accumulator returns vector.
(srfi 158) procedure (string-accumulator ) ⟹ procedure?
(return (char (or char?eof-object?)) ) ⟹ undefined / string? /
Returns an accumulator that, when invoked on a character, adds that character to a string inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the string.
(srfi 158) procedure (bytevector-accumulator ) ⟹ procedure?
(return (byte (or integer?eof-object?)) ) ⟹ undefined / bytevector? /
Returns an accumulator that, when invoked on a byte, adds that integer to a bytevector inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the bytevector.
(srfi 158) procedure (bytevector-accumulator! (bytevector bytevector?) (at integer?) ) ⟹ procedure?
(return (byte (or integer?eof-object?)) ) ⟹ undefined / bytevector? /
Returns an accumulator that, when invoked on a byte, adds that byte to consecutive positions of bytevector starting at at in order of accumulation. It is an error to try to accumulate more bytes than vector will hold. An unspecified value is returned. However, if an end-of-file object is passed, the accumulator returns bytevector.
(srfi 158) procedure (sum-accumulator ) ⟹ procedure?
(return (char (or number?eof-object?)) ) ⟹ undefined / number? /
Returns an accumulator that, when invoked on a number, adds that number to a sum inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the sum.
(srfi 158) procedure (product-accumulator ) ⟹ procedure?
(return (char (or number?eof-object?)) ) ⟹ undefined / number? /
Returns an accumulator that, when invoked on a number, multiplies that number to a product inside the accumulator in order of accumulation and returns an unspecified value. However, if an end-of-file object is passed, the accumulator returns the product.
library (srfi 159)
(srfi 159) procedure (show (port #f) (fmt formatter) ... ) ⟹ string?
(srfi 159) procedure (show (port (or output-port?boolean?)) (fmt formatter) ... ) ⟹ undefined
The entry point for all formatting. Applies the fmt formatters in sequence, accumulating the output to output-dest. As with SRFI 28 format, output-dest can be an output port, #t to indicate the current output port, or #f to accumulate the output into a string and return that as the result of show.
(srfi 159) procedure (displayed obj ) ⟹ formatter
If obj is a formatter, returns obj as is. Otherwise, outputs obj using display semantics. Specifically, strings are output as if by write-string and characters are written as if by write-char. Other objects are output as with written (including nested strings and chars inside obj). This is the default behavior for top-level formats in show, each and most other high-level formatters.
(srfi 159) procedure (written obj ) ⟹ formatter
Outputs obj using write semantics. Uses the current numeric formatting settings to the extent that the written result can still be passed to read, possibly with loss of precision. Specifically, the current radix is used if set to any of 2, 8, 10 or 16, and the fixed point precision is used if specified and the radix is 10.
(srfi 159) procedure (written-simply obj ) ⟹ formatter
Same as "written", but doesn't handle shared structures. Infinite loops can still be avoided if used inside a formatter that truncates data (see trimmed and fitted below).
(srfi 159) procedure (pretty obj ) ⟹ formatter
Pretty-prints obj. The result should be identical to written except possibly for differences in whitespace to make the output resemble formatted source code. Implementations should print vectors and data lists (lists that don't begin with a (nested) symbol) in a tabular format when possible to reduce vertical space.
(srfi 159) procedure (pretty-simply obj ) ⟹ formatter
Same as "pretty", but doesn't handle shared structures. Infinite loops can still be avoided if used inside a formatter that truncates data (see trimmed and fitted below).
(srfi 159) procedure (escaped (str string?) ) ⟹ formatter
(srfi 159) procedure (escaped (str string?) (quote-ch char?) ) ⟹ formatter
(srfi 159) procedure (escaped (str string?) (quote-ch char?) (esc-ch char?) ) ⟹ formatter
(srfi 159) procedure (escaped (str string?) (quote-ch char?) (esc-ch char?) (renamer procedure?) ) ⟹ formatter
(renamer (c char?) ) ⟹ char?
Outputs the string str, escaping any quote or escape characters. If esc-ch, which defaults to #\\, is #f, escapes only the quote-ch, which defaults to #\", by doubling it, as in SQL strings and CSV values. If renamer is provided, it should be a procedure of one character which maps that character to its escape value, e.g. #\newline => #\n, or #f if there is no escape value.
(srfi 159) procedure (maybe-escaped (str string?) (pred procedure?) ) ⟹ formatter
(srfi 159) procedure (maybe-escaped (str string?) (pred procedure?) (quote-ch char?) ) ⟹ formatter
(srfi 159) procedure (maybe-escaped (str string?) (pred procedure?) (quote-ch char?) (esc-ch char?) ) ⟹ formatter
(srfi 159) procedure (maybe-escaped (str string?) (pred procedure?) (quote-ch char?) (esc-ch char?) (renamer procedure?) ) ⟹ formatter
(pred (c char?) ) ⟹ boolean?
(renamer (c char?) ) ⟹ char?
Like escaped, but first checks if any quoting is required (by the existence of either any quote or escape characters, or any character matching pred), and if so outputs the string in quotes and with escapes. Otherwise outputs the string as is. This is useful for quoting symbols and CSV output, etc.
(srfi 159) procedure (numeric (num number?) ) ⟹ formatter
(srfi 159) procedure (numeric (num number?) (radix integer?) ) ⟹ formatter
(srfi 159) procedure (numeric (num number?) (radix integer?) (precision integer?) ) ⟹ formatter
(srfi 159) procedure (numeric (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) ) ⟹ formatter
(srfi 159) procedure (numeric (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) ) ⟹ formatter
(srfi 159) procedure (numeric (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) (comma-sep char?) ) ⟹ formatter
(srfi 159) procedure (numeric (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) (comma-sep char?) (decimal-sep char?) ) ⟹ formatter
Formats a single number num. You can optionally specify any radix from 2 to 36 (even if num isn't an integer). precision forces a fixed-point format.
A sign of #t indicates to output a plus sign (+) for positive integers. However, if sign is a pair of two strings, it means to wrap negative numbers with the two strings. For example, ("(" . ")") prints negative numbers in parentheses, financial style: -1.99 => (1.99).
comma is an integer specifying the number of digits between commas.
comma-sep is the character to use for commas, defaulting to #\,.
decimal-sep is the character to use for decimals, defaulting to #\., or to #\, (European style) if comma-sep is already #\..
These parameters may seem unwieldy, but they can also take their defaults from state variables
(srfi 159) procedure (numeric/comma (num number?) ) ⟹ formatter
(srfi 159) procedure (numeric/comma (num number?) (radix integer?) ) ⟹ formatter
(srfi 159) procedure (numeric/comma (num number?) (radix integer?) (precision integer?) ) ⟹ formatter
(srfi 159) procedure (numeric/comma (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) ) ⟹ formatter
Shortcut for numeric to print with commas.
(srfi 159) procedure (numeric/si (num number?) ) ⟹ formatter
(srfi 159) procedure (numeric/si (num number?) (base integer?) ) ⟹ formatter
(srfi 159) procedure (numeric/si (num number?) (base integer?) (separator string?) ) ⟹ formatter
Abbreviates num with an SI suffix as in the -h or --si option to many GNU commands. The base defaults to 1024, using suffix names like Ki, Mi, Gi, etc. Other bases (e.g. the standard 1000) have the suffixes k, M, G, etc. If separator is provided, it is inserted after the number, before any suffix.
(srfi 159) procedure (numeric/fitted (num number?) ) ⟹ formatter
(srfi 159) procedure (numeric/fitted (num number?) (radix integer?) ) ⟹ formatter
(srfi 159) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) ) ⟹ formatter
(srfi 159) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) ) ⟹ formatter
(srfi 159) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) ) ⟹ formatter
(srfi 159) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) (comma-sep char?) ) ⟹ formatter
(srfi 159) procedure (numeric/fitted (num number?) (radix integer?) (precision integer?) (sign (or boolean?pair?)) (comma integer?) (comma-sep char?) (decimal-sep char?) ) ⟹ formatter
Like numeric, but if the result doesn't fit in width using the current precision, output instead a string of hashes rather than showing an incorrectly truncated number.
nl ⟹ formatter
Outputs a newline.
fl ⟹ formatter
Short for "fresh line," outputs a newline only if we're not already at the start of a line.
(srfi 159) procedure (space-to (column integer?) ) ⟹ formatter
Outputs spaces up to the given column. If the current column is already >= column, does nothing. The character used for spacing is the current value of pad-char, described below, which defaults to space. Columns are zero-based.
(srfi 159) procedure (tab-to ) ⟹ formatter
(srfi 159) procedure (tab-to (tab-width integer?) ) ⟹ formatter
Outputs spaces up to the next tab stop, using tab stops of width tab-width, which defaults to 8. If already on a tab stop, does nothing. If you want to ensure you always tab at least one space, you can use (each " " (tab-to width)). Columns are zero-based.
nothing ⟹ formatter
Outputs nothing (useful in combinators and as a default noop in conditionals).
(srfi 159) procedure (each (fmt formatter) ... ) ⟹ formatter
Applies each fmt in sequence, as in the top-level of show.
(srfi 159) procedure (each-in-list (list-of-fmts list?) ) ⟹ formatter
Equivalent to (apply each list-of-fmts) but may be more efficient.
(srfi 159) procedure (joined (mapper procedure?) (list list?) ) ⟹ formatter
(srfi 159) procedure (joined (mapper procedure?) (list list?) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
Formats each element elt of list with (mapper elt), inserting sep in between. sep defaults to the empty string, but can be any format or string.
(srfi 159) procedure (joined/prefix (mapper procedure?) (list list?) ) ⟹ formatter
(srfi 159) procedure (joined/prefix (mapper procedure?) (list list?) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
As joined, but inserts sep before every element.
(srfi 159) procedure (joined/suffix (mapper procedure?) (list list?) ) ⟹ formatter
(srfi 159) procedure (joined/suffix (mapper procedure?) (list list?) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
As joined, but inserts sep after every element.
(srfi 159) procedure (joined/last (mapper procedure?) (last-mapper procedure?) (list list?) ) ⟹ formatter
(srfi 159) procedure (joined/last (mapper procedure?) (last-mapper procedure?) (list list?) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
(last-mapper element ) ⟹ formatter
As joined, but the last element of the list is formatted with last-mapper instead.
(srfi 159) procedure (joined/dot (mapper procedure?) (dot-mapper procedure?) (list (or list?dotted-list?)) ) ⟹ formatter
(srfi 159) procedure (joined/dot (mapper procedure?) (dot-mapper procedure?) (list (or list?dotted-list?)) (separator (or string?formatter)) ) ⟹ formatter
(mapper element ) ⟹ formatter
(dot-mapper tail ) ⟹ formatter
As joined, but if the list is a dotted list, then formats the dotted value with dot-mapper instead.
(srfi 159) procedure (joined/range (mapper procedure?) (start integer?) ) ⟹ formatter
(srfi 159) procedure (joined/range (mapper procedure?) (start integer?) (end (or integer?#f)) ) ⟹ formatter
(srfi 159) procedure (joined/range (mapper procedure?) (start integer?) (end (or integer?#f)) (separator (or string?formatter)) ) ⟹ formatter
(mapper (value integer?) ) ⟹ formatter
As joined, but counts from start (inclusive) to end (exclusive), formatting each integer in the range with mapper. If end is #f or unspecified, produces an infinite stream of output.
(srfi 159) procedure (padded (width integer?) (fmt formatter) ... ) ⟹ formatter
Add extra space to the left side of the output generated by the fmts to pad it to width.
(srfi 159) procedure (padded/right (width integer?) (fmt formatter) ... ) ⟹ formatter
Add extra space to the right side of the output generated by the fmts to pad it to width.
(srfi 159) procedure (padded/both (width integer?) (fmt formatter) ... ) ⟹ formatter
Add extra space to the both sides of the output generated by the fmts to pad it to width.
(srfi 159) procedure (trimmed (width integer?) (fmt formatter) ... ) ⟹ formatter
Truncates the output of the fmts to force it in under width columns. As soon as any of the fmts exceeds width, stop formatting and truncate the result, returning control to whoever called trimmed. If a truncation ellipsis is set, then when any truncation occurs trimmed will prepend the ellipsis.
(srfi 159) procedure (trimmed/right (width integer?) (fmt formatter) ... ) ⟹ formatter
Truncates the output of the fmts to force it in under width columns. As soon as any of the fmts exceeds width, stop formatting and truncate the result, returning control to whoever called trimmed. If a truncation ellipsis is set, then when any truncation occurs trimmed/right will append the ellipsis.
(srfi 159) procedure (trimmed/both (width integer?) (fmt formatter) ... ) ⟹ formatter
Truncates the output of the fmts to force it in under width columns. As soon as any of the fmts exceeds width, stop formatting and truncate the result, returning control to whoever called trimmed. If a truncation ellipsis is set, then when any truncation occurs trimmed/bith will both prepend and append the ellipsis.
(srfi 159) procedure (trimmed/lazy (width integer?) (fmt formatter) ... ) ⟹ formatter
A variant of trimmed which generates each fmt in left to right order, and truncates and terminates immediately if more than width characters are generated. Thus this is safe to use with an infinite amount of output, e.g. from written-simply on an infinite list.
(srfi 159) procedure (fitted (width integer?) (fmt formatter) ... ) ⟹ formatter
A combination of padded and trimmed that ensures that the output width is exactly width, truncating if it goes over and padding if it goes under.
(srfi 159) procedure (fitted/right (width integer?) (fmt formatter) ... ) ⟹ formatter
A combination of padded and trimmed that ensures that the output width is exactly width, truncating if it goes over and padding if it goes under.
(srfi 159) procedure (fitted/both (width integer?) (fmt formatter) ... ) ⟹ formatter
A combination of padded and trimmed that ensures that the output width is exactly width, truncating if it goes over and padding if it goes under.
(srfi 159) procedure (columnar (column (or formatterstring?symbol?number?)) ... ) ⟹ formatter
Formats each column side-by-side, i.e. as though each were formatted separately and then the individual lines concatenated together. The current line width (from the width state variable) is divided evenly among the columns, and all but the last column are right-padded.
You may also prefix any column with any of the symbols 'left, 'right or 'center to control the justification. The symbol 'infinite can be used to indicate the column generates an infinite stream of output.
You can further prefix any column with a width modifier. Any positive integer is treated as a fixed width, ignoring the available width. Any real number between 0 and 1 indicates a fraction of the available width (after subtracting out any fixed widths). Columns with unspecified width divide up the remaining width evenly. If the extra space does not divide evenly, it is allocated column-wise left to right, e.g. if the width of 78 is divided among 5 columns, the column widths become 16, 16, 16, 15, 15 in order.
Note that columnar builds its output incrementally, interleaving calls to the generators until each has produced a line, then concatenating that line together and outputting it. This is important because as noted above, some columns may produce an infinite stream of output, and in general you may want to format data larger than can fit into memory. Thus columnar would be suitable for line numbering a file of arbitrary size, or implementing the Unix yes(1) command, etc.
(srfi 159) procedure (tabular (column (or formatterstring?symbol?number?)) ... ) ⟹ formatter
Equivalent to columnar except that each column is padded at least to the minimum width required on any of its lines.
This makes it easier to generate tables without knowing widths in advance. However, because it requires generating the entire output in advance to determine the correct column widths, tabular cannot format a table larger than would fit in memory.
(srfi 159) procedure (wrapped (fmt formatter) ... ) ⟹ formatter
Behaves like each, except text is accumulated and lines are wrapped to fit in the current width as in the Unix fmt(1) command. Specifically, words are tokenized by splitting on all characters which satisfy the predicate in the parameter word-separator?, which defaults to char-whitespace?. Words are grouped into lines separating them by space, and line breaks are introduced to minimize the sum of the cube of trailing whitespace on every line.
(srfi 159) procedure (wrapped/list (list-of-strings list?) ... ) ⟹ formatter
Like wrapped, but taking a pre-tokenized list of strings.
(srfi 159) procedure (wrapped/char (fmt formatter) ... ) ⟹ formatter
As wrapped, but splits simply on individual characters exactly as the current width is reached on each line. Thus there is nothing to optimize and this formatter doesn't buffer output.
(srfi 159) procedure (justified (fmt formatter) ... ) ⟹ formatter
Like wrapped except the lines are full-justified.
(srfi 159) procedure (from-file (pathname string?) ) ⟹ formatter
Displays the contents of the file pathname one line at a time, so that in typical formatters such as columnar only constant memory is consumed, making this suitable for formatting files of arbitrary size.
(srfi 159) procedure (line-numbers ) ⟹ formatter
(srfi 159) procedure (line-numbers (start integer?) ) ⟹ formatter
A convenience utility, just formats an infinite stream of numbers (in the current radix) beginning with start, which defaults to 1.
(srfi 159) procedure (as-red (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-blue (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-green (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-cyan (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-yellow (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-magenta (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-white (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-black (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-bold (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-underline (fmt formatter) ... ) ⟹ formatter
Outputs the formatters colored or (boldened or underline) with ANSI escapes, for use when formatting to a terminal.
(srfi 159) procedure (as-unicode (fmt formatter) ... ) ⟹ formatter
Padding, trimming and tabbing, etc. will generally not do the right thing in the presence of zero-width and double-width Unicode characters. This formatter overrides the string-width state var used in column tracking to do the right thing in such cases, considering Unicode double or full width characters as 2 characters wide (as they typically are in fixed-width terminals), while treating combining and non-spacing characters as 0 characters wide.
(srfi 159) procedure (unicode-terminal-width (str string?) ) ⟹ integer?
A utility function which returns the integer number of columns str would require in a terminal
(srfi 159) syntax (fn () ((_ (binding ...) expr ... fmt) formatter ) )
(id state-var) id
state-var ⟹ formatter-variable
Short for "function," this is the analog to lambda. Returns a formatter which on application evaluates each expr and fmt in left-to-right order, in a lexical environment extended with each identifier id bound to the current value of the state variable named by the symbol state-var. The result of the fmt is then applied as a formatter.
(srfi 159) syntax (with () ((_ ((state-var value) ...) fmt ...)) )
state-var ⟹ formatter-variable
Conceptually the formatting equivalent of parameterize, temporarily altering state variables. Applies each of the formatters fmt with each state-var bound to the corresponding value. The resulting state is then updated to restore each state-var to its original value.
(srfi 159) syntax (with! () ((_ (state-var value) ...)) )
state-var ⟹ formatter-variable
Similar to with but does not restore the original values, changing the value of each state-var for any remaining formatters in a sequence.
(srfi 159) procedure (forked (fmt1 formatter) (fmt2 formatter) ) ⟹ formatter
Calls fmt1 on (a conceptual copy of) the current state, then fmt2 on the same original state as though fmt1 had not been called.
(srfi 159) procedure (call-with-output (fmt formatter) (mapper procedure?) ) ⟹ formatter
(mapper (result-string string?) ) ⟹ formatter
A utility, calls formatter on a copy of the current state (as with forked), accumulating the results into a string. Then calls the formatter resulting from (mapper result-string) on the original state.
port ⟹ formatter-variable
The textual port output is written to, this can be overridden to capture intermediate output.
row ⟹ formatter-variable
The current row of output.
col ⟹ formatter-variable
The current column of output, used for padding and spacing, etc.
width ⟹ formatter-variable
The current line width, used for wrapping, pretty-printing, and columnar formatting. The default is implementation-defined.
output ⟹ formatter-variable
The underlying standard formatter for writing a single string. The default value outputs the string while tracking the current row and col. This can be overridden both to capture intermediate output and perform transformations on strings before outputting, but should generally wrap the existing output to preserve expected behavior.
writer ⟹ formatter-variable
The mapper for automatic formatting of non-string/char values in top-level show, each and other formatters. Default value is implementation-defined.
string-width ⟹ formatter-variable
A function of a single string, it returns the length in columns of that string, used by the default output.
pad-char ⟹ formatter-variable
The character used by space-to, tab-to and other padding formatters.
ellipsis ⟹ formatter-variable
The string used when truncating as described in trimmed.
radix ⟹ formatter-variable
The radix for numeric output, defaulting to 10, as used in numeric and written.
precision ⟹ formatter-variable
The precision for numeric output, as described in numeric and written. The precision specifies the number of digits written after the decimal point. If the numeric value to be written out requires more digits to represent it than precision, the written representation is chosen which is closest to the numeric value and representable with the specified precision. If the numeric value falls on the midpoint of two such representations, it is implementation dependent which representation is chosen.
When the numeric value is an inexact floating-point number, there is more than one interpretation of this "rounding". One is to take the effective value the floating-point number represents (e.g. if we use binary floating-point numbers, we take the value of (* sign mantissa (expt 2 exponent))), and compare it to the two closest numeric representations of the given precision. Another way is to obtain the default notation of the floating-point number and apply rounding to it. The former (we call it effective rounding) is consistent with most floating-point number operations, but may lead to a more non-intuitive result than the latter (we call it notational rounding). For example, 5.015 can't be represented exactly in binary floating-point numbers. With IEEE754 floating-point numbers, the floating point number closest to 5.015 is smaller than exact 5.015, i.e. (< 5.015 5015/1000) => #t. With effective rounding with precision 2, it should result in "5.01". However, users who look at the notation may be confused by "5.015" not being rounded up as they usually expect. With notational rounding the implementation chooses "5.02" (if it also adopts round-half-to-infinity or round-half-up rule). It is up to the implementation to choose which interpretation to adopt.
decimal-sep ⟹ formatter-variable
The decimal separator for floating point output, default ".".
decimal-align ⟹ formatter-variable
Specifies an alignment for the decimal place when formatting numbers, and is useful for outputting tables of numbers.
word-separator? ⟹ formatter-variable
A character predicate used to tokenize words for wrapped and justify. Defaults to char-whitespace?. More flexibility is available with wrapped/list.
library (srfi 160 base)
(srfi 160 base) procedure (make-u8vector (size integer?) ) ⟹ u8vector?
(srfi 160 base) procedure (make-u8vector (size integer?) (fill u8?) ) ⟹ u8vector?
Returns a u8vector whose length is size. If fill is provided, all the elements of the u8vector are initialized to it.
(srfi 160 base) procedure (u8vector (value u8?) ... ) ⟹ u8vector?
Returns a u8vector initialized with values.
(srfi 160 base) procedure (u8vector? obj ) ⟹ boolean?
Returns #t if obj is a u8vector, and #f otherwise.
(srfi 160 base) procedure (u8vector-length (u8vec u8vector?) ) ⟹ integer?
Returns the length of u8vec
(srfi 160 base) procedure (u8vector-ref (u8vec u8vector?) (i integer?) ) ⟹ u8?
Returns the ith element of u8vec.
(srfi 160 base) procedure (u8vector-set! (u8vec u8vector?) (i integer?) (value u8?) ) ⟹ undefined
Sets the ith element of u8vec to value.
(srfi 160 base) procedure (u8vector->list (u8vec u8vector?) ) ⟹ list?
(srfi 160 base) procedure (u8vector->list (u8vec u8vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (u8vector->list (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u8vec
(srfi 160 base) procedure (list->u8vector (proper-list list?) ) ⟹ u8vector?
proper-list ⟹ (list u8? )
Returns u8vector with same elements as list.
(srfi 160 base) procedure (u8? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u8vector (ie., unsigned exact integer in the range 0 to (2^8)-1), and #f otherwise.
(srfi 160 base) procedure (make-s8vector (size integer?) ) ⟹ s8vector?
(srfi 160 base) procedure (make-s8vector (size integer?) (fill s8?) ) ⟹ s8vector?
Returns a s8vector whose length is size. If fill is provided, all the elements of the s8vector are initialized to it.
(srfi 160 base) procedure (s8vector (value s8?) ... ) ⟹ s8vector?
Returns a s8vector initialized with values.
(srfi 160 base) procedure (s8vector? obj ) ⟹ boolean?
Returns #t if obj is a s8vector, and #f otherwise.
(srfi 160 base) procedure (s8vector-length (s8vec s8vector?) ) ⟹ integer?
Returns the length of s8vec
(srfi 160 base) procedure (s8vector-ref (s8vec s8vector?) (i integer?) ) ⟹ s8?
Returns the ith element of s8vec.
(srfi 160 base) procedure (s8vector-set! (s8vec s8vector?) (i integer?) (value s8?) ) ⟹ undefined
Sets the ith element of s8vec to value.
(srfi 160 base) procedure (s8vector->list (s8vec s8vector?) ) ⟹ list?
(srfi 160 base) procedure (s8vector->list (s8vec s8vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (s8vector->list (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s8vec
(srfi 160 base) procedure (list->s8vector (proper-list list?) ) ⟹ s8vector?
proper-list ⟹ (list s8? )
Returns s8vector with same elements as list.
(srfi 160 base) procedure (s8? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s8vector (ie., signed exact integer in the range -(2^7) to (2^7)-1), and #f otherwise.
(srfi 160 base) procedure (make-u16vector (size integer?) ) ⟹ u16vector?
(srfi 160 base) procedure (make-u16vector (size integer?) (fill u16?) ) ⟹ u16vector?
Returns a u16vector whose length is size. If fill is provided, all the elements of the u16vector are initialized to it.
(srfi 160 base) procedure (u16vector (value u16?) ... ) ⟹ u16vector?
Returns a u16vector initialized with values.
(srfi 160 base) procedure (u16vector? obj ) ⟹ boolean?
Returns #t if obj is a u16vector, and #f otherwise.
(srfi 160 base) procedure (u16vector-length (u16vec u16vector?) ) ⟹ integer?
Returns the length of u16vec
(srfi 160 base) procedure (u16vector-ref (u16vec u16vector?) (i integer?) ) ⟹ u16?
Returns the ith element of u16vec.
(srfi 160 base) procedure (u16vector-set! (u16vec u16vector?) (i integer?) (value u16?) ) ⟹ undefined
Sets the ith element of u16vec to value.
(srfi 160 base) procedure (u16vector->list (u16vec u16vector?) ) ⟹ list?
(srfi 160 base) procedure (u16vector->list (u16vec u16vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (u16vector->list (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u16vec
(srfi 160 base) procedure (list->u16vector (proper-list list?) ) ⟹ u16vector?
proper-list ⟹ (list u16? )
Returns u16vector with same elements as list.
(srfi 160 base) procedure (u16? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u16vector (ie., unsigned exact integer in the range 0 to (2^16)-1), and #f otherwise.
(srfi 160 base) procedure (make-s16vector (size integer?) ) ⟹ s16vector?
(srfi 160 base) procedure (make-s16vector (size integer?) (fill s16?) ) ⟹ s16vector?
Returns a s16vector whose length is size. If fill is provided, all the elements of the s16vector are initialized to it.
(srfi 160 base) procedure (s16vector (value s16?) ... ) ⟹ s16vector?
Returns a s16vector initialized with values.
(srfi 160 base) procedure (s16vector? obj ) ⟹ boolean?
Returns #t if obj is a s16vector, and #f otherwise.
(srfi 160 base) procedure (s16vector-length (s16vec s16vector?) ) ⟹ integer?
Returns the length of s16vec
(srfi 160 base) procedure (s16vector-ref (s16vec s16vector?) (i integer?) ) ⟹ s16?
Returns the ith element of s16vec.
(srfi 160 base) procedure (s16vector-set! (s16vec s16vector?) (i integer?) (value s16?) ) ⟹ undefined
Sets the ith element of s16vec to value.
(srfi 160 base) procedure (s16vector->list (s16vec s16vector?) ) ⟹ list?
(srfi 160 base) procedure (s16vector->list (s16vec s16vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (s16vector->list (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s16vec
(srfi 160 base) procedure (list->s16vector (proper-list list?) ) ⟹ s16vector?
proper-list ⟹ (list s16? )
Returns s16vector with same elements as list.
(srfi 160 base) procedure (s16? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s16vector (ie., signed exact integer in the range -(2^15) to (2^15)-1), and #f otherwise.
(srfi 160 base) procedure (make-u32vector (size integer?) ) ⟹ u32vector?
(srfi 160 base) procedure (make-u32vector (size integer?) (fill u32?) ) ⟹ u32vector?
Returns a u32vector whose length is size. If fill is provided, all the elements of the u32vector are initialized to it.
(srfi 160 base) procedure (u32vector (value u32?) ... ) ⟹ u32vector?
Returns a u32vector initialized with values.
(srfi 160 base) procedure (u32vector? obj ) ⟹ boolean?
Returns #t if obj is a u32vector, and #f otherwise.
(srfi 160 base) procedure (u32vector-length (u32vec u32vector?) ) ⟹ integer?
Returns the length of u32vec
(srfi 160 base) procedure (u32vector-ref (u32vec u32vector?) (i integer?) ) ⟹ u32?
Returns the ith element of u32vec.
(srfi 160 base) procedure (u32vector-set! (u32vec u32vector?) (i integer?) (value u32?) ) ⟹ undefined
Sets the ith element of u32vec to value.
(srfi 160 base) procedure (u32vector->list (u32vec u32vector?) ) ⟹ list?
(srfi 160 base) procedure (u32vector->list (u32vec u32vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (u32vector->list (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u32vec
(srfi 160 base) procedure (list->u32vector (proper-list list?) ) ⟹ u32vector?
proper-list ⟹ (list u32? )
Returns u32vector with same elements as list.
(srfi 160 base) procedure (u32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u32vector (ie., unsigned exact integer in the range 0 to (2^32)-1), and #f otherwise.
(srfi 160 base) procedure (make-s32vector (size integer?) ) ⟹ s32vector?
(srfi 160 base) procedure (make-s32vector (size integer?) (fill s32?) ) ⟹ s32vector?
Returns a s32vector whose length is size. If fill is provided, all the elements of the s32vector are initialized to it.
(srfi 160 base) procedure (s32vector (value s32?) ... ) ⟹ s32vector?
Returns a s32vector initialized with values.
(srfi 160 base) procedure (s32vector? obj ) ⟹ boolean?
Returns #t if obj is a s32vector, and #f otherwise.
(srfi 160 base) procedure (s32vector-length (s32vec s32vector?) ) ⟹ integer?
Returns the length of s32vec
(srfi 160 base) procedure (s32vector-ref (s32vec s32vector?) (i integer?) ) ⟹ s32?
Returns the ith element of s32vec.
(srfi 160 base) procedure (s32vector-set! (s32vec s32vector?) (i integer?) (value s32?) ) ⟹ undefined
Sets the ith element of s32vec to value.
(srfi 160 base) procedure (s32vector->list (s32vec s32vector?) ) ⟹ list?
(srfi 160 base) procedure (s32vector->list (s32vec s32vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (s32vector->list (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s32vec
(srfi 160 base) procedure (list->s32vector (proper-list list?) ) ⟹ s32vector?
proper-list ⟹ (list s32? )
Returns s32vector with same elements as list.
(srfi 160 base) procedure (s32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s32vector (ie., signed exact integer in the range -(2^31) to (2^31)-1), and #f otherwise.
(srfi 160 base) procedure (make-u64vector (size integer?) ) ⟹ u64vector?
(srfi 160 base) procedure (make-u64vector (size integer?) (fill u64?) ) ⟹ u64vector?
Returns a u64vector whose length is size. If fill is provided, all the elements of the u64vector are initialized to it.
(srfi 160 base) procedure (u64vector (value u64?) ... ) ⟹ u64vector?
Returns a u64vector initialized with values.
(srfi 160 base) procedure (u64vector? obj ) ⟹ boolean?
Returns #t if obj is a u64vector, and #f otherwise.
(srfi 160 base) procedure (u64vector-length (u64vec u64vector?) ) ⟹ integer?
Returns the length of u64vec
(srfi 160 base) procedure (u64vector-ref (u64vec u64vector?) (i integer?) ) ⟹ u64?
Returns the ith element of u64vec.
(srfi 160 base) procedure (u64vector-set! (u64vec u64vector?) (i integer?) (value u64?) ) ⟹ undefined
Sets the ith element of u64vec to value.
(srfi 160 base) procedure (u64vector->list (u64vec u64vector?) ) ⟹ list?
(srfi 160 base) procedure (u64vector->list (u64vec u64vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (u64vector->list (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u64vec
(srfi 160 base) procedure (list->u64vector (proper-list list?) ) ⟹ u64vector?
proper-list ⟹ (list u64? )
Returns u64vector with same elements as list.
(srfi 160 base) procedure (u64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u64vector (ie., unsigned exact integer in the range 0 to (2^64)-1), and #f otherwise.
(srfi 160 base) procedure (make-s64vector (size integer?) ) ⟹ s64vector?
(srfi 160 base) procedure (make-s64vector (size integer?) (fill s64?) ) ⟹ s64vector?
Returns a s64vector whose length is size. If fill is provided, all the elements of the s64vector are initialized to it.
(srfi 160 base) procedure (s64vector (value s64?) ... ) ⟹ s64vector?
Returns a s64vector initialized with values.
(srfi 160 base) procedure (s64vector? obj ) ⟹ boolean?
Returns #t if obj is a s64vector, and #f otherwise.
(srfi 160 base) procedure (s64vector-length (s64vec s64vector?) ) ⟹ integer?
Returns the length of s64vec
(srfi 160 base) procedure (s64vector-ref (s64vec s64vector?) (i integer?) ) ⟹ s64?
Returns the ith element of s64vec.
(srfi 160 base) procedure (s64vector-set! (s64vec s64vector?) (i integer?) (value s64?) ) ⟹ undefined
Sets the ith element of s64vec to value.
(srfi 160 base) procedure (s64vector->list (s64vec s64vector?) ) ⟹ list?
(srfi 160 base) procedure (s64vector->list (s64vec s64vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (s64vector->list (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s64vec
(srfi 160 base) procedure (list->s64vector (proper-list list?) ) ⟹ s64vector?
proper-list ⟹ (list s64? )
Returns s64vector with same elements as list.
(srfi 160 base) procedure (s64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s64vector (ie., signed exact integer in the range -(2^63) to (2^63)-1), and #f otherwise.
(srfi 160 base) procedure (make-f32vector (size integer?) ) ⟹ f32vector?
(srfi 160 base) procedure (make-f32vector (size integer?) (fill f32?) ) ⟹ f32vector?
Returns a f32vector whose length is size. If fill is provided, all the elements of the f32vector are initialized to it.
(srfi 160 base) procedure (f32vector (value f32?) ... ) ⟹ f32vector?
Returns a f32vector initialized with values.
(srfi 160 base) procedure (f32vector? obj ) ⟹ boolean?
Returns #t if obj is a f32vector, and #f otherwise.
(srfi 160 base) procedure (f32vector-length (f32vec f32vector?) ) ⟹ integer?
Returns the length of f32vec
(srfi 160 base) procedure (f32vector-ref (f32vec f32vector?) (i integer?) ) ⟹ f32?
Returns the ith element of f32vec.
(srfi 160 base) procedure (f32vector-set! (f32vec f32vector?) (i integer?) (value f32?) ) ⟹ undefined
Sets the ith element of f32vec to value.
(srfi 160 base) procedure (f32vector->list (f32vec f32vector?) ) ⟹ list?
(srfi 160 base) procedure (f32vector->list (f32vec f32vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (f32vector->list (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f32vec
(srfi 160 base) procedure (list->f32vector (proper-list list?) ) ⟹ f32vector?
proper-list ⟹ (list f32? )
Returns f32vector with same elements as list.
(srfi 160 base) procedure (f32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an f32vector (ie., inexact real), and #f otherwise.
(srfi 160 base) procedure (make-f64vector (size integer?) ) ⟹ f64vector?
(srfi 160 base) procedure (make-f64vector (size integer?) (fill f64?) ) ⟹ f64vector?
Returns a f64vector whose length is size. If fill is provided, all the elements of the f64vector are initialized to it.
(srfi 160 base) procedure (f64vector (value f64?) ... ) ⟹ f64vector?
Returns a f64vector initialized with values.
(srfi 160 base) procedure (f64vector? obj ) ⟹ boolean?
Returns #t if obj is a f64vector, and #f otherwise.
(srfi 160 base) procedure (f64vector-length (f64vec f64vector?) ) ⟹ integer?
Returns the length of f64vec
(srfi 160 base) procedure (f64vector-ref (f64vec f64vector?) (i integer?) ) ⟹ f64?
Returns the ith element of f64vec.
(srfi 160 base) procedure (f64vector-set! (f64vec f64vector?) (i integer?) (value f64?) ) ⟹ undefined
Sets the ith element of f64vec to value.
(srfi 160 base) procedure (f64vector->list (f64vec f64vector?) ) ⟹ list?
(srfi 160 base) procedure (f64vector->list (f64vec f64vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (f64vector->list (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f64vec
(srfi 160 base) procedure (list->f64vector (proper-list list?) ) ⟹ f64vector?
proper-list ⟹ (list f64? )
Returns f64vector with same elements as list.
(srfi 160 base) procedure (f64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an f64vector (ie., inexact real), and #f otherwise.
(srfi 160 base) procedure (make-c64vector (size integer?) ) ⟹ c64vector?
(srfi 160 base) procedure (make-c64vector (size integer?) (fill c64?) ) ⟹ c64vector?
Returns a c64vector whose length is size. If fill is provided, all the elements of the c64vector are initialized to it.
(srfi 160 base) procedure (c64vector (value c64?) ... ) ⟹ c64vector?
Returns a c64vector initialized with values.
(srfi 160 base) procedure (c64vector? obj ) ⟹ boolean?
Returns #t if obj is a c64vector, and #f otherwise.
(srfi 160 base) procedure (c64vector-length (c64vec c64vector?) ) ⟹ integer?
Returns the length of c64vec
(srfi 160 base) procedure (c64vector-ref (c64vec c64vector?) (i integer?) ) ⟹ c64?
Returns the ith element of c64vec.
(srfi 160 base) procedure (c64vector-set! (c64vec c64vector?) (i integer?) (value c64?) ) ⟹ undefined
Sets the ith element of c64vec to value.
(srfi 160 base) procedure (c64vector->list (c64vec c64vector?) ) ⟹ list?
(srfi 160 base) procedure (c64vector->list (c64vec c64vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (c64vector->list (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c64vec
(srfi 160 base) procedure (list->c64vector (proper-list list?) ) ⟹ c64vector?
proper-list ⟹ (list c64? )
Returns c64vector with same elements as list.
(srfi 160 base) procedure (c64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an c64vector (ie., inexact complex), and #f otherwise.
(srfi 160 base) procedure (make-c128vector (size integer?) ) ⟹ c128vector?
(srfi 160 base) procedure (make-c128vector (size integer?) (fill c128?) ) ⟹ c128vector?
Returns a c128vector whose length is size. If fill is provided, all the elements of the c128vector are initialized to it.
(srfi 160 base) procedure (c128vector (value c128?) ... ) ⟹ c128vector?
Returns a c128vector initialized with values.
(srfi 160 base) procedure (c128vector? obj ) ⟹ boolean?
Returns #t if obj is a c128vector, and #f otherwise.
(srfi 160 base) procedure (c128vector-length (c128vec c128vector?) ) ⟹ integer?
Returns the length of c128vec
(srfi 160 base) procedure (c128vector-ref (c128vec c128vector?) (i integer?) ) ⟹ c128?
Returns the ith element of c128vec.
(srfi 160 base) procedure (c128vector-set! (c128vec c128vector?) (i integer?) (value c128?) ) ⟹ undefined
Sets the ith element of c128vec to value.
(srfi 160 base) procedure (c128vector->list (c128vec c128vector?) ) ⟹ list?
(srfi 160 base) procedure (c128vector->list (c128vec c128vector?) (start integer?) ) ⟹ list?
(srfi 160 base) procedure (c128vector->list (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c128vec
(srfi 160 base) procedure (list->c128vector (proper-list list?) ) ⟹ c128vector?
proper-list ⟹ (list c128? )
Returns c128vector with same elements as list.
(srfi 160 base) procedure (c128? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an c128vector (ie., inexact complex), and #f otherwise.
library (srfi 160 u8)
(srfi 160 u8) procedure (make-u8vector (size integer?) ) ⟹ u8vector?
(srfi 160 u8) procedure (make-u8vector (size integer?) (fill u8?) ) ⟹ u8vector?
Returns a u8vector whose length is size. If fill is provided, all the elements of the u8vector are initialized to it.
(srfi 160 u8) procedure (u8vector (value u8?) ... ) ⟹ u8vector?
Returns a u8vector initialized with values.
(srfi 160 u8) procedure (u8vector? obj ) ⟹ boolean?
Returns #t if obj is a u8vector, and #f otherwise.
(srfi 160 u8) procedure (u8vector-length (u8vec u8vector?) ) ⟹ integer?
Returns the length of u8vec
(srfi 160 u8) procedure (u8vector-ref (u8vec u8vector?) (i integer?) ) ⟹ u8?
Returns the ith element of u8vec.
(srfi 160 u8) procedure (u8vector-set! (u8vec u8vector?) (i integer?) (value u8?) ) ⟹ undefined
Sets the ith element of u8vec to value.
(srfi 160 u8) procedure (u8vector->list (u8vec u8vector?) ) ⟹ list?
(srfi 160 u8) procedure (u8vector->list (u8vec u8vector?) (start integer?) ) ⟹ list?
(srfi 160 u8) procedure (u8vector->list (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u8vec
(srfi 160 u8) procedure (list->u8vector (proper-list list?) ) ⟹ u8vector?
proper-list ⟹ (list u8? )
Returns u8vector with same elements as list.
(srfi 160 u8) procedure (u8? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u8vector (ie., unsigned exact integer in the range 0 to (2^8)-1), and #f otherwise.
(srfi 160 u8) procedure (u8vector-unfold (f procedure?) (length integer?) seed ) ⟹ u8vector?
(srfi 160 u8) procedure (u8vector-unfold (f procedure?) (length integer?) seed ) ⟹ u8vector?
(f (index integer?) state ) ⟹ (values u8?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 u8) procedure (u8vector-copy (u8vec u8vector?) ) ⟹ u8vector?
(srfi 160 u8) procedure (u8vector-copy (u8vec u8vector?) (start integer?) ) ⟹ u8vector?
(srfi 160 u8) procedure (u8vector-copy (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ u8vector?
Makes a copy of the portion of u8vec from start to end and returns it.
(srfi 160 u8) procedure (u8vector-reverse-copy (u8vec u8vector?) ) ⟹ u8vector?
(srfi 160 u8) procedure (u8vector-reverse-copy (u8vec u8vector?) (start integer?) ) ⟹ u8vector?
(srfi 160 u8) procedure (u8vector-reverse-copy (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ u8vector?
The same as u8vector-copy, but in reverse order.
(srfi 160 u8) procedure (u8vector-append (u8vec u8vector?) ... ) ⟹ u8vector?
Returns a u8vector containing all the elements of the u8vecs in order.
(srfi 160 u8) procedure (u8vector-concatenate (list-of-u8vectors list?) ) ⟹ u8vector?
list-of-u8vectors ⟹ (list u8vector? )
The same as u8vector-append, but takes a list of u8vectors rather than multiple arguments.
(srfi 160 u8) procedure (u8vector-append-subvectors (u8vec1 u8vector?) (start1 integer?) (end1 integer?) ... ) ⟹ u8vector?
Concatenates the result of applying u8vector-copy to each triplet of u8vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 u8) procedure (u8vector-empty? (u8vec u8vector?) ) ⟹ boolean?
Returns #t if u8vec has a length of zero, and #f otherwise.
(srfi 160 u8) procedure (u8vector= (u8vec u8vector?) ... ) ⟹ boolean?
Compares the u8vecs for elementwise equality, using = to do the comparisons. Returns #f unless all u8vectors are the same length.
(srfi 160 u8) procedure (u8vector-take (u8vec u8vector?) (n integer?) ) ⟹ u8vector?
(srfi 160 u8) procedure (u8vector-take-right (u8vec u8vector?) (n integer?) ) ⟹ u8vector?
Returns a u8vector containing the first/last n elements of u8vec.
(srfi 160 u8) procedure (u8vector-drop (u8vec u8vector?) (n integer?) ) ⟹ u8vector?
(srfi 160 u8) procedure (u8vector-drop-right (u8vec u8vector?) (n integer?) ) ⟹ u8vector?
Returns a u8vector containing all except the first/last n elements of u8vec.
(srfi 160 u8) procedure (u8vector-segment (u8vec u8vector?) (n integer?) ) ⟹ list?
Returns a list of u8vectors, each of which contains n consecutive elements of u8vec. The last u8vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 u8) procedure (u8vector-fold (kons procedure?) knil (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ *
(kons state (obj1 u8?) (obj2 u8?) ... ) ⟹ *
(srfi 160 u8) procedure (u8vector-fold-right (kons procedure?) knil (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ *
(kons state (obj1 u8?) (obj2 u8?) ... ) ⟹ *
When one u8vector argument u8vec is given, folds kons over the elements of u8vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple u8vector arguments are given, kons is called with the current state value and each value from all the vectors; u8vector-fold scans elements from left to right, while u8vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 u8) procedure (u8vector-map (proc procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ vector?
(proc (val1 u8?) ... ) ⟹ *
(srfi 160 u8) procedure (u8vector-map! (proc procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ undefined
(proc (val1 u8?) ... ) ⟹ *
(srfi 160 u8) procedure (u8vector-for-each (proc procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ undefined
(proc (val1 u8?) ... ) ⟹ undefined
Iterate over the elements of u8vec and apply f to each, returning respectively a u8vector of the results, an undefined value with the results placed back in u8vec, and an undefined value with no change to u8vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For u8vector-map!, only u8vec is modified even when multiple vectors are passed.
If u8vector-map or u8vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 u8) procedure (u8vector-count (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer?
(pred? (val1 u8?) (val2 u8?) ... ) ⟹ *
Call pred? on each element of u8vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 u8) procedure (u8vector-cumulate (f procedure?) knil (u8vec u8vector?) ) ⟹ u8vector?
(f state (value u8?) ) ⟹ *
Like u8vector-fold, but returns an u8vector of partial results rather than just the final result.
(srfi 160 u8) procedure (u8vector-take-while (pred? procedure?) (u8vec u8vector?) ) ⟹ u8vector?
(pred? (value u8?) ) ⟹ boolean?
(srfi 160 u8) procedure (u8vector-take-while-right (pred? procedure?) (u8vec u8vector?) ) ⟹ u8vector?
(pred? (value u8?) ) ⟹ boolean?
Return the shortest prefix/suffix of u8vec all of whose elements satisfy pred?.
(srfi 160 u8) procedure (u8vector-drop-while (pred? procedure?) (u8vec u8vector?) ) ⟹ u8vector?
(pred? (value u8?) ) ⟹ boolean?
(srfi 160 u8) procedure (u8vector-drop-while-right (pred? procedure?) (u8vec u8vector?) ) ⟹ u8vector?
(pred? (value u8?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of u8vec such that all its elements satisfy pred.
(srfi 160 u8) procedure (u8vector-index (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u8?) (value2 u8?) ... ) ⟹ *
(srfi 160 u8) procedure (u8vector-index-right (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u8?) (value2 u8?) ... ) ⟹ *
Return the index of the first/last element of u8vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u8vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for u8vector-index-right.
(srfi 160 u8) procedure (u8vector-skip (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u8?) (value2 u8?) ... ) ⟹ *
(srfi 160 u8) procedure (u8vector-skip-right (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u8?) (value2 u8?) ... ) ⟹ *
Returns the index of the first/last element of u8vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u8vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for u8vector-skip-right.
(srfi 160 u8) procedure (u8vector-any (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ *
(pred? (val1 u8?) (val2 u8?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the u8vec, or #f if there is no such element. If u8vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 u8) procedure (u8vector-every (pred? procedure?) (u8vec1 u8vector?) (u8vec2 u8vector?) ... ) ⟹ *
(pred? (val1 u8?) (val2 u8?) ... ) ⟹ *
If all elements from u8vec satisfy pred?, return the last result of pred?. If not all do, return #f. If u8vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 u8) procedure (u8vector-partition (pred? procedure?) (u8vec u8vector?) ) ⟹ (values u8vector?integer?)
(pred? (value u8?) ) ⟹ boolean?
Returns an u8vector of the same type as u8vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new u8vector and the number of elements satisfying pred?.
(srfi 160 u8) procedure (u8vector-filter (pred? procedure?) (u8vec1 u8vector?) ) ⟹ u8vector?
(pred? (val u8?) ) ⟹ boolean?
(srfi 160 u8) procedure (u8vector-remove (pred? procedure?) (u8vec1 u8vector?) ) ⟹ u8vector?
(pred? (val u8?) ) ⟹ boolean?
Return an u8vector containing the elements of u8vec that satisfy / do not satisfy pred?.
(srfi 160 u8) procedure (u8vector-swap! (u8vec u8vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of u8vec.
(srfi 160 u8) procedure (u8vector-fill! (u8vec u8vector?) (fill u8?) ) ⟹ undefined
(srfi 160 u8) procedure (u8vector-fill! (u8vec u8vector?) (fill u8?) (start integer?) ) ⟹ undefined
(srfi 160 u8) procedure (u8vector-fill! (u8vec u8vector?) (fill u8?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of u8vec from start to end with the value fill.
(srfi 160 u8) procedure (u8vector-reverse! (u8vec u8vector?) ) ⟹ undefined
(srfi 160 u8) procedure (u8vector-reverse! (u8vec u8vector?) (start integer?) ) ⟹ undefined
(srfi 160 u8) procedure (u8vector-reverse! (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of u8vec from start to end.
(srfi 160 u8) procedure (u8vector-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) ) ⟹ undefined
(srfi 160 u8) procedure (u8vector-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) (start integer?) ) ⟹ undefined
(srfi 160 u8) procedure (u8vector-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of u8from from start to end onto u8to, starting at index at.
(srfi 160 u8) procedure (u8vector-reverse-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) ) ⟹ undefined
(srfi 160 u8) procedure (u8vector-reverse-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) (start integer?) ) ⟹ undefined
(srfi 160 u8) procedure (u8vector-reverse-copy! (u8to u8vector?) (at integer?) (u8from u8vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as u8vector-copy!, but copies in reverse
(srfi 160 u8) procedure (u8vector-unfold! (f procedure?) (u8vec u8vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like u8vector-unfold, but the elements are copied into the vector u8vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 u8) procedure (u8vector-unfold-right! (f procedure?) (u8vec u8vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as u8vector-unfold!, but initializes the u8vector from right to left.
(srfi 160 u8) procedure (reverse-u8vector->list (u8vec u8vector?) ) ⟹ list?
(srfi 160 u8) procedure (reverse-u8vector->list (u8vec u8vector?) (start integer?) ) ⟹ list?
(srfi 160 u8) procedure (reverse-u8vector->list (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u8vec in reverse order.
(srfi 160 u8) procedure (reverse-list->u8vector (proper-list list?) ) ⟹ u8vector?
Returns u8vector with same elements as list in reverse order.
(srfi 160 u8) procedure (u8vector->vector (u8vec u8vector?) ) ⟹ vector?
(srfi 160 u8) procedure (u8vector->vector (u8vec u8vector?) (start integer?) ) ⟹ vector?
(srfi 160 u8) procedure (u8vector->vector (u8vec u8vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as u8vec.
(srfi 160 u8) procedure (vector->u8vector (vec vector?) ) ⟹ u8vector?
(srfi 160 u8) procedure (vector->u8vector (vec vector?) (start integer?) ) ⟹ u8vector?
(srfi 160 u8) procedure (vector->u8vector (vec vector?) (start integer?) (end integer?) ) ⟹ u8vector?
Returns u8vector with same elements as vec.
(srfi 160 u8) procedure (make-u8vector-generator (u8vector u8vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / u8? /
Returns a SRFI 121 generator that generates all the values of u8vector in order. Note that the generator is finite.
u8vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of u8vector.
(srfi 160 u8) procedure (write-u8vector (u8vec u8vector) ) ⟹ undefined
(srfi 160 u8) procedure (write-u8vector (u8vec u8vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of u8vec in the lexical syntax explained below.
library (srfi 160 s8)
(srfi 160 s8) procedure (make-s8vector (size integer?) ) ⟹ s8vector?
(srfi 160 s8) procedure (make-s8vector (size integer?) (fill s8?) ) ⟹ s8vector?
Returns a s8vector whose length is size. If fill is provided, all the elements of the s8vector are initialized to it.
(srfi 160 s8) procedure (s8vector (value s8?) ... ) ⟹ s8vector?
Returns a s8vector initialized with values.
(srfi 160 s8) procedure (s8vector? obj ) ⟹ boolean?
Returns #t if obj is a s8vector, and #f otherwise.
(srfi 160 s8) procedure (s8vector-length (s8vec s8vector?) ) ⟹ integer?
Returns the length of s8vec
(srfi 160 s8) procedure (s8vector-ref (s8vec s8vector?) (i integer?) ) ⟹ s8?
Returns the ith element of s8vec.
(srfi 160 s8) procedure (s8vector-set! (s8vec s8vector?) (i integer?) (value s8?) ) ⟹ undefined
Sets the ith element of s8vec to value.
(srfi 160 s8) procedure (s8vector->list (s8vec s8vector?) ) ⟹ list?
(srfi 160 s8) procedure (s8vector->list (s8vec s8vector?) (start integer?) ) ⟹ list?
(srfi 160 s8) procedure (s8vector->list (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s8vec
(srfi 160 s8) procedure (list->s8vector (proper-list list?) ) ⟹ s8vector?
proper-list ⟹ (list s8? )
Returns s8vector with same elements as list.
(srfi 160 s8) procedure (s8? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s8vector (ie., signed exact integer in the range -(2^7) to (2^7)-1), and #f otherwise.
(srfi 160 s8) procedure (s8vector-unfold (f procedure?) (length integer?) seed ) ⟹ s8vector?
(srfi 160 s8) procedure (s8vector-unfold (f procedure?) (length integer?) seed ) ⟹ s8vector?
(f (index integer?) state ) ⟹ (values s8?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 s8) procedure (s8vector-copy (s8vec s8vector?) ) ⟹ s8vector?
(srfi 160 s8) procedure (s8vector-copy (s8vec s8vector?) (start integer?) ) ⟹ s8vector?
(srfi 160 s8) procedure (s8vector-copy (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ s8vector?
Makes a copy of the portion of s8vec from start to end and returns it.
(srfi 160 s8) procedure (s8vector-reverse-copy (s8vec s8vector?) ) ⟹ s8vector?
(srfi 160 s8) procedure (s8vector-reverse-copy (s8vec s8vector?) (start integer?) ) ⟹ s8vector?
(srfi 160 s8) procedure (s8vector-reverse-copy (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ s8vector?
The same as s8vector-copy, but in reverse order.
(srfi 160 s8) procedure (s8vector-append (s8vec s8vector?) ... ) ⟹ s8vector?
Returns a s8vector containing all the elements of the s8vecs in order.
(srfi 160 s8) procedure (s8vector-concatenate (list-of-s8vectors list?) ) ⟹ s8vector?
list-of-s8vectors ⟹ (list s8vector? )
The same as s8vector-append, but takes a list of s8vectors rather than multiple arguments.
(srfi 160 s8) procedure (s8vector-append-subvectors (s8vec1 s8vector?) (start1 integer?) (end1 integer?) ... ) ⟹ s8vector?
Concatenates the result of applying s8vector-copy to each triplet of s8vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 s8) procedure (s8vector-empty? (s8vec s8vector?) ) ⟹ boolean?
Returns #t if s8vec has a length of zero, and #f otherwise.
(srfi 160 s8) procedure (s8vector= (s8vec s8vector?) ... ) ⟹ boolean?
Compares the s8vecs for elementwise equality, using = to do the comparisons. Returns #f unless all s8vectors are the same length.
(srfi 160 s8) procedure (s8vector-take (s8vec s8vector?) (n integer?) ) ⟹ s8vector?
(srfi 160 s8) procedure (s8vector-take-right (s8vec s8vector?) (n integer?) ) ⟹ s8vector?
Returns a s8vector containing the first/last n elements of s8vec.
(srfi 160 s8) procedure (s8vector-drop (s8vec s8vector?) (n integer?) ) ⟹ s8vector?
(srfi 160 s8) procedure (s8vector-drop-right (s8vec s8vector?) (n integer?) ) ⟹ s8vector?
Returns a s8vector containing all except the first/last n elements of s8vec.
(srfi 160 s8) procedure (s8vector-segment (s8vec s8vector?) (n integer?) ) ⟹ list?
Returns a list of s8vectors, each of which contains n consecutive elements of s8vec. The last s8vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 s8) procedure (s8vector-fold (kons procedure?) knil (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ *
(kons state (obj1 s8?) (obj2 s8?) ... ) ⟹ *
(srfi 160 s8) procedure (s8vector-fold-right (kons procedure?) knil (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ *
(kons state (obj1 s8?) (obj2 s8?) ... ) ⟹ *
When one s8vector argument s8vec is given, folds kons over the elements of s8vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple s8vector arguments are given, kons is called with the current state value and each value from all the vectors; s8vector-fold scans elements from left to right, while s8vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 s8) procedure (s8vector-map (proc procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ vector?
(proc (val1 s8?) ... ) ⟹ *
(srfi 160 s8) procedure (s8vector-map! (proc procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ undefined
(proc (val1 s8?) ... ) ⟹ *
(srfi 160 s8) procedure (s8vector-for-each (proc procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ undefined
(proc (val1 s8?) ... ) ⟹ undefined
Iterate over the elements of s8vec and apply f to each, returning respectively a s8vector of the results, an undefined value with the results placed back in s8vec, and an undefined value with no change to s8vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For s8vector-map!, only s8vec is modified even when multiple vectors are passed.
If s8vector-map or s8vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 s8) procedure (s8vector-count (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer?
(pred? (val1 s8?) (val2 s8?) ... ) ⟹ *
Call pred? on each element of s8vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 s8) procedure (s8vector-cumulate (f procedure?) knil (s8vec s8vector?) ) ⟹ s8vector?
(f state (value s8?) ) ⟹ *
Like s8vector-fold, but returns an s8vector of partial results rather than just the final result.
(srfi 160 s8) procedure (s8vector-take-while (pred? procedure?) (s8vec s8vector?) ) ⟹ s8vector?
(pred? (value s8?) ) ⟹ boolean?
(srfi 160 s8) procedure (s8vector-take-while-right (pred? procedure?) (s8vec s8vector?) ) ⟹ s8vector?
(pred? (value s8?) ) ⟹ boolean?
Return the shortest prefix/suffix of s8vec all of whose elements satisfy pred?.
(srfi 160 s8) procedure (s8vector-drop-while (pred? procedure?) (s8vec s8vector?) ) ⟹ s8vector?
(pred? (value s8?) ) ⟹ boolean?
(srfi 160 s8) procedure (s8vector-drop-while-right (pred? procedure?) (s8vec s8vector?) ) ⟹ s8vector?
(pred? (value s8?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of s8vec such that all its elements satisfy pred.
(srfi 160 s8) procedure (s8vector-index (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s8?) (value2 s8?) ... ) ⟹ *
(srfi 160 s8) procedure (s8vector-index-right (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s8?) (value2 s8?) ... ) ⟹ *
Return the index of the first/last element of s8vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s8vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for s8vector-index-right.
(srfi 160 s8) procedure (s8vector-skip (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s8?) (value2 s8?) ... ) ⟹ *
(srfi 160 s8) procedure (s8vector-skip-right (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s8?) (value2 s8?) ... ) ⟹ *
Returns the index of the first/last element of s8vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s8vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for s8vector-skip-right.
(srfi 160 s8) procedure (s8vector-any (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ *
(pred? (val1 s8?) (val2 s8?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the s8vec, or #f if there is no such element. If s8vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 s8) procedure (s8vector-every (pred? procedure?) (s8vec1 s8vector?) (s8vec2 s8vector?) ... ) ⟹ *
(pred? (val1 s8?) (val2 s8?) ... ) ⟹ *
If all elements from s8vec satisfy pred?, return the last result of pred?. If not all do, return #f. If s8vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 s8) procedure (s8vector-partition (pred? procedure?) (s8vec s8vector?) ) ⟹ (values s8vector?integer?)
(pred? (value s8?) ) ⟹ boolean?
Returns an s8vector of the same type as s8vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new s8vector and the number of elements satisfying pred?.
(srfi 160 s8) procedure (s8vector-filter (pred? procedure?) (s8vec1 s8vector?) ) ⟹ s8vector?
(pred? (val s8?) ) ⟹ boolean?
(srfi 160 s8) procedure (s8vector-remove (pred? procedure?) (s8vec1 s8vector?) ) ⟹ s8vector?
(pred? (val s8?) ) ⟹ boolean?
Return an s8vector containing the elements of s8vec that satisfy / do not satisfy pred?.
(srfi 160 s8) procedure (s8vector-swap! (s8vec s8vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of s8vec.
(srfi 160 s8) procedure (s8vector-fill! (s8vec s8vector?) (fill s8?) ) ⟹ undefined
(srfi 160 s8) procedure (s8vector-fill! (s8vec s8vector?) (fill s8?) (start integer?) ) ⟹ undefined
(srfi 160 s8) procedure (s8vector-fill! (s8vec s8vector?) (fill s8?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of s8vec from start to end with the value fill.
(srfi 160 s8) procedure (s8vector-reverse! (s8vec s8vector?) ) ⟹ undefined
(srfi 160 s8) procedure (s8vector-reverse! (s8vec s8vector?) (start integer?) ) ⟹ undefined
(srfi 160 s8) procedure (s8vector-reverse! (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of s8vec from start to end.
(srfi 160 s8) procedure (s8vector-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) ) ⟹ undefined
(srfi 160 s8) procedure (s8vector-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) (start integer?) ) ⟹ undefined
(srfi 160 s8) procedure (s8vector-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of s8from from start to end onto s8to, starting at index at.
(srfi 160 s8) procedure (s8vector-reverse-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) ) ⟹ undefined
(srfi 160 s8) procedure (s8vector-reverse-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) (start integer?) ) ⟹ undefined
(srfi 160 s8) procedure (s8vector-reverse-copy! (s8to s8vector?) (at integer?) (s8from s8vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as s8vector-copy!, but copies in reverse
(srfi 160 s8) procedure (s8vector-unfold! (f procedure?) (s8vec s8vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like s8vector-unfold, but the elements are copied into the vector s8vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 s8) procedure (s8vector-unfold-right! (f procedure?) (s8vec s8vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as s8vector-unfold!, but initializes the s8vector from right to left.
(srfi 160 s8) procedure (reverse-s8vector->list (s8vec s8vector?) ) ⟹ list?
(srfi 160 s8) procedure (reverse-s8vector->list (s8vec s8vector?) (start integer?) ) ⟹ list?
(srfi 160 s8) procedure (reverse-s8vector->list (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s8vec in reverse order.
(srfi 160 s8) procedure (reverse-list->s8vector (proper-list list?) ) ⟹ s8vector?
Returns s8vector with same elements as list in reverse order.
(srfi 160 s8) procedure (s8vector->vector (s8vec s8vector?) ) ⟹ vector?
(srfi 160 s8) procedure (s8vector->vector (s8vec s8vector?) (start integer?) ) ⟹ vector?
(srfi 160 s8) procedure (s8vector->vector (s8vec s8vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as s8vec.
(srfi 160 s8) procedure (vector->s8vector (vec vector?) ) ⟹ s8vector?
(srfi 160 s8) procedure (vector->s8vector (vec vector?) (start integer?) ) ⟹ s8vector?
(srfi 160 s8) procedure (vector->s8vector (vec vector?) (start integer?) (end integer?) ) ⟹ s8vector?
Returns s8vector with same elements as vec.
(srfi 160 s8) procedure (make-s8vector-generator (s8vector s8vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / s8? /
Returns a SRFI 121 generator that generates all the values of s8vector in order. Note that the generator is finite.
s8vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of s8vector.
(srfi 160 s8) procedure (write-s8vector (s8vec s8vector) ) ⟹ undefined
(srfi 160 s8) procedure (write-s8vector (s8vec s8vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of s8vec in the lexical syntax explained below.
library (srfi 160 u16)
(srfi 160 u16) procedure (make-u16vector (size integer?) ) ⟹ u16vector?
(srfi 160 u16) procedure (make-u16vector (size integer?) (fill u16?) ) ⟹ u16vector?
Returns a u16vector whose length is size. If fill is provided, all the elements of the u16vector are initialized to it.
(srfi 160 u16) procedure (u16vector (value u16?) ... ) ⟹ u16vector?
Returns a u16vector initialized with values.
(srfi 160 u16) procedure (u16vector? obj ) ⟹ boolean?
Returns #t if obj is a u16vector, and #f otherwise.
(srfi 160 u16) procedure (u16vector-length (u16vec u16vector?) ) ⟹ integer?
Returns the length of u16vec
(srfi 160 u16) procedure (u16vector-ref (u16vec u16vector?) (i integer?) ) ⟹ u16?
Returns the ith element of u16vec.
(srfi 160 u16) procedure (u16vector-set! (u16vec u16vector?) (i integer?) (value u16?) ) ⟹ undefined
Sets the ith element of u16vec to value.
(srfi 160 u16) procedure (u16vector->list (u16vec u16vector?) ) ⟹ list?
(srfi 160 u16) procedure (u16vector->list (u16vec u16vector?) (start integer?) ) ⟹ list?
(srfi 160 u16) procedure (u16vector->list (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u16vec
(srfi 160 u16) procedure (list->u16vector (proper-list list?) ) ⟹ u16vector?
proper-list ⟹ (list u16? )
Returns u16vector with same elements as list.
(srfi 160 u16) procedure (u16? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u16vector (ie., unsigned exact integer in the range 0 to (2^16)-1), and #f otherwise.
(srfi 160 u16) procedure (u16vector-unfold (f procedure?) (length integer?) seed ) ⟹ u16vector?
(srfi 160 u16) procedure (u16vector-unfold (f procedure?) (length integer?) seed ) ⟹ u16vector?
(f (index integer?) state ) ⟹ (values u16?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 u16) procedure (u16vector-copy (u16vec u16vector?) ) ⟹ u16vector?
(srfi 160 u16) procedure (u16vector-copy (u16vec u16vector?) (start integer?) ) ⟹ u16vector?
(srfi 160 u16) procedure (u16vector-copy (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ u16vector?
Makes a copy of the portion of u16vec from start to end and returns it.
(srfi 160 u16) procedure (u16vector-reverse-copy (u16vec u16vector?) ) ⟹ u16vector?
(srfi 160 u16) procedure (u16vector-reverse-copy (u16vec u16vector?) (start integer?) ) ⟹ u16vector?
(srfi 160 u16) procedure (u16vector-reverse-copy (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ u16vector?
The same as u16vector-copy, but in reverse order.
(srfi 160 u16) procedure (u16vector-append (u16vec u16vector?) ... ) ⟹ u16vector?
Returns a u16vector containing all the elements of the u16vecs in order.
(srfi 160 u16) procedure (u16vector-concatenate (list-of-u16vectors list?) ) ⟹ u16vector?
list-of-u16vectors ⟹ (list u16vector? )
The same as u16vector-append, but takes a list of u16vectors rather than multiple arguments.
(srfi 160 u16) procedure (u16vector-append-subvectors (u16vec1 u16vector?) (start1 integer?) (end1 integer?) ... ) ⟹ u16vector?
Concatenates the result of applying u16vector-copy to each triplet of u16vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 u16) procedure (u16vector-empty? (u16vec u16vector?) ) ⟹ boolean?
Returns #t if u16vec has a length of zero, and #f otherwise.
(srfi 160 u16) procedure (u16vector= (u16vec u16vector?) ... ) ⟹ boolean?
Compares the u16vecs for elementwise equality, using = to do the comparisons. Returns #f unless all u16vectors are the same length.
(srfi 160 u16) procedure (u16vector-take (u16vec u16vector?) (n integer?) ) ⟹ u16vector?
(srfi 160 u16) procedure (u16vector-take-right (u16vec u16vector?) (n integer?) ) ⟹ u16vector?
Returns a u16vector containing the first/last n elements of u16vec.
(srfi 160 u16) procedure (u16vector-drop (u16vec u16vector?) (n integer?) ) ⟹ u16vector?
(srfi 160 u16) procedure (u16vector-drop-right (u16vec u16vector?) (n integer?) ) ⟹ u16vector?
Returns a u16vector containing all except the first/last n elements of u16vec.
(srfi 160 u16) procedure (u16vector-segment (u16vec u16vector?) (n integer?) ) ⟹ list?
Returns a list of u16vectors, each of which contains n consecutive elements of u16vec. The last u16vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 u16) procedure (u16vector-fold (kons procedure?) knil (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ *
(kons state (obj1 u16?) (obj2 u16?) ... ) ⟹ *
(srfi 160 u16) procedure (u16vector-fold-right (kons procedure?) knil (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ *
(kons state (obj1 u16?) (obj2 u16?) ... ) ⟹ *
When one u16vector argument u16vec is given, folds kons over the elements of u16vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple u16vector arguments are given, kons is called with the current state value and each value from all the vectors; u16vector-fold scans elements from left to right, while u16vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 u16) procedure (u16vector-map (proc procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ vector?
(proc (val1 u16?) ... ) ⟹ *
(srfi 160 u16) procedure (u16vector-map! (proc procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ undefined
(proc (val1 u16?) ... ) ⟹ *
(srfi 160 u16) procedure (u16vector-for-each (proc procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ undefined
(proc (val1 u16?) ... ) ⟹ undefined
Iterate over the elements of u16vec and apply f to each, returning respectively a u16vector of the results, an undefined value with the results placed back in u16vec, and an undefined value with no change to u16vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For u16vector-map!, only u16vec is modified even when multiple vectors are passed.
If u16vector-map or u16vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 u16) procedure (u16vector-count (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer?
(pred? (val1 u16?) (val2 u16?) ... ) ⟹ *
Call pred? on each element of u16vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 u16) procedure (u16vector-cumulate (f procedure?) knil (u16vec u16vector?) ) ⟹ u16vector?
(f state (value u16?) ) ⟹ *
Like u16vector-fold, but returns an u16vector of partial results rather than just the final result.
(srfi 160 u16) procedure (u16vector-take-while (pred? procedure?) (u16vec u16vector?) ) ⟹ u16vector?
(pred? (value u16?) ) ⟹ boolean?
(srfi 160 u16) procedure (u16vector-take-while-right (pred? procedure?) (u16vec u16vector?) ) ⟹ u16vector?
(pred? (value u16?) ) ⟹ boolean?
Return the shortest prefix/suffix of u16vec all of whose elements satisfy pred?.
(srfi 160 u16) procedure (u16vector-drop-while (pred? procedure?) (u16vec u16vector?) ) ⟹ u16vector?
(pred? (value u16?) ) ⟹ boolean?
(srfi 160 u16) procedure (u16vector-drop-while-right (pred? procedure?) (u16vec u16vector?) ) ⟹ u16vector?
(pred? (value u16?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of u16vec such that all its elements satisfy pred.
(srfi 160 u16) procedure (u16vector-index (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u16?) (value2 u16?) ... ) ⟹ *
(srfi 160 u16) procedure (u16vector-index-right (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u16?) (value2 u16?) ... ) ⟹ *
Return the index of the first/last element of u16vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u16vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for u16vector-index-right.
(srfi 160 u16) procedure (u16vector-skip (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u16?) (value2 u16?) ... ) ⟹ *
(srfi 160 u16) procedure (u16vector-skip-right (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u16?) (value2 u16?) ... ) ⟹ *
Returns the index of the first/last element of u16vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u16vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for u16vector-skip-right.
(srfi 160 u16) procedure (u16vector-any (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ *
(pred? (val1 u16?) (val2 u16?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the u16vec, or #f if there is no such element. If u16vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 u16) procedure (u16vector-every (pred? procedure?) (u16vec1 u16vector?) (u16vec2 u16vector?) ... ) ⟹ *
(pred? (val1 u16?) (val2 u16?) ... ) ⟹ *
If all elements from u16vec satisfy pred?, return the last result of pred?. If not all do, return #f. If u16vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 u16) procedure (u16vector-partition (pred? procedure?) (u16vec u16vector?) ) ⟹ (values u16vector?integer?)
(pred? (value u16?) ) ⟹ boolean?
Returns an u16vector of the same type as u16vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new u16vector and the number of elements satisfying pred?.
(srfi 160 u16) procedure (u16vector-filter (pred? procedure?) (u16vec1 u16vector?) ) ⟹ u16vector?
(pred? (val u16?) ) ⟹ boolean?
(srfi 160 u16) procedure (u16vector-remove (pred? procedure?) (u16vec1 u16vector?) ) ⟹ u16vector?
(pred? (val u16?) ) ⟹ boolean?
Return an u16vector containing the elements of u16vec that satisfy / do not satisfy pred?.
(srfi 160 u16) procedure (u16vector-swap! (u16vec u16vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of u16vec.
(srfi 160 u16) procedure (u16vector-fill! (u16vec u16vector?) (fill u16?) ) ⟹ undefined
(srfi 160 u16) procedure (u16vector-fill! (u16vec u16vector?) (fill u16?) (start integer?) ) ⟹ undefined
(srfi 160 u16) procedure (u16vector-fill! (u16vec u16vector?) (fill u16?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of u16vec from start to end with the value fill.
(srfi 160 u16) procedure (u16vector-reverse! (u16vec u16vector?) ) ⟹ undefined
(srfi 160 u16) procedure (u16vector-reverse! (u16vec u16vector?) (start integer?) ) ⟹ undefined
(srfi 160 u16) procedure (u16vector-reverse! (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of u16vec from start to end.
(srfi 160 u16) procedure (u16vector-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) ) ⟹ undefined
(srfi 160 u16) procedure (u16vector-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) (start integer?) ) ⟹ undefined
(srfi 160 u16) procedure (u16vector-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of u16from from start to end onto u16to, starting at index at.
(srfi 160 u16) procedure (u16vector-reverse-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) ) ⟹ undefined
(srfi 160 u16) procedure (u16vector-reverse-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) (start integer?) ) ⟹ undefined
(srfi 160 u16) procedure (u16vector-reverse-copy! (u16to u16vector?) (at integer?) (u16from u16vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as u16vector-copy!, but copies in reverse
(srfi 160 u16) procedure (u16vector-unfold! (f procedure?) (u16vec u16vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like u16vector-unfold, but the elements are copied into the vector u16vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 u16) procedure (u16vector-unfold-right! (f procedure?) (u16vec u16vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as u16vector-unfold!, but initializes the u16vector from right to left.
(srfi 160 u16) procedure (reverse-u16vector->list (u16vec u16vector?) ) ⟹ list?
(srfi 160 u16) procedure (reverse-u16vector->list (u16vec u16vector?) (start integer?) ) ⟹ list?
(srfi 160 u16) procedure (reverse-u16vector->list (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u16vec in reverse order.
(srfi 160 u16) procedure (reverse-list->u16vector (proper-list list?) ) ⟹ u16vector?
Returns u16vector with same elements as list in reverse order.
(srfi 160 u16) procedure (u16vector->vector (u16vec u16vector?) ) ⟹ vector?
(srfi 160 u16) procedure (u16vector->vector (u16vec u16vector?) (start integer?) ) ⟹ vector?
(srfi 160 u16) procedure (u16vector->vector (u16vec u16vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as u16vec.
(srfi 160 u16) procedure (vector->u16vector (vec vector?) ) ⟹ u16vector?
(srfi 160 u16) procedure (vector->u16vector (vec vector?) (start integer?) ) ⟹ u16vector?
(srfi 160 u16) procedure (vector->u16vector (vec vector?) (start integer?) (end integer?) ) ⟹ u16vector?
Returns u16vector with same elements as vec.
(srfi 160 u16) procedure (make-u16vector-generator (u16vector u16vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / u16? /
Returns a SRFI 121 generator that generates all the values of u16vector in order. Note that the generator is finite.
u16vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of u16vector.
(srfi 160 u16) procedure (write-u16vector (u16vec u16vector) ) ⟹ undefined
(srfi 160 u16) procedure (write-u16vector (u16vec u16vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of u16vec in the lexical syntax explained below.
library (srfi 160 s16)
(srfi 160 s16) procedure (make-s16vector (size integer?) ) ⟹ s16vector?
(srfi 160 s16) procedure (make-s16vector (size integer?) (fill s16?) ) ⟹ s16vector?
Returns a s16vector whose length is size. If fill is provided, all the elements of the s16vector are initialized to it.
(srfi 160 s16) procedure (s16vector (value s16?) ... ) ⟹ s16vector?
Returns a s16vector initialized with values.
(srfi 160 s16) procedure (s16vector? obj ) ⟹ boolean?
Returns #t if obj is a s16vector, and #f otherwise.
(srfi 160 s16) procedure (s16vector-length (s16vec s16vector?) ) ⟹ integer?
Returns the length of s16vec
(srfi 160 s16) procedure (s16vector-ref (s16vec s16vector?) (i integer?) ) ⟹ s16?
Returns the ith element of s16vec.
(srfi 160 s16) procedure (s16vector-set! (s16vec s16vector?) (i integer?) (value s16?) ) ⟹ undefined
Sets the ith element of s16vec to value.
(srfi 160 s16) procedure (s16vector->list (s16vec s16vector?) ) ⟹ list?
(srfi 160 s16) procedure (s16vector->list (s16vec s16vector?) (start integer?) ) ⟹ list?
(srfi 160 s16) procedure (s16vector->list (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s16vec
(srfi 160 s16) procedure (list->s16vector (proper-list list?) ) ⟹ s16vector?
proper-list ⟹ (list s16? )
Returns s16vector with same elements as list.
(srfi 160 s16) procedure (s16? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s16vector (ie., signed exact integer in the range -(2^15) to (2^15)-1), and #f otherwise.
(srfi 160 s16) procedure (s16vector-unfold (f procedure?) (length integer?) seed ) ⟹ s16vector?
(srfi 160 s16) procedure (s16vector-unfold (f procedure?) (length integer?) seed ) ⟹ s16vector?
(f (index integer?) state ) ⟹ (values s16?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 s16) procedure (s16vector-copy (s16vec s16vector?) ) ⟹ s16vector?
(srfi 160 s16) procedure (s16vector-copy (s16vec s16vector?) (start integer?) ) ⟹ s16vector?
(srfi 160 s16) procedure (s16vector-copy (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ s16vector?
Makes a copy of the portion of s16vec from start to end and returns it.
(srfi 160 s16) procedure (s16vector-reverse-copy (s16vec s16vector?) ) ⟹ s16vector?
(srfi 160 s16) procedure (s16vector-reverse-copy (s16vec s16vector?) (start integer?) ) ⟹ s16vector?
(srfi 160 s16) procedure (s16vector-reverse-copy (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ s16vector?
The same as s16vector-copy, but in reverse order.
(srfi 160 s16) procedure (s16vector-append (s16vec s16vector?) ... ) ⟹ s16vector?
Returns a s16vector containing all the elements of the s16vecs in order.
(srfi 160 s16) procedure (s16vector-concatenate (list-of-s16vectors list?) ) ⟹ s16vector?
list-of-s16vectors ⟹ (list s16vector? )
The same as s16vector-append, but takes a list of s16vectors rather than multiple arguments.
(srfi 160 s16) procedure (s16vector-append-subvectors (s16vec1 s16vector?) (start1 integer?) (end1 integer?) ... ) ⟹ s16vector?
Concatenates the result of applying s16vector-copy to each triplet of s16vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 s16) procedure (s16vector-empty? (s16vec s16vector?) ) ⟹ boolean?
Returns #t if s16vec has a length of zero, and #f otherwise.
(srfi 160 s16) procedure (s16vector= (s16vec s16vector?) ... ) ⟹ boolean?
Compares the s16vecs for elementwise equality, using = to do the comparisons. Returns #f unless all s16vectors are the same length.
(srfi 160 s16) procedure (s16vector-take (s16vec s16vector?) (n integer?) ) ⟹ s16vector?
(srfi 160 s16) procedure (s16vector-take-right (s16vec s16vector?) (n integer?) ) ⟹ s16vector?
Returns a s16vector containing the first/last n elements of s16vec.
(srfi 160 s16) procedure (s16vector-drop (s16vec s16vector?) (n integer?) ) ⟹ s16vector?
(srfi 160 s16) procedure (s16vector-drop-right (s16vec s16vector?) (n integer?) ) ⟹ s16vector?
Returns a s16vector containing all except the first/last n elements of s16vec.
(srfi 160 s16) procedure (s16vector-segment (s16vec s16vector?) (n integer?) ) ⟹ list?
Returns a list of s16vectors, each of which contains n consecutive elements of s16vec. The last s16vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 s16) procedure (s16vector-fold (kons procedure?) knil (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ *
(kons state (obj1 s16?) (obj2 s16?) ... ) ⟹ *
(srfi 160 s16) procedure (s16vector-fold-right (kons procedure?) knil (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ *
(kons state (obj1 s16?) (obj2 s16?) ... ) ⟹ *
When one s16vector argument s16vec is given, folds kons over the elements of s16vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple s16vector arguments are given, kons is called with the current state value and each value from all the vectors; s16vector-fold scans elements from left to right, while s16vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 s16) procedure (s16vector-map (proc procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ vector?
(proc (val1 s16?) ... ) ⟹ *
(srfi 160 s16) procedure (s16vector-map! (proc procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ undefined
(proc (val1 s16?) ... ) ⟹ *
(srfi 160 s16) procedure (s16vector-for-each (proc procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ undefined
(proc (val1 s16?) ... ) ⟹ undefined
Iterate over the elements of s16vec and apply f to each, returning respectively a s16vector of the results, an undefined value with the results placed back in s16vec, and an undefined value with no change to s16vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For s16vector-map!, only s16vec is modified even when multiple vectors are passed.
If s16vector-map or s16vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 s16) procedure (s16vector-count (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer?
(pred? (val1 s16?) (val2 s16?) ... ) ⟹ *
Call pred? on each element of s16vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 s16) procedure (s16vector-cumulate (f procedure?) knil (s16vec s16vector?) ) ⟹ s16vector?
(f state (value s16?) ) ⟹ *
Like s16vector-fold, but returns an s16vector of partial results rather than just the final result.
(srfi 160 s16) procedure (s16vector-take-while (pred? procedure?) (s16vec s16vector?) ) ⟹ s16vector?
(pred? (value s16?) ) ⟹ boolean?
(srfi 160 s16) procedure (s16vector-take-while-right (pred? procedure?) (s16vec s16vector?) ) ⟹ s16vector?
(pred? (value s16?) ) ⟹ boolean?
Return the shortest prefix/suffix of s16vec all of whose elements satisfy pred?.
(srfi 160 s16) procedure (s16vector-drop-while (pred? procedure?) (s16vec s16vector?) ) ⟹ s16vector?
(pred? (value s16?) ) ⟹ boolean?
(srfi 160 s16) procedure (s16vector-drop-while-right (pred? procedure?) (s16vec s16vector?) ) ⟹ s16vector?
(pred? (value s16?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of s16vec such that all its elements satisfy pred.
(srfi 160 s16) procedure (s16vector-index (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s16?) (value2 s16?) ... ) ⟹ *
(srfi 160 s16) procedure (s16vector-index-right (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s16?) (value2 s16?) ... ) ⟹ *
Return the index of the first/last element of s16vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s16vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for s16vector-index-right.
(srfi 160 s16) procedure (s16vector-skip (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s16?) (value2 s16?) ... ) ⟹ *
(srfi 160 s16) procedure (s16vector-skip-right (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s16?) (value2 s16?) ... ) ⟹ *
Returns the index of the first/last element of s16vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s16vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for s16vector-skip-right.
(srfi 160 s16) procedure (s16vector-any (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ *
(pred? (val1 s16?) (val2 s16?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the s16vec, or #f if there is no such element. If s16vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 s16) procedure (s16vector-every (pred? procedure?) (s16vec1 s16vector?) (s16vec2 s16vector?) ... ) ⟹ *
(pred? (val1 s16?) (val2 s16?) ... ) ⟹ *
If all elements from s16vec satisfy pred?, return the last result of pred?. If not all do, return #f. If s16vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 s16) procedure (s16vector-partition (pred? procedure?) (s16vec s16vector?) ) ⟹ (values s16vector?integer?)
(pred? (value s16?) ) ⟹ boolean?
Returns an s16vector of the same type as s16vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new s16vector and the number of elements satisfying pred?.
(srfi 160 s16) procedure (s16vector-filter (pred? procedure?) (s16vec1 s16vector?) ) ⟹ s16vector?
(pred? (val s16?) ) ⟹ boolean?
(srfi 160 s16) procedure (s16vector-remove (pred? procedure?) (s16vec1 s16vector?) ) ⟹ s16vector?
(pred? (val s16?) ) ⟹ boolean?
Return an s16vector containing the elements of s16vec that satisfy / do not satisfy pred?.
(srfi 160 s16) procedure (s16vector-swap! (s16vec s16vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of s16vec.
(srfi 160 s16) procedure (s16vector-fill! (s16vec s16vector?) (fill s16?) ) ⟹ undefined
(srfi 160 s16) procedure (s16vector-fill! (s16vec s16vector?) (fill s16?) (start integer?) ) ⟹ undefined
(srfi 160 s16) procedure (s16vector-fill! (s16vec s16vector?) (fill s16?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of s16vec from start to end with the value fill.
(srfi 160 s16) procedure (s16vector-reverse! (s16vec s16vector?) ) ⟹ undefined
(srfi 160 s16) procedure (s16vector-reverse! (s16vec s16vector?) (start integer?) ) ⟹ undefined
(srfi 160 s16) procedure (s16vector-reverse! (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of s16vec from start to end.
(srfi 160 s16) procedure (s16vector-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) ) ⟹ undefined
(srfi 160 s16) procedure (s16vector-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) (start integer?) ) ⟹ undefined
(srfi 160 s16) procedure (s16vector-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of s16from from start to end onto s16to, starting at index at.
(srfi 160 s16) procedure (s16vector-reverse-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) ) ⟹ undefined
(srfi 160 s16) procedure (s16vector-reverse-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) (start integer?) ) ⟹ undefined
(srfi 160 s16) procedure (s16vector-reverse-copy! (s16to s16vector?) (at integer?) (s16from s16vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as s16vector-copy!, but copies in reverse
(srfi 160 s16) procedure (s16vector-unfold! (f procedure?) (s16vec s16vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like s16vector-unfold, but the elements are copied into the vector s16vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 s16) procedure (s16vector-unfold-right! (f procedure?) (s16vec s16vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as s16vector-unfold!, but initializes the s16vector from right to left.
(srfi 160 s16) procedure (reverse-s16vector->list (s16vec s16vector?) ) ⟹ list?
(srfi 160 s16) procedure (reverse-s16vector->list (s16vec s16vector?) (start integer?) ) ⟹ list?
(srfi 160 s16) procedure (reverse-s16vector->list (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s16vec in reverse order.
(srfi 160 s16) procedure (reverse-list->s16vector (proper-list list?) ) ⟹ s16vector?
Returns s16vector with same elements as list in reverse order.
(srfi 160 s16) procedure (s16vector->vector (s16vec s16vector?) ) ⟹ vector?
(srfi 160 s16) procedure (s16vector->vector (s16vec s16vector?) (start integer?) ) ⟹ vector?
(srfi 160 s16) procedure (s16vector->vector (s16vec s16vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as s16vec.
(srfi 160 s16) procedure (vector->s16vector (vec vector?) ) ⟹ s16vector?
(srfi 160 s16) procedure (vector->s16vector (vec vector?) (start integer?) ) ⟹ s16vector?
(srfi 160 s16) procedure (vector->s16vector (vec vector?) (start integer?) (end integer?) ) ⟹ s16vector?
Returns s16vector with same elements as vec.
(srfi 160 s16) procedure (make-s16vector-generator (s16vector s16vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / s16? /
Returns a SRFI 121 generator that generates all the values of s16vector in order. Note that the generator is finite.
s16vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of s16vector.
(srfi 160 s16) procedure (write-s16vector (s16vec s16vector) ) ⟹ undefined
(srfi 160 s16) procedure (write-s16vector (s16vec s16vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of s16vec in the lexical syntax explained below.
library (srfi 160 u32)
(srfi 160 u32) procedure (make-u32vector (size integer?) ) ⟹ u32vector?
(srfi 160 u32) procedure (make-u32vector (size integer?) (fill u32?) ) ⟹ u32vector?
Returns a u32vector whose length is size. If fill is provided, all the elements of the u32vector are initialized to it.
(srfi 160 u32) procedure (u32vector (value u32?) ... ) ⟹ u32vector?
Returns a u32vector initialized with values.
(srfi 160 u32) procedure (u32vector? obj ) ⟹ boolean?
Returns #t if obj is a u32vector, and #f otherwise.
(srfi 160 u32) procedure (u32vector-length (u32vec u32vector?) ) ⟹ integer?
Returns the length of u32vec
(srfi 160 u32) procedure (u32vector-ref (u32vec u32vector?) (i integer?) ) ⟹ u32?
Returns the ith element of u32vec.
(srfi 160 u32) procedure (u32vector-set! (u32vec u32vector?) (i integer?) (value u32?) ) ⟹ undefined
Sets the ith element of u32vec to value.
(srfi 160 u32) procedure (u32vector->list (u32vec u32vector?) ) ⟹ list?
(srfi 160 u32) procedure (u32vector->list (u32vec u32vector?) (start integer?) ) ⟹ list?
(srfi 160 u32) procedure (u32vector->list (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u32vec
(srfi 160 u32) procedure (list->u32vector (proper-list list?) ) ⟹ u32vector?
proper-list ⟹ (list u32? )
Returns u32vector with same elements as list.
(srfi 160 u32) procedure (u32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u32vector (ie., unsigned exact integer in the range 0 to (2^32)-1), and #f otherwise.
(srfi 160 u32) procedure (u32vector-unfold (f procedure?) (length integer?) seed ) ⟹ u32vector?
(srfi 160 u32) procedure (u32vector-unfold (f procedure?) (length integer?) seed ) ⟹ u32vector?
(f (index integer?) state ) ⟹ (values u32?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 u32) procedure (u32vector-copy (u32vec u32vector?) ) ⟹ u32vector?
(srfi 160 u32) procedure (u32vector-copy (u32vec u32vector?) (start integer?) ) ⟹ u32vector?
(srfi 160 u32) procedure (u32vector-copy (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ u32vector?
Makes a copy of the portion of u32vec from start to end and returns it.
(srfi 160 u32) procedure (u32vector-reverse-copy (u32vec u32vector?) ) ⟹ u32vector?
(srfi 160 u32) procedure (u32vector-reverse-copy (u32vec u32vector?) (start integer?) ) ⟹ u32vector?
(srfi 160 u32) procedure (u32vector-reverse-copy (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ u32vector?
The same as u32vector-copy, but in reverse order.
(srfi 160 u32) procedure (u32vector-append (u32vec u32vector?) ... ) ⟹ u32vector?
Returns a u32vector containing all the elements of the u32vecs in order.
(srfi 160 u32) procedure (u32vector-concatenate (list-of-u32vectors list?) ) ⟹ u32vector?
list-of-u32vectors ⟹ (list u32vector? )
The same as u32vector-append, but takes a list of u32vectors rather than multiple arguments.
(srfi 160 u32) procedure (u32vector-append-subvectors (u32vec1 u32vector?) (start1 integer?) (end1 integer?) ... ) ⟹ u32vector?
Concatenates the result of applying u32vector-copy to each triplet of u32vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 u32) procedure (u32vector-empty? (u32vec u32vector?) ) ⟹ boolean?
Returns #t if u32vec has a length of zero, and #f otherwise.
(srfi 160 u32) procedure (u32vector= (u32vec u32vector?) ... ) ⟹ boolean?
Compares the u32vecs for elementwise equality, using = to do the comparisons. Returns #f unless all u32vectors are the same length.
(srfi 160 u32) procedure (u32vector-take (u32vec u32vector?) (n integer?) ) ⟹ u32vector?
(srfi 160 u32) procedure (u32vector-take-right (u32vec u32vector?) (n integer?) ) ⟹ u32vector?
Returns a u32vector containing the first/last n elements of u32vec.
(srfi 160 u32) procedure (u32vector-drop (u32vec u32vector?) (n integer?) ) ⟹ u32vector?
(srfi 160 u32) procedure (u32vector-drop-right (u32vec u32vector?) (n integer?) ) ⟹ u32vector?
Returns a u32vector containing all except the first/last n elements of u32vec.
(srfi 160 u32) procedure (u32vector-segment (u32vec u32vector?) (n integer?) ) ⟹ list?
Returns a list of u32vectors, each of which contains n consecutive elements of u32vec. The last u32vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 u32) procedure (u32vector-fold (kons procedure?) knil (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ *
(kons state (obj1 u32?) (obj2 u32?) ... ) ⟹ *
(srfi 160 u32) procedure (u32vector-fold-right (kons procedure?) knil (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ *
(kons state (obj1 u32?) (obj2 u32?) ... ) ⟹ *
When one u32vector argument u32vec is given, folds kons over the elements of u32vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple u32vector arguments are given, kons is called with the current state value and each value from all the vectors; u32vector-fold scans elements from left to right, while u32vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 u32) procedure (u32vector-map (proc procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ vector?
(proc (val1 u32?) ... ) ⟹ *
(srfi 160 u32) procedure (u32vector-map! (proc procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ undefined
(proc (val1 u32?) ... ) ⟹ *
(srfi 160 u32) procedure (u32vector-for-each (proc procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ undefined
(proc (val1 u32?) ... ) ⟹ undefined
Iterate over the elements of u32vec and apply f to each, returning respectively a u32vector of the results, an undefined value with the results placed back in u32vec, and an undefined value with no change to u32vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For u32vector-map!, only u32vec is modified even when multiple vectors are passed.
If u32vector-map or u32vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 u32) procedure (u32vector-count (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer?
(pred? (val1 u32?) (val2 u32?) ... ) ⟹ *
Call pred? on each element of u32vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 u32) procedure (u32vector-cumulate (f procedure?) knil (u32vec u32vector?) ) ⟹ u32vector?
(f state (value u32?) ) ⟹ *
Like u32vector-fold, but returns an u32vector of partial results rather than just the final result.
(srfi 160 u32) procedure (u32vector-take-while (pred? procedure?) (u32vec u32vector?) ) ⟹ u32vector?
(pred? (value u32?) ) ⟹ boolean?
(srfi 160 u32) procedure (u32vector-take-while-right (pred? procedure?) (u32vec u32vector?) ) ⟹ u32vector?
(pred? (value u32?) ) ⟹ boolean?
Return the shortest prefix/suffix of u32vec all of whose elements satisfy pred?.
(srfi 160 u32) procedure (u32vector-drop-while (pred? procedure?) (u32vec u32vector?) ) ⟹ u32vector?
(pred? (value u32?) ) ⟹ boolean?
(srfi 160 u32) procedure (u32vector-drop-while-right (pred? procedure?) (u32vec u32vector?) ) ⟹ u32vector?
(pred? (value u32?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of u32vec such that all its elements satisfy pred.
(srfi 160 u32) procedure (u32vector-index (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u32?) (value2 u32?) ... ) ⟹ *
(srfi 160 u32) procedure (u32vector-index-right (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u32?) (value2 u32?) ... ) ⟹ *
Return the index of the first/last element of u32vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u32vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for u32vector-index-right.
(srfi 160 u32) procedure (u32vector-skip (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u32?) (value2 u32?) ... ) ⟹ *
(srfi 160 u32) procedure (u32vector-skip-right (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u32?) (value2 u32?) ... ) ⟹ *
Returns the index of the first/last element of u32vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u32vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for u32vector-skip-right.
(srfi 160 u32) procedure (u32vector-any (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ *
(pred? (val1 u32?) (val2 u32?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the u32vec, or #f if there is no such element. If u32vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 u32) procedure (u32vector-every (pred? procedure?) (u32vec1 u32vector?) (u32vec2 u32vector?) ... ) ⟹ *
(pred? (val1 u32?) (val2 u32?) ... ) ⟹ *
If all elements from u32vec satisfy pred?, return the last result of pred?. If not all do, return #f. If u32vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 u32) procedure (u32vector-partition (pred? procedure?) (u32vec u32vector?) ) ⟹ (values u32vector?integer?)
(pred? (value u32?) ) ⟹ boolean?
Returns an u32vector of the same type as u32vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new u32vector and the number of elements satisfying pred?.
(srfi 160 u32) procedure (u32vector-filter (pred? procedure?) (u32vec1 u32vector?) ) ⟹ u32vector?
(pred? (val u32?) ) ⟹ boolean?
(srfi 160 u32) procedure (u32vector-remove (pred? procedure?) (u32vec1 u32vector?) ) ⟹ u32vector?
(pred? (val u32?) ) ⟹ boolean?
Return an u32vector containing the elements of u32vec that satisfy / do not satisfy pred?.
(srfi 160 u32) procedure (u32vector-swap! (u32vec u32vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of u32vec.
(srfi 160 u32) procedure (u32vector-fill! (u32vec u32vector?) (fill u32?) ) ⟹ undefined
(srfi 160 u32) procedure (u32vector-fill! (u32vec u32vector?) (fill u32?) (start integer?) ) ⟹ undefined
(srfi 160 u32) procedure (u32vector-fill! (u32vec u32vector?) (fill u32?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of u32vec from start to end with the value fill.
(srfi 160 u32) procedure (u32vector-reverse! (u32vec u32vector?) ) ⟹ undefined
(srfi 160 u32) procedure (u32vector-reverse! (u32vec u32vector?) (start integer?) ) ⟹ undefined
(srfi 160 u32) procedure (u32vector-reverse! (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of u32vec from start to end.
(srfi 160 u32) procedure (u32vector-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) ) ⟹ undefined
(srfi 160 u32) procedure (u32vector-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) (start integer?) ) ⟹ undefined
(srfi 160 u32) procedure (u32vector-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of u32from from start to end onto u32to, starting at index at.
(srfi 160 u32) procedure (u32vector-reverse-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) ) ⟹ undefined
(srfi 160 u32) procedure (u32vector-reverse-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) (start integer?) ) ⟹ undefined
(srfi 160 u32) procedure (u32vector-reverse-copy! (u32to u32vector?) (at integer?) (u32from u32vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as u32vector-copy!, but copies in reverse
(srfi 160 u32) procedure (u32vector-unfold! (f procedure?) (u32vec u32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like u32vector-unfold, but the elements are copied into the vector u32vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 u32) procedure (u32vector-unfold-right! (f procedure?) (u32vec u32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as u32vector-unfold!, but initializes the u32vector from right to left.
(srfi 160 u32) procedure (reverse-u32vector->list (u32vec u32vector?) ) ⟹ list?
(srfi 160 u32) procedure (reverse-u32vector->list (u32vec u32vector?) (start integer?) ) ⟹ list?
(srfi 160 u32) procedure (reverse-u32vector->list (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u32vec in reverse order.
(srfi 160 u32) procedure (reverse-list->u32vector (proper-list list?) ) ⟹ u32vector?
Returns u32vector with same elements as list in reverse order.
(srfi 160 u32) procedure (u32vector->vector (u32vec u32vector?) ) ⟹ vector?
(srfi 160 u32) procedure (u32vector->vector (u32vec u32vector?) (start integer?) ) ⟹ vector?
(srfi 160 u32) procedure (u32vector->vector (u32vec u32vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as u32vec.
(srfi 160 u32) procedure (vector->u32vector (vec vector?) ) ⟹ u32vector?
(srfi 160 u32) procedure (vector->u32vector (vec vector?) (start integer?) ) ⟹ u32vector?
(srfi 160 u32) procedure (vector->u32vector (vec vector?) (start integer?) (end integer?) ) ⟹ u32vector?
Returns u32vector with same elements as vec.
(srfi 160 u32) procedure (make-u32vector-generator (u32vector u32vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / u32? /
Returns a SRFI 121 generator that generates all the values of u32vector in order. Note that the generator is finite.
u32vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of u32vector.
(srfi 160 u32) procedure (write-u32vector (u32vec u32vector) ) ⟹ undefined
(srfi 160 u32) procedure (write-u32vector (u32vec u32vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of u32vec in the lexical syntax explained below.
library (srfi 160 s32)
(srfi 160 s32) procedure (make-s32vector (size integer?) ) ⟹ s32vector?
(srfi 160 s32) procedure (make-s32vector (size integer?) (fill s32?) ) ⟹ s32vector?
Returns a s32vector whose length is size. If fill is provided, all the elements of the s32vector are initialized to it.
(srfi 160 s32) procedure (s32vector (value s32?) ... ) ⟹ s32vector?
Returns a s32vector initialized with values.
(srfi 160 s32) procedure (s32vector? obj ) ⟹ boolean?
Returns #t if obj is a s32vector, and #f otherwise.
(srfi 160 s32) procedure (s32vector-length (s32vec s32vector?) ) ⟹ integer?
Returns the length of s32vec
(srfi 160 s32) procedure (s32vector-ref (s32vec s32vector?) (i integer?) ) ⟹ s32?
Returns the ith element of s32vec.
(srfi 160 s32) procedure (s32vector-set! (s32vec s32vector?) (i integer?) (value s32?) ) ⟹ undefined
Sets the ith element of s32vec to value.
(srfi 160 s32) procedure (s32vector->list (s32vec s32vector?) ) ⟹ list?
(srfi 160 s32) procedure (s32vector->list (s32vec s32vector?) (start integer?) ) ⟹ list?
(srfi 160 s32) procedure (s32vector->list (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s32vec
(srfi 160 s32) procedure (list->s32vector (proper-list list?) ) ⟹ s32vector?
proper-list ⟹ (list s32? )
Returns s32vector with same elements as list.
(srfi 160 s32) procedure (s32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s32vector (ie., signed exact integer in the range -(2^31) to (2^31)-1), and #f otherwise.
(srfi 160 s32) procedure (s32vector-unfold (f procedure?) (length integer?) seed ) ⟹ s32vector?
(srfi 160 s32) procedure (s32vector-unfold (f procedure?) (length integer?) seed ) ⟹ s32vector?
(f (index integer?) state ) ⟹ (values s32?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 s32) procedure (s32vector-copy (s32vec s32vector?) ) ⟹ s32vector?
(srfi 160 s32) procedure (s32vector-copy (s32vec s32vector?) (start integer?) ) ⟹ s32vector?
(srfi 160 s32) procedure (s32vector-copy (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ s32vector?
Makes a copy of the portion of s32vec from start to end and returns it.
(srfi 160 s32) procedure (s32vector-reverse-copy (s32vec s32vector?) ) ⟹ s32vector?
(srfi 160 s32) procedure (s32vector-reverse-copy (s32vec s32vector?) (start integer?) ) ⟹ s32vector?
(srfi 160 s32) procedure (s32vector-reverse-copy (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ s32vector?
The same as s32vector-copy, but in reverse order.
(srfi 160 s32) procedure (s32vector-append (s32vec s32vector?) ... ) ⟹ s32vector?
Returns a s32vector containing all the elements of the s32vecs in order.
(srfi 160 s32) procedure (s32vector-concatenate (list-of-s32vectors list?) ) ⟹ s32vector?
list-of-s32vectors ⟹ (list s32vector? )
The same as s32vector-append, but takes a list of s32vectors rather than multiple arguments.
(srfi 160 s32) procedure (s32vector-append-subvectors (s32vec1 s32vector?) (start1 integer?) (end1 integer?) ... ) ⟹ s32vector?
Concatenates the result of applying s32vector-copy to each triplet of s32vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 s32) procedure (s32vector-empty? (s32vec s32vector?) ) ⟹ boolean?
Returns #t if s32vec has a length of zero, and #f otherwise.
(srfi 160 s32) procedure (s32vector= (s32vec s32vector?) ... ) ⟹ boolean?
Compares the s32vecs for elementwise equality, using = to do the comparisons. Returns #f unless all s32vectors are the same length.
(srfi 160 s32) procedure (s32vector-take (s32vec s32vector?) (n integer?) ) ⟹ s32vector?
(srfi 160 s32) procedure (s32vector-take-right (s32vec s32vector?) (n integer?) ) ⟹ s32vector?
Returns a s32vector containing the first/last n elements of s32vec.
(srfi 160 s32) procedure (s32vector-drop (s32vec s32vector?) (n integer?) ) ⟹ s32vector?
(srfi 160 s32) procedure (s32vector-drop-right (s32vec s32vector?) (n integer?) ) ⟹ s32vector?
Returns a s32vector containing all except the first/last n elements of s32vec.
(srfi 160 s32) procedure (s32vector-segment (s32vec s32vector?) (n integer?) ) ⟹ list?
Returns a list of s32vectors, each of which contains n consecutive elements of s32vec. The last s32vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 s32) procedure (s32vector-fold (kons procedure?) knil (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ *
(kons state (obj1 s32?) (obj2 s32?) ... ) ⟹ *
(srfi 160 s32) procedure (s32vector-fold-right (kons procedure?) knil (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ *
(kons state (obj1 s32?) (obj2 s32?) ... ) ⟹ *
When one s32vector argument s32vec is given, folds kons over the elements of s32vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple s32vector arguments are given, kons is called with the current state value and each value from all the vectors; s32vector-fold scans elements from left to right, while s32vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 s32) procedure (s32vector-map (proc procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ vector?
(proc (val1 s32?) ... ) ⟹ *
(srfi 160 s32) procedure (s32vector-map! (proc procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ undefined
(proc (val1 s32?) ... ) ⟹ *
(srfi 160 s32) procedure (s32vector-for-each (proc procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ undefined
(proc (val1 s32?) ... ) ⟹ undefined
Iterate over the elements of s32vec and apply f to each, returning respectively a s32vector of the results, an undefined value with the results placed back in s32vec, and an undefined value with no change to s32vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For s32vector-map!, only s32vec is modified even when multiple vectors are passed.
If s32vector-map or s32vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 s32) procedure (s32vector-count (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer?
(pred? (val1 s32?) (val2 s32?) ... ) ⟹ *
Call pred? on each element of s32vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 s32) procedure (s32vector-cumulate (f procedure?) knil (s32vec s32vector?) ) ⟹ s32vector?
(f state (value s32?) ) ⟹ *
Like s32vector-fold, but returns an s32vector of partial results rather than just the final result.
(srfi 160 s32) procedure (s32vector-take-while (pred? procedure?) (s32vec s32vector?) ) ⟹ s32vector?
(pred? (value s32?) ) ⟹ boolean?
(srfi 160 s32) procedure (s32vector-take-while-right (pred? procedure?) (s32vec s32vector?) ) ⟹ s32vector?
(pred? (value s32?) ) ⟹ boolean?
Return the shortest prefix/suffix of s32vec all of whose elements satisfy pred?.
(srfi 160 s32) procedure (s32vector-drop-while (pred? procedure?) (s32vec s32vector?) ) ⟹ s32vector?
(pred? (value s32?) ) ⟹ boolean?
(srfi 160 s32) procedure (s32vector-drop-while-right (pred? procedure?) (s32vec s32vector?) ) ⟹ s32vector?
(pred? (value s32?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of s32vec such that all its elements satisfy pred.
(srfi 160 s32) procedure (s32vector-index (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s32?) (value2 s32?) ... ) ⟹ *
(srfi 160 s32) procedure (s32vector-index-right (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s32?) (value2 s32?) ... ) ⟹ *
Return the index of the first/last element of s32vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s32vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for s32vector-index-right.
(srfi 160 s32) procedure (s32vector-skip (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s32?) (value2 s32?) ... ) ⟹ *
(srfi 160 s32) procedure (s32vector-skip-right (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s32?) (value2 s32?) ... ) ⟹ *
Returns the index of the first/last element of s32vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s32vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for s32vector-skip-right.
(srfi 160 s32) procedure (s32vector-any (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ *
(pred? (val1 s32?) (val2 s32?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the s32vec, or #f if there is no such element. If s32vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 s32) procedure (s32vector-every (pred? procedure?) (s32vec1 s32vector?) (s32vec2 s32vector?) ... ) ⟹ *
(pred? (val1 s32?) (val2 s32?) ... ) ⟹ *
If all elements from s32vec satisfy pred?, return the last result of pred?. If not all do, return #f. If s32vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 s32) procedure (s32vector-partition (pred? procedure?) (s32vec s32vector?) ) ⟹ (values s32vector?integer?)
(pred? (value s32?) ) ⟹ boolean?
Returns an s32vector of the same type as s32vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new s32vector and the number of elements satisfying pred?.
(srfi 160 s32) procedure (s32vector-filter (pred? procedure?) (s32vec1 s32vector?) ) ⟹ s32vector?
(pred? (val s32?) ) ⟹ boolean?
(srfi 160 s32) procedure (s32vector-remove (pred? procedure?) (s32vec1 s32vector?) ) ⟹ s32vector?
(pred? (val s32?) ) ⟹ boolean?
Return an s32vector containing the elements of s32vec that satisfy / do not satisfy pred?.
(srfi 160 s32) procedure (s32vector-swap! (s32vec s32vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of s32vec.
(srfi 160 s32) procedure (s32vector-fill! (s32vec s32vector?) (fill s32?) ) ⟹ undefined
(srfi 160 s32) procedure (s32vector-fill! (s32vec s32vector?) (fill s32?) (start integer?) ) ⟹ undefined
(srfi 160 s32) procedure (s32vector-fill! (s32vec s32vector?) (fill s32?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of s32vec from start to end with the value fill.
(srfi 160 s32) procedure (s32vector-reverse! (s32vec s32vector?) ) ⟹ undefined
(srfi 160 s32) procedure (s32vector-reverse! (s32vec s32vector?) (start integer?) ) ⟹ undefined
(srfi 160 s32) procedure (s32vector-reverse! (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of s32vec from start to end.
(srfi 160 s32) procedure (s32vector-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) ) ⟹ undefined
(srfi 160 s32) procedure (s32vector-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) (start integer?) ) ⟹ undefined
(srfi 160 s32) procedure (s32vector-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of s32from from start to end onto s32to, starting at index at.
(srfi 160 s32) procedure (s32vector-reverse-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) ) ⟹ undefined
(srfi 160 s32) procedure (s32vector-reverse-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) (start integer?) ) ⟹ undefined
(srfi 160 s32) procedure (s32vector-reverse-copy! (s32to s32vector?) (at integer?) (s32from s32vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as s32vector-copy!, but copies in reverse
(srfi 160 s32) procedure (s32vector-unfold! (f procedure?) (s32vec s32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like s32vector-unfold, but the elements are copied into the vector s32vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 s32) procedure (s32vector-unfold-right! (f procedure?) (s32vec s32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as s32vector-unfold!, but initializes the s32vector from right to left.
(srfi 160 s32) procedure (reverse-s32vector->list (s32vec s32vector?) ) ⟹ list?
(srfi 160 s32) procedure (reverse-s32vector->list (s32vec s32vector?) (start integer?) ) ⟹ list?
(srfi 160 s32) procedure (reverse-s32vector->list (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s32vec in reverse order.
(srfi 160 s32) procedure (reverse-list->s32vector (proper-list list?) ) ⟹ s32vector?
Returns s32vector with same elements as list in reverse order.
(srfi 160 s32) procedure (s32vector->vector (s32vec s32vector?) ) ⟹ vector?
(srfi 160 s32) procedure (s32vector->vector (s32vec s32vector?) (start integer?) ) ⟹ vector?
(srfi 160 s32) procedure (s32vector->vector (s32vec s32vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as s32vec.
(srfi 160 s32) procedure (vector->s32vector (vec vector?) ) ⟹ s32vector?
(srfi 160 s32) procedure (vector->s32vector (vec vector?) (start integer?) ) ⟹ s32vector?
(srfi 160 s32) procedure (vector->s32vector (vec vector?) (start integer?) (end integer?) ) ⟹ s32vector?
Returns s32vector with same elements as vec.
(srfi 160 s32) procedure (make-s32vector-generator (s32vector s32vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / s32? /
Returns a SRFI 121 generator that generates all the values of s32vector in order. Note that the generator is finite.
s32vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of s32vector.
(srfi 160 s32) procedure (write-s32vector (s32vec s32vector) ) ⟹ undefined
(srfi 160 s32) procedure (write-s32vector (s32vec s32vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of s32vec in the lexical syntax explained below.
library (srfi 160 u64)
(srfi 160 u64) procedure (make-u64vector (size integer?) ) ⟹ u64vector?
(srfi 160 u64) procedure (make-u64vector (size integer?) (fill u64?) ) ⟹ u64vector?
Returns a u64vector whose length is size. If fill is provided, all the elements of the u64vector are initialized to it.
(srfi 160 u64) procedure (u64vector (value u64?) ... ) ⟹ u64vector?
Returns a u64vector initialized with values.
(srfi 160 u64) procedure (u64vector? obj ) ⟹ boolean?
Returns #t if obj is a u64vector, and #f otherwise.
(srfi 160 u64) procedure (u64vector-length (u64vec u64vector?) ) ⟹ integer?
Returns the length of u64vec
(srfi 160 u64) procedure (u64vector-ref (u64vec u64vector?) (i integer?) ) ⟹ u64?
Returns the ith element of u64vec.
(srfi 160 u64) procedure (u64vector-set! (u64vec u64vector?) (i integer?) (value u64?) ) ⟹ undefined
Sets the ith element of u64vec to value.
(srfi 160 u64) procedure (u64vector->list (u64vec u64vector?) ) ⟹ list?
(srfi 160 u64) procedure (u64vector->list (u64vec u64vector?) (start integer?) ) ⟹ list?
(srfi 160 u64) procedure (u64vector->list (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u64vec
(srfi 160 u64) procedure (list->u64vector (proper-list list?) ) ⟹ u64vector?
proper-list ⟹ (list u64? )
Returns u64vector with same elements as list.
(srfi 160 u64) procedure (u64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an u64vector (ie., unsigned exact integer in the range 0 to (2^64)-1), and #f otherwise.
(srfi 160 u64) procedure (u64vector-unfold (f procedure?) (length integer?) seed ) ⟹ u64vector?
(srfi 160 u64) procedure (u64vector-unfold (f procedure?) (length integer?) seed ) ⟹ u64vector?
(f (index integer?) state ) ⟹ (values u64?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 u64) procedure (u64vector-copy (u64vec u64vector?) ) ⟹ u64vector?
(srfi 160 u64) procedure (u64vector-copy (u64vec u64vector?) (start integer?) ) ⟹ u64vector?
(srfi 160 u64) procedure (u64vector-copy (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ u64vector?
Makes a copy of the portion of u64vec from start to end and returns it.
(srfi 160 u64) procedure (u64vector-reverse-copy (u64vec u64vector?) ) ⟹ u64vector?
(srfi 160 u64) procedure (u64vector-reverse-copy (u64vec u64vector?) (start integer?) ) ⟹ u64vector?
(srfi 160 u64) procedure (u64vector-reverse-copy (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ u64vector?
The same as u64vector-copy, but in reverse order.
(srfi 160 u64) procedure (u64vector-append (u64vec u64vector?) ... ) ⟹ u64vector?
Returns a u64vector containing all the elements of the u64vecs in order.
(srfi 160 u64) procedure (u64vector-concatenate (list-of-u64vectors list?) ) ⟹ u64vector?
list-of-u64vectors ⟹ (list u64vector? )
The same as u64vector-append, but takes a list of u64vectors rather than multiple arguments.
(srfi 160 u64) procedure (u64vector-append-subvectors (u64vec1 u64vector?) (start1 integer?) (end1 integer?) ... ) ⟹ u64vector?
Concatenates the result of applying u64vector-copy to each triplet of u64vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 u64) procedure (u64vector-empty? (u64vec u64vector?) ) ⟹ boolean?
Returns #t if u64vec has a length of zero, and #f otherwise.
(srfi 160 u64) procedure (u64vector= (u64vec u64vector?) ... ) ⟹ boolean?
Compares the u64vecs for elementwise equality, using = to do the comparisons. Returns #f unless all u64vectors are the same length.
(srfi 160 u64) procedure (u64vector-take (u64vec u64vector?) (n integer?) ) ⟹ u64vector?
(srfi 160 u64) procedure (u64vector-take-right (u64vec u64vector?) (n integer?) ) ⟹ u64vector?
Returns a u64vector containing the first/last n elements of u64vec.
(srfi 160 u64) procedure (u64vector-drop (u64vec u64vector?) (n integer?) ) ⟹ u64vector?
(srfi 160 u64) procedure (u64vector-drop-right (u64vec u64vector?) (n integer?) ) ⟹ u64vector?
Returns a u64vector containing all except the first/last n elements of u64vec.
(srfi 160 u64) procedure (u64vector-segment (u64vec u64vector?) (n integer?) ) ⟹ list?
Returns a list of u64vectors, each of which contains n consecutive elements of u64vec. The last u64vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 u64) procedure (u64vector-fold (kons procedure?) knil (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ *
(kons state (obj1 u64?) (obj2 u64?) ... ) ⟹ *
(srfi 160 u64) procedure (u64vector-fold-right (kons procedure?) knil (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ *
(kons state (obj1 u64?) (obj2 u64?) ... ) ⟹ *
When one u64vector argument u64vec is given, folds kons over the elements of u64vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple u64vector arguments are given, kons is called with the current state value and each value from all the vectors; u64vector-fold scans elements from left to right, while u64vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 u64) procedure (u64vector-map (proc procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ vector?
(proc (val1 u64?) ... ) ⟹ *
(srfi 160 u64) procedure (u64vector-map! (proc procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ undefined
(proc (val1 u64?) ... ) ⟹ *
(srfi 160 u64) procedure (u64vector-for-each (proc procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ undefined
(proc (val1 u64?) ... ) ⟹ undefined
Iterate over the elements of u64vec and apply f to each, returning respectively a u64vector of the results, an undefined value with the results placed back in u64vec, and an undefined value with no change to u64vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For u64vector-map!, only u64vec is modified even when multiple vectors are passed.
If u64vector-map or u64vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 u64) procedure (u64vector-count (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer?
(pred? (val1 u64?) (val2 u64?) ... ) ⟹ *
Call pred? on each element of u64vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 u64) procedure (u64vector-cumulate (f procedure?) knil (u64vec u64vector?) ) ⟹ u64vector?
(f state (value u64?) ) ⟹ *
Like u64vector-fold, but returns an u64vector of partial results rather than just the final result.
(srfi 160 u64) procedure (u64vector-take-while (pred? procedure?) (u64vec u64vector?) ) ⟹ u64vector?
(pred? (value u64?) ) ⟹ boolean?
(srfi 160 u64) procedure (u64vector-take-while-right (pred? procedure?) (u64vec u64vector?) ) ⟹ u64vector?
(pred? (value u64?) ) ⟹ boolean?
Return the shortest prefix/suffix of u64vec all of whose elements satisfy pred?.
(srfi 160 u64) procedure (u64vector-drop-while (pred? procedure?) (u64vec u64vector?) ) ⟹ u64vector?
(pred? (value u64?) ) ⟹ boolean?
(srfi 160 u64) procedure (u64vector-drop-while-right (pred? procedure?) (u64vec u64vector?) ) ⟹ u64vector?
(pred? (value u64?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of u64vec such that all its elements satisfy pred.
(srfi 160 u64) procedure (u64vector-index (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u64?) (value2 u64?) ... ) ⟹ *
(srfi 160 u64) procedure (u64vector-index-right (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u64?) (value2 u64?) ... ) ⟹ *
Return the index of the first/last element of u64vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u64vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for u64vector-index-right.
(srfi 160 u64) procedure (u64vector-skip (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u64?) (value2 u64?) ... ) ⟹ *
(srfi 160 u64) procedure (u64vector-skip-right (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 u64?) (value2 u64?) ... ) ⟹ *
Returns the index of the first/last element of u64vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, u64vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for u64vector-skip-right.
(srfi 160 u64) procedure (u64vector-any (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ *
(pred? (val1 u64?) (val2 u64?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the u64vec, or #f if there is no such element. If u64vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 u64) procedure (u64vector-every (pred? procedure?) (u64vec1 u64vector?) (u64vec2 u64vector?) ... ) ⟹ *
(pred? (val1 u64?) (val2 u64?) ... ) ⟹ *
If all elements from u64vec satisfy pred?, return the last result of pred?. If not all do, return #f. If u64vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 u64) procedure (u64vector-partition (pred? procedure?) (u64vec u64vector?) ) ⟹ (values u64vector?integer?)
(pred? (value u64?) ) ⟹ boolean?
Returns an u64vector of the same type as u64vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new u64vector and the number of elements satisfying pred?.
(srfi 160 u64) procedure (u64vector-filter (pred? procedure?) (u64vec1 u64vector?) ) ⟹ u64vector?
(pred? (val u64?) ) ⟹ boolean?
(srfi 160 u64) procedure (u64vector-remove (pred? procedure?) (u64vec1 u64vector?) ) ⟹ u64vector?
(pred? (val u64?) ) ⟹ boolean?
Return an u64vector containing the elements of u64vec that satisfy / do not satisfy pred?.
(srfi 160 u64) procedure (u64vector-swap! (u64vec u64vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of u64vec.
(srfi 160 u64) procedure (u64vector-fill! (u64vec u64vector?) (fill u64?) ) ⟹ undefined
(srfi 160 u64) procedure (u64vector-fill! (u64vec u64vector?) (fill u64?) (start integer?) ) ⟹ undefined
(srfi 160 u64) procedure (u64vector-fill! (u64vec u64vector?) (fill u64?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of u64vec from start to end with the value fill.
(srfi 160 u64) procedure (u64vector-reverse! (u64vec u64vector?) ) ⟹ undefined
(srfi 160 u64) procedure (u64vector-reverse! (u64vec u64vector?) (start integer?) ) ⟹ undefined
(srfi 160 u64) procedure (u64vector-reverse! (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of u64vec from start to end.
(srfi 160 u64) procedure (u64vector-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) ) ⟹ undefined
(srfi 160 u64) procedure (u64vector-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) (start integer?) ) ⟹ undefined
(srfi 160 u64) procedure (u64vector-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of u64from from start to end onto u64to, starting at index at.
(srfi 160 u64) procedure (u64vector-reverse-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) ) ⟹ undefined
(srfi 160 u64) procedure (u64vector-reverse-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) (start integer?) ) ⟹ undefined
(srfi 160 u64) procedure (u64vector-reverse-copy! (u64to u64vector?) (at integer?) (u64from u64vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as u64vector-copy!, but copies in reverse
(srfi 160 u64) procedure (u64vector-unfold! (f procedure?) (u64vec u64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like u64vector-unfold, but the elements are copied into the vector u64vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 u64) procedure (u64vector-unfold-right! (f procedure?) (u64vec u64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as u64vector-unfold!, but initializes the u64vector from right to left.
(srfi 160 u64) procedure (reverse-u64vector->list (u64vec u64vector?) ) ⟹ list?
(srfi 160 u64) procedure (reverse-u64vector->list (u64vec u64vector?) (start integer?) ) ⟹ list?
(srfi 160 u64) procedure (reverse-u64vector->list (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as u64vec in reverse order.
(srfi 160 u64) procedure (reverse-list->u64vector (proper-list list?) ) ⟹ u64vector?
Returns u64vector with same elements as list in reverse order.
(srfi 160 u64) procedure (u64vector->vector (u64vec u64vector?) ) ⟹ vector?
(srfi 160 u64) procedure (u64vector->vector (u64vec u64vector?) (start integer?) ) ⟹ vector?
(srfi 160 u64) procedure (u64vector->vector (u64vec u64vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as u64vec.
(srfi 160 u64) procedure (vector->u64vector (vec vector?) ) ⟹ u64vector?
(srfi 160 u64) procedure (vector->u64vector (vec vector?) (start integer?) ) ⟹ u64vector?
(srfi 160 u64) procedure (vector->u64vector (vec vector?) (start integer?) (end integer?) ) ⟹ u64vector?
Returns u64vector with same elements as vec.
(srfi 160 u64) procedure (make-u64vector-generator (u64vector u64vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / u64? /
Returns a SRFI 121 generator that generates all the values of u64vector in order. Note that the generator is finite.
u64vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of u64vector.
(srfi 160 u64) procedure (write-u64vector (u64vec u64vector) ) ⟹ undefined
(srfi 160 u64) procedure (write-u64vector (u64vec u64vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of u64vec in the lexical syntax explained below.
library (srfi 160 s64)
(srfi 160 s64) procedure (make-s64vector (size integer?) ) ⟹ s64vector?
(srfi 160 s64) procedure (make-s64vector (size integer?) (fill s64?) ) ⟹ s64vector?
Returns a s64vector whose length is size. If fill is provided, all the elements of the s64vector are initialized to it.
(srfi 160 s64) procedure (s64vector (value s64?) ... ) ⟹ s64vector?
Returns a s64vector initialized with values.
(srfi 160 s64) procedure (s64vector? obj ) ⟹ boolean?
Returns #t if obj is a s64vector, and #f otherwise.
(srfi 160 s64) procedure (s64vector-length (s64vec s64vector?) ) ⟹ integer?
Returns the length of s64vec
(srfi 160 s64) procedure (s64vector-ref (s64vec s64vector?) (i integer?) ) ⟹ s64?
Returns the ith element of s64vec.
(srfi 160 s64) procedure (s64vector-set! (s64vec s64vector?) (i integer?) (value s64?) ) ⟹ undefined
Sets the ith element of s64vec to value.
(srfi 160 s64) procedure (s64vector->list (s64vec s64vector?) ) ⟹ list?
(srfi 160 s64) procedure (s64vector->list (s64vec s64vector?) (start integer?) ) ⟹ list?
(srfi 160 s64) procedure (s64vector->list (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s64vec
(srfi 160 s64) procedure (list->s64vector (proper-list list?) ) ⟹ s64vector?
proper-list ⟹ (list s64? )
Returns s64vector with same elements as list.
(srfi 160 s64) procedure (s64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an s64vector (ie., signed exact integer in the range -(2^63) to (2^63)-1), and #f otherwise.
(srfi 160 s64) procedure (s64vector-unfold (f procedure?) (length integer?) seed ) ⟹ s64vector?
(srfi 160 s64) procedure (s64vector-unfold (f procedure?) (length integer?) seed ) ⟹ s64vector?
(f (index integer?) state ) ⟹ (values s64?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 s64) procedure (s64vector-copy (s64vec s64vector?) ) ⟹ s64vector?
(srfi 160 s64) procedure (s64vector-copy (s64vec s64vector?) (start integer?) ) ⟹ s64vector?
(srfi 160 s64) procedure (s64vector-copy (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ s64vector?
Makes a copy of the portion of s64vec from start to end and returns it.
(srfi 160 s64) procedure (s64vector-reverse-copy (s64vec s64vector?) ) ⟹ s64vector?
(srfi 160 s64) procedure (s64vector-reverse-copy (s64vec s64vector?) (start integer?) ) ⟹ s64vector?
(srfi 160 s64) procedure (s64vector-reverse-copy (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ s64vector?
The same as s64vector-copy, but in reverse order.
(srfi 160 s64) procedure (s64vector-append (s64vec s64vector?) ... ) ⟹ s64vector?
Returns a s64vector containing all the elements of the s64vecs in order.
(srfi 160 s64) procedure (s64vector-concatenate (list-of-s64vectors list?) ) ⟹ s64vector?
list-of-s64vectors ⟹ (list s64vector? )
The same as s64vector-append, but takes a list of s64vectors rather than multiple arguments.
(srfi 160 s64) procedure (s64vector-append-subvectors (s64vec1 s64vector?) (start1 integer?) (end1 integer?) ... ) ⟹ s64vector?
Concatenates the result of applying s64vector-copy to each triplet of s64vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 s64) procedure (s64vector-empty? (s64vec s64vector?) ) ⟹ boolean?
Returns #t if s64vec has a length of zero, and #f otherwise.
(srfi 160 s64) procedure (s64vector= (s64vec s64vector?) ... ) ⟹ boolean?
Compares the s64vecs for elementwise equality, using = to do the comparisons. Returns #f unless all s64vectors are the same length.
(srfi 160 s64) procedure (s64vector-take (s64vec s64vector?) (n integer?) ) ⟹ s64vector?
(srfi 160 s64) procedure (s64vector-take-right (s64vec s64vector?) (n integer?) ) ⟹ s64vector?
Returns a s64vector containing the first/last n elements of s64vec.
(srfi 160 s64) procedure (s64vector-drop (s64vec s64vector?) (n integer?) ) ⟹ s64vector?
(srfi 160 s64) procedure (s64vector-drop-right (s64vec s64vector?) (n integer?) ) ⟹ s64vector?
Returns a s64vector containing all except the first/last n elements of s64vec.
(srfi 160 s64) procedure (s64vector-segment (s64vec s64vector?) (n integer?) ) ⟹ list?
Returns a list of s64vectors, each of which contains n consecutive elements of s64vec. The last s64vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 s64) procedure (s64vector-fold (kons procedure?) knil (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ *
(kons state (obj1 s64?) (obj2 s64?) ... ) ⟹ *
(srfi 160 s64) procedure (s64vector-fold-right (kons procedure?) knil (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ *
(kons state (obj1 s64?) (obj2 s64?) ... ) ⟹ *
When one s64vector argument s64vec is given, folds kons over the elements of s64vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple s64vector arguments are given, kons is called with the current state value and each value from all the vectors; s64vector-fold scans elements from left to right, while s64vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 s64) procedure (s64vector-map (proc procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ vector?
(proc (val1 s64?) ... ) ⟹ *
(srfi 160 s64) procedure (s64vector-map! (proc procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ undefined
(proc (val1 s64?) ... ) ⟹ *
(srfi 160 s64) procedure (s64vector-for-each (proc procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ undefined
(proc (val1 s64?) ... ) ⟹ undefined
Iterate over the elements of s64vec and apply f to each, returning respectively a s64vector of the results, an undefined value with the results placed back in s64vec, and an undefined value with no change to s64vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For s64vector-map!, only s64vec is modified even when multiple vectors are passed.
If s64vector-map or s64vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 s64) procedure (s64vector-count (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer?
(pred? (val1 s64?) (val2 s64?) ... ) ⟹ *
Call pred? on each element of s64vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 s64) procedure (s64vector-cumulate (f procedure?) knil (s64vec s64vector?) ) ⟹ s64vector?
(f state (value s64?) ) ⟹ *
Like s64vector-fold, but returns an s64vector of partial results rather than just the final result.
(srfi 160 s64) procedure (s64vector-take-while (pred? procedure?) (s64vec s64vector?) ) ⟹ s64vector?
(pred? (value s64?) ) ⟹ boolean?
(srfi 160 s64) procedure (s64vector-take-while-right (pred? procedure?) (s64vec s64vector?) ) ⟹ s64vector?
(pred? (value s64?) ) ⟹ boolean?
Return the shortest prefix/suffix of s64vec all of whose elements satisfy pred?.
(srfi 160 s64) procedure (s64vector-drop-while (pred? procedure?) (s64vec s64vector?) ) ⟹ s64vector?
(pred? (value s64?) ) ⟹ boolean?
(srfi 160 s64) procedure (s64vector-drop-while-right (pred? procedure?) (s64vec s64vector?) ) ⟹ s64vector?
(pred? (value s64?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of s64vec such that all its elements satisfy pred.
(srfi 160 s64) procedure (s64vector-index (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s64?) (value2 s64?) ... ) ⟹ *
(srfi 160 s64) procedure (s64vector-index-right (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s64?) (value2 s64?) ... ) ⟹ *
Return the index of the first/last element of s64vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s64vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for s64vector-index-right.
(srfi 160 s64) procedure (s64vector-skip (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s64?) (value2 s64?) ... ) ⟹ *
(srfi 160 s64) procedure (s64vector-skip-right (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 s64?) (value2 s64?) ... ) ⟹ *
Returns the index of the first/last element of s64vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, s64vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for s64vector-skip-right.
(srfi 160 s64) procedure (s64vector-any (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ *
(pred? (val1 s64?) (val2 s64?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the s64vec, or #f if there is no such element. If s64vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 s64) procedure (s64vector-every (pred? procedure?) (s64vec1 s64vector?) (s64vec2 s64vector?) ... ) ⟹ *
(pred? (val1 s64?) (val2 s64?) ... ) ⟹ *
If all elements from s64vec satisfy pred?, return the last result of pred?. If not all do, return #f. If s64vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 s64) procedure (s64vector-partition (pred? procedure?) (s64vec s64vector?) ) ⟹ (values s64vector?integer?)
(pred? (value s64?) ) ⟹ boolean?
Returns an s64vector of the same type as s64vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new s64vector and the number of elements satisfying pred?.
(srfi 160 s64) procedure (s64vector-filter (pred? procedure?) (s64vec1 s64vector?) ) ⟹ s64vector?
(pred? (val s64?) ) ⟹ boolean?
(srfi 160 s64) procedure (s64vector-remove (pred? procedure?) (s64vec1 s64vector?) ) ⟹ s64vector?
(pred? (val s64?) ) ⟹ boolean?
Return an s64vector containing the elements of s64vec that satisfy / do not satisfy pred?.
(srfi 160 s64) procedure (s64vector-swap! (s64vec s64vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of s64vec.
(srfi 160 s64) procedure (s64vector-fill! (s64vec s64vector?) (fill s64?) ) ⟹ undefined
(srfi 160 s64) procedure (s64vector-fill! (s64vec s64vector?) (fill s64?) (start integer?) ) ⟹ undefined
(srfi 160 s64) procedure (s64vector-fill! (s64vec s64vector?) (fill s64?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of s64vec from start to end with the value fill.
(srfi 160 s64) procedure (s64vector-reverse! (s64vec s64vector?) ) ⟹ undefined
(srfi 160 s64) procedure (s64vector-reverse! (s64vec s64vector?) (start integer?) ) ⟹ undefined
(srfi 160 s64) procedure (s64vector-reverse! (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of s64vec from start to end.
(srfi 160 s64) procedure (s64vector-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) ) ⟹ undefined
(srfi 160 s64) procedure (s64vector-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) (start integer?) ) ⟹ undefined
(srfi 160 s64) procedure (s64vector-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of s64from from start to end onto s64to, starting at index at.
(srfi 160 s64) procedure (s64vector-reverse-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) ) ⟹ undefined
(srfi 160 s64) procedure (s64vector-reverse-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) (start integer?) ) ⟹ undefined
(srfi 160 s64) procedure (s64vector-reverse-copy! (s64to s64vector?) (at integer?) (s64from s64vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as s64vector-copy!, but copies in reverse
(srfi 160 s64) procedure (s64vector-unfold! (f procedure?) (s64vec s64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like s64vector-unfold, but the elements are copied into the vector s64vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 s64) procedure (s64vector-unfold-right! (f procedure?) (s64vec s64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as s64vector-unfold!, but initializes the s64vector from right to left.
(srfi 160 s64) procedure (reverse-s64vector->list (s64vec s64vector?) ) ⟹ list?
(srfi 160 s64) procedure (reverse-s64vector->list (s64vec s64vector?) (start integer?) ) ⟹ list?
(srfi 160 s64) procedure (reverse-s64vector->list (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as s64vec in reverse order.
(srfi 160 s64) procedure (reverse-list->s64vector (proper-list list?) ) ⟹ s64vector?
Returns s64vector with same elements as list in reverse order.
(srfi 160 s64) procedure (s64vector->vector (s64vec s64vector?) ) ⟹ vector?
(srfi 160 s64) procedure (s64vector->vector (s64vec s64vector?) (start integer?) ) ⟹ vector?
(srfi 160 s64) procedure (s64vector->vector (s64vec s64vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as s64vec.
(srfi 160 s64) procedure (vector->s64vector (vec vector?) ) ⟹ s64vector?
(srfi 160 s64) procedure (vector->s64vector (vec vector?) (start integer?) ) ⟹ s64vector?
(srfi 160 s64) procedure (vector->s64vector (vec vector?) (start integer?) (end integer?) ) ⟹ s64vector?
Returns s64vector with same elements as vec.
(srfi 160 s64) procedure (make-s64vector-generator (s64vector s64vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / s64? /
Returns a SRFI 121 generator that generates all the values of s64vector in order. Note that the generator is finite.
s64vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of s64vector.
(srfi 160 s64) procedure (write-s64vector (s64vec s64vector) ) ⟹ undefined
(srfi 160 s64) procedure (write-s64vector (s64vec s64vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of s64vec in the lexical syntax explained below.
library (srfi 160 f32)
(srfi 160 f32) procedure (make-f32vector (size integer?) ) ⟹ f32vector?
(srfi 160 f32) procedure (make-f32vector (size integer?) (fill f32?) ) ⟹ f32vector?
Returns a f32vector whose length is size. If fill is provided, all the elements of the f32vector are initialized to it.
(srfi 160 f32) procedure (f32vector (value f32?) ... ) ⟹ f32vector?
Returns a f32vector initialized with values.
(srfi 160 f32) procedure (f32vector? obj ) ⟹ boolean?
Returns #t if obj is a f32vector, and #f otherwise.
(srfi 160 f32) procedure (f32vector-length (f32vec f32vector?) ) ⟹ integer?
Returns the length of f32vec
(srfi 160 f32) procedure (f32vector-ref (f32vec f32vector?) (i integer?) ) ⟹ f32?
Returns the ith element of f32vec.
(srfi 160 f32) procedure (f32vector-set! (f32vec f32vector?) (i integer?) (value f32?) ) ⟹ undefined
Sets the ith element of f32vec to value.
(srfi 160 f32) procedure (f32vector->list (f32vec f32vector?) ) ⟹ list?
(srfi 160 f32) procedure (f32vector->list (f32vec f32vector?) (start integer?) ) ⟹ list?
(srfi 160 f32) procedure (f32vector->list (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f32vec
(srfi 160 f32) procedure (list->f32vector (proper-list list?) ) ⟹ f32vector?
proper-list ⟹ (list f32? )
Returns f32vector with same elements as list.
(srfi 160 f32) procedure (f32? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an f32vector (ie., inexact real), and #f otherwise.
(srfi 160 f32) procedure (f32vector-unfold (f procedure?) (length integer?) seed ) ⟹ f32vector?
(srfi 160 f32) procedure (f32vector-unfold (f procedure?) (length integer?) seed ) ⟹ f32vector?
(f (index integer?) state ) ⟹ (values f32?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 f32) procedure (f32vector-copy (f32vec f32vector?) ) ⟹ f32vector?
(srfi 160 f32) procedure (f32vector-copy (f32vec f32vector?) (start integer?) ) ⟹ f32vector?
(srfi 160 f32) procedure (f32vector-copy (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ f32vector?
Makes a copy of the portion of f32vec from start to end and returns it.
(srfi 160 f32) procedure (f32vector-reverse-copy (f32vec f32vector?) ) ⟹ f32vector?
(srfi 160 f32) procedure (f32vector-reverse-copy (f32vec f32vector?) (start integer?) ) ⟹ f32vector?
(srfi 160 f32) procedure (f32vector-reverse-copy (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ f32vector?
The same as f32vector-copy, but in reverse order.
(srfi 160 f32) procedure (f32vector-append (f32vec f32vector?) ... ) ⟹ f32vector?
Returns a f32vector containing all the elements of the f32vecs in order.
(srfi 160 f32) procedure (f32vector-concatenate (list-of-f32vectors list?) ) ⟹ f32vector?
list-of-f32vectors ⟹ (list f32vector? )
The same as f32vector-append, but takes a list of f32vectors rather than multiple arguments.
(srfi 160 f32) procedure (f32vector-append-subvectors (f32vec1 f32vector?) (start1 integer?) (end1 integer?) ... ) ⟹ f32vector?
Concatenates the result of applying f32vector-copy to each triplet of f32vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 f32) procedure (f32vector-empty? (f32vec f32vector?) ) ⟹ boolean?
Returns #t if f32vec has a length of zero, and #f otherwise.
(srfi 160 f32) procedure (f32vector= (f32vec f32vector?) ... ) ⟹ boolean?
Compares the f32vecs for elementwise equality, using = to do the comparisons. Returns #f unless all f32vectors are the same length.
(srfi 160 f32) procedure (f32vector-take (f32vec f32vector?) (n integer?) ) ⟹ f32vector?
(srfi 160 f32) procedure (f32vector-take-right (f32vec f32vector?) (n integer?) ) ⟹ f32vector?
Returns a f32vector containing the first/last n elements of f32vec.
(srfi 160 f32) procedure (f32vector-drop (f32vec f32vector?) (n integer?) ) ⟹ f32vector?
(srfi 160 f32) procedure (f32vector-drop-right (f32vec f32vector?) (n integer?) ) ⟹ f32vector?
Returns a f32vector containing all except the first/last n elements of f32vec.
(srfi 160 f32) procedure (f32vector-segment (f32vec f32vector?) (n integer?) ) ⟹ list?
Returns a list of f32vectors, each of which contains n consecutive elements of f32vec. The last f32vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 f32) procedure (f32vector-fold (kons procedure?) knil (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ *
(kons state (obj1 f32?) (obj2 f32?) ... ) ⟹ *
(srfi 160 f32) procedure (f32vector-fold-right (kons procedure?) knil (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ *
(kons state (obj1 f32?) (obj2 f32?) ... ) ⟹ *
When one f32vector argument f32vec is given, folds kons over the elements of f32vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple f32vector arguments are given, kons is called with the current state value and each value from all the vectors; f32vector-fold scans elements from left to right, while f32vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 f32) procedure (f32vector-map (proc procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ vector?
(proc (val1 f32?) ... ) ⟹ *
(srfi 160 f32) procedure (f32vector-map! (proc procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ undefined
(proc (val1 f32?) ... ) ⟹ *
(srfi 160 f32) procedure (f32vector-for-each (proc procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ undefined
(proc (val1 f32?) ... ) ⟹ undefined
Iterate over the elements of f32vec and apply f to each, returning respectively a f32vector of the results, an undefined value with the results placed back in f32vec, and an undefined value with no change to f32vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For f32vector-map!, only f32vec is modified even when multiple vectors are passed.
If f32vector-map or f32vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 f32) procedure (f32vector-count (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer?
(pred? (val1 f32?) (val2 f32?) ... ) ⟹ *
Call pred? on each element of f32vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 f32) procedure (f32vector-cumulate (f procedure?) knil (f32vec f32vector?) ) ⟹ f32vector?
(f state (value f32?) ) ⟹ *
Like f32vector-fold, but returns an f32vector of partial results rather than just the final result.
(srfi 160 f32) procedure (f32vector-take-while (pred? procedure?) (f32vec f32vector?) ) ⟹ f32vector?
(pred? (value f32?) ) ⟹ boolean?
(srfi 160 f32) procedure (f32vector-take-while-right (pred? procedure?) (f32vec f32vector?) ) ⟹ f32vector?
(pred? (value f32?) ) ⟹ boolean?
Return the shortest prefix/suffix of f32vec all of whose elements satisfy pred?.
(srfi 160 f32) procedure (f32vector-drop-while (pred? procedure?) (f32vec f32vector?) ) ⟹ f32vector?
(pred? (value f32?) ) ⟹ boolean?
(srfi 160 f32) procedure (f32vector-drop-while-right (pred? procedure?) (f32vec f32vector?) ) ⟹ f32vector?
(pred? (value f32?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of f32vec such that all its elements satisfy pred.
(srfi 160 f32) procedure (f32vector-index (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f32?) (value2 f32?) ... ) ⟹ *
(srfi 160 f32) procedure (f32vector-index-right (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f32?) (value2 f32?) ... ) ⟹ *
Return the index of the first/last element of f32vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, f32vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for f32vector-index-right.
(srfi 160 f32) procedure (f32vector-skip (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f32?) (value2 f32?) ... ) ⟹ *
(srfi 160 f32) procedure (f32vector-skip-right (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f32?) (value2 f32?) ... ) ⟹ *
Returns the index of the first/last element of f32vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, f32vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for f32vector-skip-right.
(srfi 160 f32) procedure (f32vector-any (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ *
(pred? (val1 f32?) (val2 f32?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the f32vec, or #f if there is no such element. If f32vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 f32) procedure (f32vector-every (pred? procedure?) (f32vec1 f32vector?) (f32vec2 f32vector?) ... ) ⟹ *
(pred? (val1 f32?) (val2 f32?) ... ) ⟹ *
If all elements from f32vec satisfy pred?, return the last result of pred?. If not all do, return #f. If f32vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 f32) procedure (f32vector-partition (pred? procedure?) (f32vec f32vector?) ) ⟹ (values f32vector?integer?)
(pred? (value f32?) ) ⟹ boolean?
Returns an f32vector of the same type as f32vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new f32vector and the number of elements satisfying pred?.
(srfi 160 f32) procedure (f32vector-filter (pred? procedure?) (f32vec1 f32vector?) ) ⟹ f32vector?
(pred? (val f32?) ) ⟹ boolean?
(srfi 160 f32) procedure (f32vector-remove (pred? procedure?) (f32vec1 f32vector?) ) ⟹ f32vector?
(pred? (val f32?) ) ⟹ boolean?
Return an f32vector containing the elements of f32vec that satisfy / do not satisfy pred?.
(srfi 160 f32) procedure (f32vector-swap! (f32vec f32vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of f32vec.
(srfi 160 f32) procedure (f32vector-fill! (f32vec f32vector?) (fill f32?) ) ⟹ undefined
(srfi 160 f32) procedure (f32vector-fill! (f32vec f32vector?) (fill f32?) (start integer?) ) ⟹ undefined
(srfi 160 f32) procedure (f32vector-fill! (f32vec f32vector?) (fill f32?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of f32vec from start to end with the value fill.
(srfi 160 f32) procedure (f32vector-reverse! (f32vec f32vector?) ) ⟹ undefined
(srfi 160 f32) procedure (f32vector-reverse! (f32vec f32vector?) (start integer?) ) ⟹ undefined
(srfi 160 f32) procedure (f32vector-reverse! (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of f32vec from start to end.
(srfi 160 f32) procedure (f32vector-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) ) ⟹ undefined
(srfi 160 f32) procedure (f32vector-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) (start integer?) ) ⟹ undefined
(srfi 160 f32) procedure (f32vector-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of f32from from start to end onto f32to, starting at index at.
(srfi 160 f32) procedure (f32vector-reverse-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) ) ⟹ undefined
(srfi 160 f32) procedure (f32vector-reverse-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) (start integer?) ) ⟹ undefined
(srfi 160 f32) procedure (f32vector-reverse-copy! (f32to f32vector?) (at integer?) (f32from f32vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as f32vector-copy!, but copies in reverse
(srfi 160 f32) procedure (f32vector-unfold! (f procedure?) (f32vec f32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like f32vector-unfold, but the elements are copied into the vector f32vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 f32) procedure (f32vector-unfold-right! (f procedure?) (f32vec f32vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as f32vector-unfold!, but initializes the f32vector from right to left.
(srfi 160 f32) procedure (reverse-f32vector->list (f32vec f32vector?) ) ⟹ list?
(srfi 160 f32) procedure (reverse-f32vector->list (f32vec f32vector?) (start integer?) ) ⟹ list?
(srfi 160 f32) procedure (reverse-f32vector->list (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f32vec in reverse order.
(srfi 160 f32) procedure (reverse-list->f32vector (proper-list list?) ) ⟹ f32vector?
Returns f32vector with same elements as list in reverse order.
(srfi 160 f32) procedure (f32vector->vector (f32vec f32vector?) ) ⟹ vector?
(srfi 160 f32) procedure (f32vector->vector (f32vec f32vector?) (start integer?) ) ⟹ vector?
(srfi 160 f32) procedure (f32vector->vector (f32vec f32vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as f32vec.
(srfi 160 f32) procedure (vector->f32vector (vec vector?) ) ⟹ f32vector?
(srfi 160 f32) procedure (vector->f32vector (vec vector?) (start integer?) ) ⟹ f32vector?
(srfi 160 f32) procedure (vector->f32vector (vec vector?) (start integer?) (end integer?) ) ⟹ f32vector?
Returns f32vector with same elements as vec.
(srfi 160 f32) procedure (make-f32vector-generator (f32vector f32vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / f32? /
Returns a SRFI 121 generator that generates all the values of f32vector in order. Note that the generator is finite.
f32vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of f32vector.
(srfi 160 f32) procedure (write-f32vector (f32vec f32vector) ) ⟹ undefined
(srfi 160 f32) procedure (write-f32vector (f32vec f32vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of f32vec in the lexical syntax explained below.
library (srfi 160 f64)
(srfi 160 f64) procedure (make-f64vector (size integer?) ) ⟹ f64vector?
(srfi 160 f64) procedure (make-f64vector (size integer?) (fill f64?) ) ⟹ f64vector?
Returns a f64vector whose length is size. If fill is provided, all the elements of the f64vector are initialized to it.
(srfi 160 f64) procedure (f64vector (value f64?) ... ) ⟹ f64vector?
Returns a f64vector initialized with values.
(srfi 160 f64) procedure (f64vector? obj ) ⟹ boolean?
Returns #t if obj is a f64vector, and #f otherwise.
(srfi 160 f64) procedure (f64vector-length (f64vec f64vector?) ) ⟹ integer?
Returns the length of f64vec
(srfi 160 f64) procedure (f64vector-ref (f64vec f64vector?) (i integer?) ) ⟹ f64?
Returns the ith element of f64vec.
(srfi 160 f64) procedure (f64vector-set! (f64vec f64vector?) (i integer?) (value f64?) ) ⟹ undefined
Sets the ith element of f64vec to value.
(srfi 160 f64) procedure (f64vector->list (f64vec f64vector?) ) ⟹ list?
(srfi 160 f64) procedure (f64vector->list (f64vec f64vector?) (start integer?) ) ⟹ list?
(srfi 160 f64) procedure (f64vector->list (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f64vec
(srfi 160 f64) procedure (list->f64vector (proper-list list?) ) ⟹ f64vector?
proper-list ⟹ (list f64? )
Returns f64vector with same elements as list.
(srfi 160 f64) procedure (f64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an f64vector (ie., inexact real), and #f otherwise.
(srfi 160 f64) procedure (f64vector-unfold (f procedure?) (length integer?) seed ) ⟹ f64vector?
(srfi 160 f64) procedure (f64vector-unfold (f procedure?) (length integer?) seed ) ⟹ f64vector?
(f (index integer?) state ) ⟹ (values f64?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 f64) procedure (f64vector-copy (f64vec f64vector?) ) ⟹ f64vector?
(srfi 160 f64) procedure (f64vector-copy (f64vec f64vector?) (start integer?) ) ⟹ f64vector?
(srfi 160 f64) procedure (f64vector-copy (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ f64vector?
Makes a copy of the portion of f64vec from start to end and returns it.
(srfi 160 f64) procedure (f64vector-reverse-copy (f64vec f64vector?) ) ⟹ f64vector?
(srfi 160 f64) procedure (f64vector-reverse-copy (f64vec f64vector?) (start integer?) ) ⟹ f64vector?
(srfi 160 f64) procedure (f64vector-reverse-copy (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ f64vector?
The same as f64vector-copy, but in reverse order.
(srfi 160 f64) procedure (f64vector-append (f64vec f64vector?) ... ) ⟹ f64vector?
Returns a f64vector containing all the elements of the f64vecs in order.
(srfi 160 f64) procedure (f64vector-concatenate (list-of-f64vectors list?) ) ⟹ f64vector?
list-of-f64vectors ⟹ (list f64vector? )
The same as f64vector-append, but takes a list of f64vectors rather than multiple arguments.
(srfi 160 f64) procedure (f64vector-append-subvectors (f64vec1 f64vector?) (start1 integer?) (end1 integer?) ... ) ⟹ f64vector?
Concatenates the result of applying f64vector-copy to each triplet of f64vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 f64) procedure (f64vector-empty? (f64vec f64vector?) ) ⟹ boolean?
Returns #t if f64vec has a length of zero, and #f otherwise.
(srfi 160 f64) procedure (f64vector= (f64vec f64vector?) ... ) ⟹ boolean?
Compares the f64vecs for elementwise equality, using = to do the comparisons. Returns #f unless all f64vectors are the same length.
(srfi 160 f64) procedure (f64vector-take (f64vec f64vector?) (n integer?) ) ⟹ f64vector?
(srfi 160 f64) procedure (f64vector-take-right (f64vec f64vector?) (n integer?) ) ⟹ f64vector?
Returns a f64vector containing the first/last n elements of f64vec.
(srfi 160 f64) procedure (f64vector-drop (f64vec f64vector?) (n integer?) ) ⟹ f64vector?
(srfi 160 f64) procedure (f64vector-drop-right (f64vec f64vector?) (n integer?) ) ⟹ f64vector?
Returns a f64vector containing all except the first/last n elements of f64vec.
(srfi 160 f64) procedure (f64vector-segment (f64vec f64vector?) (n integer?) ) ⟹ list?
Returns a list of f64vectors, each of which contains n consecutive elements of f64vec. The last f64vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 f64) procedure (f64vector-fold (kons procedure?) knil (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ *
(kons state (obj1 f64?) (obj2 f64?) ... ) ⟹ *
(srfi 160 f64) procedure (f64vector-fold-right (kons procedure?) knil (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ *
(kons state (obj1 f64?) (obj2 f64?) ... ) ⟹ *
When one f64vector argument f64vec is given, folds kons over the elements of f64vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple f64vector arguments are given, kons is called with the current state value and each value from all the vectors; f64vector-fold scans elements from left to right, while f64vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 f64) procedure (f64vector-map (proc procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ vector?
(proc (val1 f64?) ... ) ⟹ *
(srfi 160 f64) procedure (f64vector-map! (proc procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ undefined
(proc (val1 f64?) ... ) ⟹ *
(srfi 160 f64) procedure (f64vector-for-each (proc procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ undefined
(proc (val1 f64?) ... ) ⟹ undefined
Iterate over the elements of f64vec and apply f to each, returning respectively a f64vector of the results, an undefined value with the results placed back in f64vec, and an undefined value with no change to f64vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For f64vector-map!, only f64vec is modified even when multiple vectors are passed.
If f64vector-map or f64vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 f64) procedure (f64vector-count (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer?
(pred? (val1 f64?) (val2 f64?) ... ) ⟹ *
Call pred? on each element of f64vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 f64) procedure (f64vector-cumulate (f procedure?) knil (f64vec f64vector?) ) ⟹ f64vector?
(f state (value f64?) ) ⟹ *
Like f64vector-fold, but returns an f64vector of partial results rather than just the final result.
(srfi 160 f64) procedure (f64vector-take-while (pred? procedure?) (f64vec f64vector?) ) ⟹ f64vector?
(pred? (value f64?) ) ⟹ boolean?
(srfi 160 f64) procedure (f64vector-take-while-right (pred? procedure?) (f64vec f64vector?) ) ⟹ f64vector?
(pred? (value f64?) ) ⟹ boolean?
Return the shortest prefix/suffix of f64vec all of whose elements satisfy pred?.
(srfi 160 f64) procedure (f64vector-drop-while (pred? procedure?) (f64vec f64vector?) ) ⟹ f64vector?
(pred? (value f64?) ) ⟹ boolean?
(srfi 160 f64) procedure (f64vector-drop-while-right (pred? procedure?) (f64vec f64vector?) ) ⟹ f64vector?
(pred? (value f64?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of f64vec such that all its elements satisfy pred.
(srfi 160 f64) procedure (f64vector-index (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f64?) (value2 f64?) ... ) ⟹ *
(srfi 160 f64) procedure (f64vector-index-right (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f64?) (value2 f64?) ... ) ⟹ *
Return the index of the first/last element of f64vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, f64vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for f64vector-index-right.
(srfi 160 f64) procedure (f64vector-skip (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f64?) (value2 f64?) ... ) ⟹ *
(srfi 160 f64) procedure (f64vector-skip-right (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 f64?) (value2 f64?) ... ) ⟹ *
Returns the index of the first/last element of f64vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, f64vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for f64vector-skip-right.
(srfi 160 f64) procedure (f64vector-any (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ *
(pred? (val1 f64?) (val2 f64?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the f64vec, or #f if there is no such element. If f64vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 f64) procedure (f64vector-every (pred? procedure?) (f64vec1 f64vector?) (f64vec2 f64vector?) ... ) ⟹ *
(pred? (val1 f64?) (val2 f64?) ... ) ⟹ *
If all elements from f64vec satisfy pred?, return the last result of pred?. If not all do, return #f. If f64vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 f64) procedure (f64vector-partition (pred? procedure?) (f64vec f64vector?) ) ⟹ (values f64vector?integer?)
(pred? (value f64?) ) ⟹ boolean?
Returns an f64vector of the same type as f64vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new f64vector and the number of elements satisfying pred?.
(srfi 160 f64) procedure (f64vector-filter (pred? procedure?) (f64vec1 f64vector?) ) ⟹ f64vector?
(pred? (val f64?) ) ⟹ boolean?
(srfi 160 f64) procedure (f64vector-remove (pred? procedure?) (f64vec1 f64vector?) ) ⟹ f64vector?
(pred? (val f64?) ) ⟹ boolean?
Return an f64vector containing the elements of f64vec that satisfy / do not satisfy pred?.
(srfi 160 f64) procedure (f64vector-swap! (f64vec f64vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of f64vec.
(srfi 160 f64) procedure (f64vector-fill! (f64vec f64vector?) (fill f64?) ) ⟹ undefined
(srfi 160 f64) procedure (f64vector-fill! (f64vec f64vector?) (fill f64?) (start integer?) ) ⟹ undefined
(srfi 160 f64) procedure (f64vector-fill! (f64vec f64vector?) (fill f64?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of f64vec from start to end with the value fill.
(srfi 160 f64) procedure (f64vector-reverse! (f64vec f64vector?) ) ⟹ undefined
(srfi 160 f64) procedure (f64vector-reverse! (f64vec f64vector?) (start integer?) ) ⟹ undefined
(srfi 160 f64) procedure (f64vector-reverse! (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of f64vec from start to end.
(srfi 160 f64) procedure (f64vector-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) ) ⟹ undefined
(srfi 160 f64) procedure (f64vector-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) (start integer?) ) ⟹ undefined
(srfi 160 f64) procedure (f64vector-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of f64from from start to end onto f64to, starting at index at.
(srfi 160 f64) procedure (f64vector-reverse-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) ) ⟹ undefined
(srfi 160 f64) procedure (f64vector-reverse-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) (start integer?) ) ⟹ undefined
(srfi 160 f64) procedure (f64vector-reverse-copy! (f64to f64vector?) (at integer?) (f64from f64vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as f64vector-copy!, but copies in reverse
(srfi 160 f64) procedure (f64vector-unfold! (f procedure?) (f64vec f64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like f64vector-unfold, but the elements are copied into the vector f64vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 f64) procedure (f64vector-unfold-right! (f procedure?) (f64vec f64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as f64vector-unfold!, but initializes the f64vector from right to left.
(srfi 160 f64) procedure (reverse-f64vector->list (f64vec f64vector?) ) ⟹ list?
(srfi 160 f64) procedure (reverse-f64vector->list (f64vec f64vector?) (start integer?) ) ⟹ list?
(srfi 160 f64) procedure (reverse-f64vector->list (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as f64vec in reverse order.
(srfi 160 f64) procedure (reverse-list->f64vector (proper-list list?) ) ⟹ f64vector?
Returns f64vector with same elements as list in reverse order.
(srfi 160 f64) procedure (f64vector->vector (f64vec f64vector?) ) ⟹ vector?
(srfi 160 f64) procedure (f64vector->vector (f64vec f64vector?) (start integer?) ) ⟹ vector?
(srfi 160 f64) procedure (f64vector->vector (f64vec f64vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as f64vec.
(srfi 160 f64) procedure (vector->f64vector (vec vector?) ) ⟹ f64vector?
(srfi 160 f64) procedure (vector->f64vector (vec vector?) (start integer?) ) ⟹ f64vector?
(srfi 160 f64) procedure (vector->f64vector (vec vector?) (start integer?) (end integer?) ) ⟹ f64vector?
Returns f64vector with same elements as vec.
(srfi 160 f64) procedure (make-f64vector-generator (f64vector f64vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / f64? /
Returns a SRFI 121 generator that generates all the values of f64vector in order. Note that the generator is finite.
f64vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of f64vector.
(srfi 160 f64) procedure (write-f64vector (f64vec f64vector) ) ⟹ undefined
(srfi 160 f64) procedure (write-f64vector (f64vec f64vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of f64vec in the lexical syntax explained below.
library (srfi 160 c64)
(srfi 160 c64) procedure (make-c64vector (size integer?) ) ⟹ c64vector?
(srfi 160 c64) procedure (make-c64vector (size integer?) (fill c64?) ) ⟹ c64vector?
Returns a c64vector whose length is size. If fill is provided, all the elements of the c64vector are initialized to it.
(srfi 160 c64) procedure (c64vector (value c64?) ... ) ⟹ c64vector?
Returns a c64vector initialized with values.
(srfi 160 c64) procedure (c64vector? obj ) ⟹ boolean?
Returns #t if obj is a c64vector, and #f otherwise.
(srfi 160 c64) procedure (c64vector-length (c64vec c64vector?) ) ⟹ integer?
Returns the length of c64vec
(srfi 160 c64) procedure (c64vector-ref (c64vec c64vector?) (i integer?) ) ⟹ c64?
Returns the ith element of c64vec.
(srfi 160 c64) procedure (c64vector-set! (c64vec c64vector?) (i integer?) (value c64?) ) ⟹ undefined
Sets the ith element of c64vec to value.
(srfi 160 c64) procedure (c64vector->list (c64vec c64vector?) ) ⟹ list?
(srfi 160 c64) procedure (c64vector->list (c64vec c64vector?) (start integer?) ) ⟹ list?
(srfi 160 c64) procedure (c64vector->list (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c64vec
(srfi 160 c64) procedure (list->c64vector (proper-list list?) ) ⟹ c64vector?
proper-list ⟹ (list c64? )
Returns c64vector with same elements as list.
(srfi 160 c64) procedure (c64? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an c64vector (ie., inexact complex), and #f otherwise.
(srfi 160 c64) procedure (c64vector-unfold (f procedure?) (length integer?) seed ) ⟹ c64vector?
(srfi 160 c64) procedure (c64vector-unfold (f procedure?) (length integer?) seed ) ⟹ c64vector?
(f (index integer?) state ) ⟹ (values c64?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 c64) procedure (c64vector-copy (c64vec c64vector?) ) ⟹ c64vector?
(srfi 160 c64) procedure (c64vector-copy (c64vec c64vector?) (start integer?) ) ⟹ c64vector?
(srfi 160 c64) procedure (c64vector-copy (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ c64vector?
Makes a copy of the portion of c64vec from start to end and returns it.
(srfi 160 c64) procedure (c64vector-reverse-copy (c64vec c64vector?) ) ⟹ c64vector?
(srfi 160 c64) procedure (c64vector-reverse-copy (c64vec c64vector?) (start integer?) ) ⟹ c64vector?
(srfi 160 c64) procedure (c64vector-reverse-copy (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ c64vector?
The same as c64vector-copy, but in reverse order.
(srfi 160 c64) procedure (c64vector-append (c64vec c64vector?) ... ) ⟹ c64vector?
Returns a c64vector containing all the elements of the c64vecs in order.
(srfi 160 c64) procedure (c64vector-concatenate (list-of-c64vectors list?) ) ⟹ c64vector?
list-of-c64vectors ⟹ (list c64vector? )
The same as c64vector-append, but takes a list of c64vectors rather than multiple arguments.
(srfi 160 c64) procedure (c64vector-append-subvectors (c64vec1 c64vector?) (start1 integer?) (end1 integer?) ... ) ⟹ c64vector?
Concatenates the result of applying c64vector-copy to each triplet of c64vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 c64) procedure (c64vector-empty? (c64vec c64vector?) ) ⟹ boolean?
Returns #t if c64vec has a length of zero, and #f otherwise.
(srfi 160 c64) procedure (c64vector= (c64vec c64vector?) ... ) ⟹ boolean?
Compares the c64vecs for elementwise equality, using = to do the comparisons. Returns #f unless all c64vectors are the same length.
(srfi 160 c64) procedure (c64vector-take (c64vec c64vector?) (n integer?) ) ⟹ c64vector?
(srfi 160 c64) procedure (c64vector-take-right (c64vec c64vector?) (n integer?) ) ⟹ c64vector?
Returns a c64vector containing the first/last n elements of c64vec.
(srfi 160 c64) procedure (c64vector-drop (c64vec c64vector?) (n integer?) ) ⟹ c64vector?
(srfi 160 c64) procedure (c64vector-drop-right (c64vec c64vector?) (n integer?) ) ⟹ c64vector?
Returns a c64vector containing all except the first/last n elements of c64vec.
(srfi 160 c64) procedure (c64vector-segment (c64vec c64vector?) (n integer?) ) ⟹ list?
Returns a list of c64vectors, each of which contains n consecutive elements of c64vec. The last c64vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 c64) procedure (c64vector-fold (kons procedure?) knil (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ *
(kons state (obj1 c64?) (obj2 c64?) ... ) ⟹ *
(srfi 160 c64) procedure (c64vector-fold-right (kons procedure?) knil (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ *
(kons state (obj1 c64?) (obj2 c64?) ... ) ⟹ *
When one c64vector argument c64vec is given, folds kons over the elements of c64vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple c64vector arguments are given, kons is called with the current state value and each value from all the vectors; c64vector-fold scans elements from left to right, while c64vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 c64) procedure (c64vector-map (proc procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ vector?
(proc (val1 c64?) ... ) ⟹ *
(srfi 160 c64) procedure (c64vector-map! (proc procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ undefined
(proc (val1 c64?) ... ) ⟹ *
(srfi 160 c64) procedure (c64vector-for-each (proc procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ undefined
(proc (val1 c64?) ... ) ⟹ undefined
Iterate over the elements of c64vec and apply f to each, returning respectively a c64vector of the results, an undefined value with the results placed back in c64vec, and an undefined value with no change to c64vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For c64vector-map!, only c64vec is modified even when multiple vectors are passed.
If c64vector-map or c64vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 c64) procedure (c64vector-count (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer?
(pred? (val1 c64?) (val2 c64?) ... ) ⟹ *
Call pred? on each element of c64vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 c64) procedure (c64vector-cumulate (f procedure?) knil (c64vec c64vector?) ) ⟹ c64vector?
(f state (value c64?) ) ⟹ *
Like c64vector-fold, but returns an c64vector of partial results rather than just the final result.
(srfi 160 c64) procedure (c64vector-take-while (pred? procedure?) (c64vec c64vector?) ) ⟹ c64vector?
(pred? (value c64?) ) ⟹ boolean?
(srfi 160 c64) procedure (c64vector-take-while-right (pred? procedure?) (c64vec c64vector?) ) ⟹ c64vector?
(pred? (value c64?) ) ⟹ boolean?
Return the shortest prefix/suffix of c64vec all of whose elements satisfy pred?.
(srfi 160 c64) procedure (c64vector-drop-while (pred? procedure?) (c64vec c64vector?) ) ⟹ c64vector?
(pred? (value c64?) ) ⟹ boolean?
(srfi 160 c64) procedure (c64vector-drop-while-right (pred? procedure?) (c64vec c64vector?) ) ⟹ c64vector?
(pred? (value c64?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of c64vec such that all its elements satisfy pred.
(srfi 160 c64) procedure (c64vector-index (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c64?) (value2 c64?) ... ) ⟹ *
(srfi 160 c64) procedure (c64vector-index-right (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c64?) (value2 c64?) ... ) ⟹ *
Return the index of the first/last element of c64vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, c64vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for c64vector-index-right.
(srfi 160 c64) procedure (c64vector-skip (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c64?) (value2 c64?) ... ) ⟹ *
(srfi 160 c64) procedure (c64vector-skip-right (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c64?) (value2 c64?) ... ) ⟹ *
Returns the index of the first/last element of c64vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, c64vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for c64vector-skip-right.
(srfi 160 c64) procedure (c64vector-any (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ *
(pred? (val1 c64?) (val2 c64?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the c64vec, or #f if there is no such element. If c64vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 c64) procedure (c64vector-every (pred? procedure?) (c64vec1 c64vector?) (c64vec2 c64vector?) ... ) ⟹ *
(pred? (val1 c64?) (val2 c64?) ... ) ⟹ *
If all elements from c64vec satisfy pred?, return the last result of pred?. If not all do, return #f. If c64vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 c64) procedure (c64vector-partition (pred? procedure?) (c64vec c64vector?) ) ⟹ (values c64vector?integer?)
(pred? (value c64?) ) ⟹ boolean?
Returns an c64vector of the same type as c64vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new c64vector and the number of elements satisfying pred?.
(srfi 160 c64) procedure (c64vector-filter (pred? procedure?) (c64vec1 c64vector?) ) ⟹ c64vector?
(pred? (val c64?) ) ⟹ boolean?
(srfi 160 c64) procedure (c64vector-remove (pred? procedure?) (c64vec1 c64vector?) ) ⟹ c64vector?
(pred? (val c64?) ) ⟹ boolean?
Return an c64vector containing the elements of c64vec that satisfy / do not satisfy pred?.
(srfi 160 c64) procedure (c64vector-swap! (c64vec c64vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of c64vec.
(srfi 160 c64) procedure (c64vector-fill! (c64vec c64vector?) (fill c64?) ) ⟹ undefined
(srfi 160 c64) procedure (c64vector-fill! (c64vec c64vector?) (fill c64?) (start integer?) ) ⟹ undefined
(srfi 160 c64) procedure (c64vector-fill! (c64vec c64vector?) (fill c64?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of c64vec from start to end with the value fill.
(srfi 160 c64) procedure (c64vector-reverse! (c64vec c64vector?) ) ⟹ undefined
(srfi 160 c64) procedure (c64vector-reverse! (c64vec c64vector?) (start integer?) ) ⟹ undefined
(srfi 160 c64) procedure (c64vector-reverse! (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of c64vec from start to end.
(srfi 160 c64) procedure (c64vector-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) ) ⟹ undefined
(srfi 160 c64) procedure (c64vector-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) (start integer?) ) ⟹ undefined
(srfi 160 c64) procedure (c64vector-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of c64from from start to end onto c64to, starting at index at.
(srfi 160 c64) procedure (c64vector-reverse-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) ) ⟹ undefined
(srfi 160 c64) procedure (c64vector-reverse-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) (start integer?) ) ⟹ undefined
(srfi 160 c64) procedure (c64vector-reverse-copy! (c64to c64vector?) (at integer?) (c64from c64vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as c64vector-copy!, but copies in reverse
(srfi 160 c64) procedure (c64vector-unfold! (f procedure?) (c64vec c64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like c64vector-unfold, but the elements are copied into the vector c64vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 c64) procedure (c64vector-unfold-right! (f procedure?) (c64vec c64vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as c64vector-unfold!, but initializes the c64vector from right to left.
(srfi 160 c64) procedure (reverse-c64vector->list (c64vec c64vector?) ) ⟹ list?
(srfi 160 c64) procedure (reverse-c64vector->list (c64vec c64vector?) (start integer?) ) ⟹ list?
(srfi 160 c64) procedure (reverse-c64vector->list (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c64vec in reverse order.
(srfi 160 c64) procedure (reverse-list->c64vector (proper-list list?) ) ⟹ c64vector?
Returns c64vector with same elements as list in reverse order.
(srfi 160 c64) procedure (c64vector->vector (c64vec c64vector?) ) ⟹ vector?
(srfi 160 c64) procedure (c64vector->vector (c64vec c64vector?) (start integer?) ) ⟹ vector?
(srfi 160 c64) procedure (c64vector->vector (c64vec c64vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as c64vec.
(srfi 160 c64) procedure (vector->c64vector (vec vector?) ) ⟹ c64vector?
(srfi 160 c64) procedure (vector->c64vector (vec vector?) (start integer?) ) ⟹ c64vector?
(srfi 160 c64) procedure (vector->c64vector (vec vector?) (start integer?) (end integer?) ) ⟹ c64vector?
Returns c64vector with same elements as vec.
(srfi 160 c64) procedure (make-c64vector-generator (c64vector c64vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / c64? /
Returns a SRFI 121 generator that generates all the values of c64vector in order. Note that the generator is finite.
c64vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of c64vector.
(srfi 160 c64) procedure (write-c64vector (c64vec c64vector) ) ⟹ undefined
(srfi 160 c64) procedure (write-c64vector (c64vec c64vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of c64vec in the lexical syntax explained below.
library (srfi 160 c128)
(srfi 160 c128) procedure (make-c128vector (size integer?) ) ⟹ c128vector?
(srfi 160 c128) procedure (make-c128vector (size integer?) (fill c128?) ) ⟹ c128vector?
Returns a c128vector whose length is size. If fill is provided, all the elements of the c128vector are initialized to it.
(srfi 160 c128) procedure (c128vector (value c128?) ... ) ⟹ c128vector?
Returns a c128vector initialized with values.
(srfi 160 c128) procedure (c128vector? obj ) ⟹ boolean?
Returns #t if obj is a c128vector, and #f otherwise.
(srfi 160 c128) procedure (c128vector-length (c128vec c128vector?) ) ⟹ integer?
Returns the length of c128vec
(srfi 160 c128) procedure (c128vector-ref (c128vec c128vector?) (i integer?) ) ⟹ c128?
Returns the ith element of c128vec.
(srfi 160 c128) procedure (c128vector-set! (c128vec c128vector?) (i integer?) (value c128?) ) ⟹ undefined
Sets the ith element of c128vec to value.
(srfi 160 c128) procedure (c128vector->list (c128vec c128vector?) ) ⟹ list?
(srfi 160 c128) procedure (c128vector->list (c128vec c128vector?) (start integer?) ) ⟹ list?
(srfi 160 c128) procedure (c128vector->list (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c128vec
(srfi 160 c128) procedure (list->c128vector (proper-list list?) ) ⟹ c128vector?
proper-list ⟹ (list c128? )
Returns c128vector with same elements as list.
(srfi 160 c128) procedure (c128? obj ) ⟹ boolean?
Returns #t if obj is a valid element of an c128vector (ie., inexact complex), and #f otherwise.
(srfi 160 c128) procedure (c128vector-unfold (f procedure?) (length integer?) seed ) ⟹ c128vector?
(srfi 160 c128) procedure (c128vector-unfold (f procedure?) (length integer?) seed ) ⟹ c128vector?
(f (index integer?) state ) ⟹ (values c128?*)
Creates a vector whose length is length and iterates across each index k between 0 and length - 1, applying f at each iteration to the current index and current state, in that order, to receive two values: the element to put in the kth slot of the new vector and a new state for the next iteration. On the first call to f, the state's value is seed.
(srfi 160 c128) procedure (c128vector-copy (c128vec c128vector?) ) ⟹ c128vector?
(srfi 160 c128) procedure (c128vector-copy (c128vec c128vector?) (start integer?) ) ⟹ c128vector?
(srfi 160 c128) procedure (c128vector-copy (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ c128vector?
Makes a copy of the portion of c128vec from start to end and returns it.
(srfi 160 c128) procedure (c128vector-reverse-copy (c128vec c128vector?) ) ⟹ c128vector?
(srfi 160 c128) procedure (c128vector-reverse-copy (c128vec c128vector?) (start integer?) ) ⟹ c128vector?
(srfi 160 c128) procedure (c128vector-reverse-copy (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ c128vector?
The same as c128vector-copy, but in reverse order.
(srfi 160 c128) procedure (c128vector-append (c128vec c128vector?) ... ) ⟹ c128vector?
Returns a c128vector containing all the elements of the c128vecs in order.
(srfi 160 c128) procedure (c128vector-concatenate (list-of-c128vectors list?) ) ⟹ c128vector?
list-of-c128vectors ⟹ (list c128vector? )
The same as c128vector-append, but takes a list of c128vectors rather than multiple arguments.
(srfi 160 c128) procedure (c128vector-append-subvectors (c128vec1 c128vector?) (start1 integer?) (end1 integer?) ... ) ⟹ c128vector?
Concatenates the result of applying c128vector-copy to each triplet of c128vec, start, end arguments, but may be implemented more efficiently.
(srfi 160 c128) procedure (c128vector-empty? (c128vec c128vector?) ) ⟹ boolean?
Returns #t if c128vec has a length of zero, and #f otherwise.
(srfi 160 c128) procedure (c128vector= (c128vec c128vector?) ... ) ⟹ boolean?
Compares the c128vecs for elementwise equality, using = to do the comparisons. Returns #f unless all c128vectors are the same length.
(srfi 160 c128) procedure (c128vector-take (c128vec c128vector?) (n integer?) ) ⟹ c128vector?
(srfi 160 c128) procedure (c128vector-take-right (c128vec c128vector?) (n integer?) ) ⟹ c128vector?
Returns a c128vector containing the first/last n elements of c128vec.
(srfi 160 c128) procedure (c128vector-drop (c128vec c128vector?) (n integer?) ) ⟹ c128vector?
(srfi 160 c128) procedure (c128vector-drop-right (c128vec c128vector?) (n integer?) ) ⟹ c128vector?
Returns a c128vector containing all except the first/last n elements of c128vec.
(srfi 160 c128) procedure (c128vector-segment (c128vec c128vector?) (n integer?) ) ⟹ list?
Returns a list of c128vectors, each of which contains n consecutive elements of c128vec. The last c128vector may be shorter than n. It is an error if n is not an exact positive integer.
(srfi 160 c128) procedure (c128vector-fold (kons procedure?) knil (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ *
(kons state (obj1 c128?) (obj2 c128?) ... ) ⟹ *
(srfi 160 c128) procedure (c128vector-fold-right (kons procedure?) knil (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ *
(kons state (obj1 c128?) (obj2 c128?) ... ) ⟹ *
When one c128vector argument c128vec is given, folds kons over the elements of c128vec in increasing/decreasing order using knil as the initial value. The kons procedure is called with the state first and the element second, as in SRFIs 43 and 133 (heterogeneous vectors). This is the opposite order to that used in SRFI 1 (lists) and the various string SRFIs.
When multiple c128vector arguments are given, kons is called with the current state value and each value from all the vectors; c128vector-fold scans elements from left to right, while c128vector-fold-right does from right to left. If the lengths of vectors differ, only the portion of each vector up to the length of the shortest vector is scanned.
(srfi 160 c128) procedure (c128vector-map (proc procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ vector?
(proc (val1 c128?) ... ) ⟹ *
(srfi 160 c128) procedure (c128vector-map! (proc procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ undefined
(proc (val1 c128?) ... ) ⟹ *
(srfi 160 c128) procedure (c128vector-for-each (proc procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ undefined
(proc (val1 c128?) ... ) ⟹ undefined
Iterate over the elements of c128vec and apply f to each, returning respectively a c128vector of the results, an undefined value with the results placed back in c128vec, and an undefined value with no change to c128vec.
If more than one vector is passed, f gets one element from each vector as arguments. If the lengths of the vectors differ, iteration stops at the end of the shortest vector. For c128vector-map!, only c128vec is modified even when multiple vectors are passed.
If c128vector-map or c128vector-map! returns more than once (i.e. because of a continuation captured by f), the values returned or stored by earlier returns may be mutated.
(srfi 160 c128) procedure (c128vector-count (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer?
(pred? (val1 c128?) (val2 c128?) ... ) ⟹ *
Call pred? on each element of c128vec and return the number of calls that return true.
When multiple vectors are given, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are given for each iteration, which stops at the end of the shortest vector.
(srfi 160 c128) procedure (c128vector-cumulate (f procedure?) knil (c128vec c128vector?) ) ⟹ c128vector?
(f state (value c128?) ) ⟹ *
Like c128vector-fold, but returns an c128vector of partial results rather than just the final result.
(srfi 160 c128) procedure (c128vector-take-while (pred? procedure?) (c128vec c128vector?) ) ⟹ c128vector?
(pred? (value c128?) ) ⟹ boolean?
(srfi 160 c128) procedure (c128vector-take-while-right (pred? procedure?) (c128vec c128vector?) ) ⟹ c128vector?
(pred? (value c128?) ) ⟹ boolean?
Return the shortest prefix/suffix of c128vec all of whose elements satisfy pred?.
(srfi 160 c128) procedure (c128vector-drop-while (pred? procedure?) (c128vec c128vector?) ) ⟹ c128vector?
(pred? (value c128?) ) ⟹ boolean?
(srfi 160 c128) procedure (c128vector-drop-while-right (pred? procedure?) (c128vec c128vector?) ) ⟹ c128vector?
(pred? (value c128?) ) ⟹ boolean?
Drops the longest initial prefix/suffix of c128vec such that all its elements satisfy pred.
(srfi 160 c128) procedure (c128vector-index (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c128?) (value2 c128?) ... ) ⟹ *
(srfi 160 c128) procedure (c128vector-index-right (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c128?) (value2 c128?) ... ) ⟹ *
Return the index of the first/last element of c128vec that satisfies pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, c128vector-index stops iteration at the end of the shortest one. Lengths of vectors must be the same for c128vector-index-right.
(srfi 160 c128) procedure (c128vector-skip (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c128?) (value2 c128?) ... ) ⟹ *
(srfi 160 c128) procedure (c128vector-skip-right (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ integer? / #f /
(pred? (value1 c128?) (value2 c128?) ... ) ⟹ *
Returns the index of the first/last element of c128vec that does not satisfy pred?.
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, c128vector-skip stops iteration at the end of the shortest one. Lengths of vectors must be the same for c128vector-skip-right.
(srfi 160 c128) procedure (c128vector-any (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ *
(pred? (val1 c128?) (val2 c128?) ... ) ⟹ *
Returns first non-false result of applying pred? on a element from the c128vec, or #f if there is no such element. If c128vec is empty, returns #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector are passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 c128) procedure (c128vector-every (pred? procedure?) (c128vec1 c128vector?) (c128vec2 c128vector?) ... ) ⟹ *
(pred? (val1 c128?) (val2 c128?) ... ) ⟹ *
If all elements from c128vec satisfy pred?, return the last result of pred?. If not all do, return #f. If c128vec is empty, return #t
When multiple vectors are passed, pred? must take the same number of arguments as the number of vectors, and corresponding elements from each vector is passed for each iteration. If the lengths of vectors differ, it stops at the end of the shortest one.
(srfi 160 c128) procedure (c128vector-partition (pred? procedure?) (c128vec c128vector?) ) ⟹ (values c128vector?integer?)
(pred? (value c128?) ) ⟹ boolean?
Returns an c128vector of the same type as c128vec, but with all elements satisfying pred? in the leftmost part of the vector and the other elements in the remaining part. The order of elements is otherwise preserved. Returns two values, the new c128vector and the number of elements satisfying pred?.
(srfi 160 c128) procedure (c128vector-filter (pred? procedure?) (c128vec1 c128vector?) ) ⟹ c128vector?
(pred? (val c128?) ) ⟹ boolean?
(srfi 160 c128) procedure (c128vector-remove (pred? procedure?) (c128vec1 c128vector?) ) ⟹ c128vector?
(pred? (val c128?) ) ⟹ boolean?
Return an c128vector containing the elements of c128vec that satisfy / do not satisfy pred?.
(srfi 160 c128) procedure (c128vector-swap! (c128vec c128vector?) (i integer?) (j integer?) ) ⟹ undefined
Interchanges the ith and jth elements of c128vec.
(srfi 160 c128) procedure (c128vector-fill! (c128vec c128vector?) (fill c128?) ) ⟹ undefined
(srfi 160 c128) procedure (c128vector-fill! (c128vec c128vector?) (fill c128?) (start integer?) ) ⟹ undefined
(srfi 160 c128) procedure (c128vector-fill! (c128vec c128vector?) (fill c128?) (start integer?) (end integer?) ) ⟹ undefined
Fills the portion of c128vec from start to end with the value fill.
(srfi 160 c128) procedure (c128vector-reverse! (c128vec c128vector?) ) ⟹ undefined
(srfi 160 c128) procedure (c128vector-reverse! (c128vec c128vector?) (start integer?) ) ⟹ undefined
(srfi 160 c128) procedure (c128vector-reverse! (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ undefined
Reverses the portion of c128vec from start to end.
(srfi 160 c128) procedure (c128vector-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) ) ⟹ undefined
(srfi 160 c128) procedure (c128vector-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) (start integer?) ) ⟹ undefined
(srfi 160 c128) procedure (c128vector-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) (start integer?) (end integer?) ) ⟹ undefined
Copies the portion of c128from from start to end onto c128to, starting at index at.
(srfi 160 c128) procedure (c128vector-reverse-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) ) ⟹ undefined
(srfi 160 c128) procedure (c128vector-reverse-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) (start integer?) ) ⟹ undefined
(srfi 160 c128) procedure (c128vector-reverse-copy! (c128to c128vector?) (at integer?) (c128from c128vector?) (start integer?) (end integer?) ) ⟹ undefined
The same as c128vector-copy!, but copies in reverse
(srfi 160 c128) procedure (c128vector-unfold! (f procedure?) (c128vec c128vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
Like c128vector-unfold, but the elements are copied into the vector c128vec starting at element start rather than into a newly allocated vector. Terminates when end - start elements have been generated.
(srfi 160 c128) procedure (c128vector-unfold-right! (f procedure?) (c128vec c128vector?) (start integer?) (end integer?) initial-seed ... ) ⟹ undefined
(f (index integer?) seed ... ) ⟹ (values **...)
The same as c128vector-unfold!, but initializes the c128vector from right to left.
(srfi 160 c128) procedure (reverse-c128vector->list (c128vec c128vector?) ) ⟹ list?
(srfi 160 c128) procedure (reverse-c128vector->list (c128vec c128vector?) (start integer?) ) ⟹ list?
(srfi 160 c128) procedure (reverse-c128vector->list (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ list?
Returns a list with same elements as c128vec in reverse order.
(srfi 160 c128) procedure (reverse-list->c128vector (proper-list list?) ) ⟹ c128vector?
Returns c128vector with same elements as list in reverse order.
(srfi 160 c128) procedure (c128vector->vector (c128vec c128vector?) ) ⟹ vector?
(srfi 160 c128) procedure (c128vector->vector (c128vec c128vector?) (start integer?) ) ⟹ vector?
(srfi 160 c128) procedure (c128vector->vector (c128vec c128vector?) (start integer?) (end integer?) ) ⟹ vector?
Returns vector with same elements as c128vec.
(srfi 160 c128) procedure (vector->c128vector (vec vector?) ) ⟹ c128vector?
(srfi 160 c128) procedure (vector->c128vector (vec vector?) (start integer?) ) ⟹ c128vector?
(srfi 160 c128) procedure (vector->c128vector (vec vector?) (start integer?) (end integer?) ) ⟹ c128vector?
Returns c128vector with same elements as vec.
(srfi 160 c128) procedure (make-c128vector-generator (c128vector c128vector?) ) ⟹ procedure?
(return ) ⟹ eof-object? / c128? /
Returns a SRFI 121 generator that generates all the values of c128vector in order. Note that the generator is finite.
c128vector-comparator ⟹ comparator?
Variable containing a SRFI 128 comparator whose components provide ordering and hashing of c128vector.
(srfi 160 c128) procedure (write-c128vector (c128vec c128vector) ) ⟹ undefined
(srfi 160 c128) procedure (write-c128vector (c128vec c128vector) (port output-port?) ) ⟹ undefined
Prints to port (the current output port by default) a representation of c128vec in the lexical syntax explained below.
library (srfi 161)
(srfi 161) procedure (ubox value ) ⟹ ubox?
Constructor. Returns a newly allocated unifiable box initialized to value. The new unifiable box is not equal to any previously constructed unifiable box.
(srfi 161) procedure (ubox? object ) ⟹ boolean?
Predicate. Returns #t if object is a unifiable box, and #f otherwise.
(srfi 161) procedure (ubox-ref (ubox ubox?) ) ⟹ *
Accessor. Returns the current value of the unifiable box ubox.
(srfi 161) procedure (ubox-set! (ubox ubox?) value ) ⟹ undefined
Mutator. Changes the unifiable box ubox to hold value. The return value is unspecified.
(srfi 161) procedure (ubox=? (ubox1 ubox?) (ubox2 ubox?) ) ⟹ boolean?
Equality predicate. Returns #t if ubox1 and ubox2 are equal unifiable boxes, and #f otherwise.
(srfi 161) procedure (ubox-unify! (proc procedure?) (ubox1 ubox?) (ubox2 ubox?) ) ⟹ undefined
(proc value1 value2 ) ⟹ *
Union operation. Invokes proc on the values of ubox1 and ubox2, makes ubox1 and ubox2 equal, and updates their value to the result of the invocation of proc. The return value is unspecified.
(srfi 161) procedure (ubox-union! (ubox1 ubox?) (ubox2 ubox?) ) ⟹ undefined
Union operation. Makes the unifiable boxes ubox1 and ubox2 equal. The value of the unified box is the value of either ubox1 or ubox2 before the unification. The return value is unspecified.
(srfi 161) procedure (ubox-link! (ubox1 ubox?) (ubox2 ubox?) ) ⟹ undefined
Union operation. Makes the unifiable boxes ubox1 and ubox2 equal. The value of the unified box is the value of ubox2 before the unification. The return value is unspecified.
library (srfi 162)
(srfi 162) procedure (comparator-max (comarator comparator?) obj1 obj2 ... ) ⟹ *
(srfi 162) procedure (comparator-min (comarator comparator?) obj1 obj2 ... ) ⟹ *
(srfi 162) procedure (comparator-max-in-list (comarator comparator?) (list list?) ) ⟹ *
(srfi 162) procedure (comparator-min-in-list (comarator comparator?) (list list?) ) ⟹ *
These procedures are analogous to min and max respectively, but may be applied to any orderable objects, not just to real numbers. They apply the ordering procedure of comparator to the objects to find and return a minimal (or maximal) object. The order in which the values are compared is unspecified. If two objects are equal in the sense of the comparator, either may be returned.
The -in-list versions accept a single list argument.
default-comparator ⟹ comparator?
A pre-created default comparator. It should behave exactly like a comparator returned by SRFI 128 make-default-comparator.
boolean-comparator ⟹ comparator?
A comparator for booleans such that #f compares before #t.
real-comparator ⟹ comparator?
A comparator for real numbers such that smaller numbers compare before larger numbers.
char-comparator ⟹ comparator?
A comparator for characters using Unicode codepoint order.
char-ci-comparator ⟹ comparator?
A comparator for characters using char-ci<?.
string-comparator ⟹ comparator?
A comparator for strings using the implementation-specific definition of string<?.
string-ci-comparator ⟹ comparator?
A comparator for strings using the implementation-specific definition of string-ci<?.
pair-comparator ⟹ comparator?
Compares pairs as if by the application of make-pair-comparator to pairs with default-comparator as the car and cdr comparators.
list-comparator ⟹ comparator?
Compares lists as if by the application of make-list-comparator to lists with default-comparator as the element comparator.
vector-comparator ⟹ comparator?
Compares vectors as if by the application of make-vector-comparator to vectors with default-comparator as the element comparator.
eq-comparator ⟹ comparator?
eqv-comparator ⟹ comparator?
equal-comparator ⟹ comparator?
comparators whose functions behave as follows:
These comparators accept circular structure (in the case of equal-comparator, provided the implementation's equal? predicate does so) and NaNs.
library (srfi 165)
(srfi 165) procedure (make-computation-environment-variable (name (or string?symbol?)) default (immutable? boolean?) ) ⟹ computation-env-variable
Returns a Scheme object that can be used as an environment variable, whose default value is default and which is immutable if immutable? is not #f. The symbol or string name is solely for debugging purposes. The type of the returned object is unspecified. Each invocation returns an environment variable different to any previously returned environment variable.
(srfi 165) procedure (make-computation-environment ) ⟹ computation-env
Returns a new environment, in which environment variables can be bound to values. The type of the returned object is unspecified.
(srfi 165) procedure (computation-environment-ref (env computation-env) (var computation-env-variable) ) ⟹ *
If the variable var is bound to a value in the environment env, returns that value, and the environment variable's default value otherwise.
(srfi 165) procedure (computation-environment-update (env computation-env) (var1 computation-env-variable) val1 ... ) ⟹ computation-env
The arguments arg... alternate between environment variables var and values val. Returns a new environment that extends the environment env by binding each environment variable var to the respective value val.
(srfi 165) procedure (computation-environment-update! (env computation-env) (var computation-env-variable) val ) ⟹ undefined
Updates the environment env in place by binding the environment variable var to val, and returns an unspecified value.
(srfi 165) procedure (computation-environment-copy (env computation-env) ) ⟹ computation-env
Returns a fresh copy of the environment env.
(srfi 165) procedure (make-computation (proc procedure?) ) ⟹ computation
(proc (compute procedure?) ) ⟹ *
(compute (computation computation) ) ⟹ *
Takes a procedure proc, which takes one argument, and returns a computation. The Scheme type of a computation is disjoint from any type, as if created by define-record-type, except possibly procedures.
When the computation is later executed on an environment, the procedure proc is called with an argument compute, which is a procedure taking one argument. Whenever compute is invoked on another computation, the other computation is executed on the environment and its results are returned. The results yielded by the execution are the results of the invocation of proc.
(srfi 165) procedure (computation-run (computation computation) ) ⟹ *
Executes the computation computation and returns the results it yields.
(srfi 165) procedure (computation-ask ) ⟹ computation
Returns a computation that, when executed on an environment, yields that environment.
(srfi 165) procedure (computation-local (updater procedure?) (computation computation) ) ⟹ computation
(updater (env computation-env) ) ⟹ computation-env
Returns a computation that, when executed on an environment env, invokes the procedure updater on env, executes the computation computation on the result of the invocation of updater, which must be an environment, and yields its results.
(srfi 165) procedure (computation-pure obj1 ... ) ⟹ computation
Returns a computation that, when executed, yields the values obj1...
(srfi 165) procedure (computation-each (computation1 computation) ... ) ⟹ computation
Returns a computation that, when executed, sequentially executes the computations computation1, …, computationn and yields the results yielded by the last computation.
(srfi 165) procedure (computation-each-in-list (list list?) ) ⟹ computation
list ⟹ (list computation )
Equivalent to (computation-each computation1 ... computationn) if list is a list whose elements are computation1, ..., computationn.
(srfi 165) procedure (computation-bind (computation computation) (proc1 procedure?) ... ) ⟹ computation
(proc obj ) ⟹ computation
(computation-bind computation) is equivalent to computation. (computation-bind computation proc1 proc2 ...) is equivalent to (computation-bind (computation-bind computation proc1) proc2 ...).
The invocation of (computation-bind computation proc) returns a computation that, when executed, executes the computation computation, on which results the procedure proc is then invoked, resulting in a computation that is then executed and whose results are yielded.
(srfi 165) procedure (computation-sequence (list list?) ) ⟹ computation
list ⟹ (list computation )
When invoked on a list list of computations, returns a computation that, when executed, executes the computations in sequence and yields a list whose elements are the results yielded by the computations.
(srfi 165) procedure (computation-forked (computation1 computation) ... ) ⟹ computation
Returns a computation that, when executed on an environment, executes each of the computations computation1, ... on fresh copies of the environment, and finally executes computation_n on the original environment and yields its results.
(srfi 165) procedure (computation-bind/forked (computation computation) (proc1 procedure?) ... ) ⟹ computation
(proc obj ) ⟹ computation
As (computation-bind computation proc1 ...), but executes computation on a fresh copy of the environment.
(srfi 165) syntax (computation-fn () ((_ ((variable1 init1) ...) body) computation ) )
Evaluates the expressions init1... to environment variables var1... in an unspecified order and returns a computation that, when executed, lexically binds the variables variable1... to the values to which the environment variables var1, ... are bound, and evaluates the body in the resulting lexical environment. The value of the last expression in body has to be a computation, which is then executed and its results yielded.
A clause of the form (variable variable) (i.e. the expression init is the variable reference variable) can be abbreviated by variable.
An unbound environment variable behaves as if it were bound to its default value.
(srfi 165) syntax (computation-with () ((_ ((variable1 init1) ...) expr1 ... expr_n) computation ) )
Evaluates the expressions expr1...expr_n to computations computation1, ..., computation_n, the expressions variable1... to environment variables var1... and the expressions init1... to values val1... in an unspecified order, and returns a computation that, when executed on an environment, extends that environment non-destructively by binding var1,... to val1..., sequentially executes the computations computation1, ... computation_n on that extended environment, and then yields the results of the last computation.
(srfi 165) syntax (computation-with! () ((_ (variable1 init1) ...) computation ) )
Evaluates the expressions variable1... to mutable environment variables var1... and the expressions init1... to values val1... in an unspecified order, and returns a computation that, when executed on an environment, modifies this environment in place by binding var1,... to val1... and which yields an unspecified value.
default-computation ⟹ computation-env-variable
This SRFI exports the identifier default-computation, which is bound to a location holding a mutable environment variable (as if created by (make-computation-environment-variable)) in the sense of this SRFI. In each fresh computation environment, default-computation is initially unbound. Whenever a computation computation is to be executed on an environment and is neither a computation nor a procedure, the value to which default-computation is bound in the environment has to be a procedure, which is then invoked on computation to return a computation, which is then executed on the environment.
(srfi 165) syntax (define-computation-type () ((_ make-environment run clause ...)) )
(variable default) (variable default "immutable") variable
This syntax may appear wherever other definitions may appear. Each clause is of the form (variable default), (variable default "immutable"), or variable. The latter form is equivalent to (variable #f). make-environment, run, and each variable are identifiers.
An instance of define-computation-type is equivalent to the following definitions:
library (srfi 180)
(srfi 180) procedure (json-write obj obj ) ⟹ undefined
(srfi 180) procedure (json-write obj obj (port-or-accumulator (or port?procedure?)) ) ⟹ undefined
JSON writer procedure. PORT-OR-ACCUMULATOR must be a textual output port, or an accumulator that accepts characters and strings. The default value of PORT-OR-ACCUMULATOR is the value returned by the procedure current-output-port. The value returned by json-write is unspecified.
json-write will validate that OBJ can be serialized into JSON before writing to PORT. An error that satisfies json-error? is raised in the case where OBJ is not an object or a composition of the following types:
(srfi 180) procedure (json-accumulator (port-or-accumulator (or port?procedure?)) ) ⟹ procedure?
Streaming event-based JSON writer. PORT-OR-ACCUMULATOR must be a textual output port or an accumulator that accepts characters and strings. It returns an accumulator procedure that accepts Scheme objects as its first and only argument and that follows the same protocol as described in json-generator. Any deviation from the protocol must raise an error that satisfies json-error?. In particular, objects and arrays must be properly nested.
Mind the fact that most JSON parsers have a nesting limit that is not documented by the standard. Even if you can produce arbitrarily nested JSON with this library, you might not be able to read it with another library.
(srfi 180) procedure (json-sequence-read ) ⟹ procedure?
(srfi 180) procedure (json-sequence-read (port-or-generator (or port?procedure?)) ) ⟹ procedure?
JSON reader of JSON Text Sequences (RFC 7464). As its first and only argument, it takes a generator of characters or a textual input port whose default value is the value returned by current-input-port. It will return a generator of Scheme objects as specified in json-read.
(srfi 180) procedure (json-lines-read ) ⟹ procedure?
(srfi 180) procedure (json-lines-read (port-or-generator (or port?generator?)) ) ⟹ procedure?
JSON reader of jsonlines or ndjson. As its first and only argument, it takes a generator of characters or a textual input port whose default value is the value returned by current-input-port. It will return a generator of Scheme objects as specified in json-read.
(srfi 180) procedure (json-read ) ⟹ *
(srfi 180) procedure (json-read (port-or-generator (or port?procedure?)) ) ⟹ *
JSON reader procedure. PORT-OR-GENERATOR must be a textual input port or a generator of characters. The default value of PORT-OR-GENERATOR is the value returned by the procedure current-input-port. The returned value is a Scheme object. json-read must return only the first toplevel JSON value or structure. When there are multiple toplevel values or structures in PORT-OR-GENERATOR, the user should call json-read several times to read all of it.
The mapping between JSON types and Scheme objects is the following:
In the case where nesting of arrays or objects reaches the value returned by the parameter json-nesting-depth-limit, json-read must raise an object that satisfies the predicate json-error?
(srfi 180) procedure (json-fold (proc procedure?) (array-start procedure?) (array-end procedure?) (object-start procedure?) (object-end procedure?) seed ) ⟹ *
(srfi 180) procedure (json-fold (proc procedure?) (array-start procedure?) (array-end procedure?) (object-start procedure?) (object-end procedure?) seed (port-or-generator (or port?procedure?)) ) ⟹ *
(proc obj seed ) ⟹ *
(array-start obj seed ) ⟹ *
(array-end obj seed ) ⟹ *
(object-start obj seed ) ⟹ *
(object-end obj seed ) ⟹ *
Fundamental JSON iterator.
json-fold will read the JSON text from PORT-OR-GENERATOR, which has (current-input-port) as its default value. json-fold will call the procedures passed as argument:
ARRAY-START and ARRAY-END take the same arguments, and have similar behavior, but are called for iterating on JSON arrays.
json-fold must return the seed when:
(srfi 180) procedure (json-generator ) ⟹ procedure?
(srfi 180) procedure (json-generator (port-or-generator (or port?procedure?)) ) ⟹ procedure?
Streaming event-based JSON reader. PORT-OR-GENERATOR default value is the value returned by current-input-port. It must be a textual input port or a generator of characters. json-generator returns a generator of Scheme objects, each of which must be one of:
In the case where nesting of arrays or objects reaches the value returned by the parameter json-nesting-depth-limit, the generator must raise an object that satisfies the predicate json-error?
In cases where the JSON is invalid, the generator returned by json-generator should raise an object that satisfies the predicate json-error?.
Otherwise, if PORT-OR-GENERATOR contains valid JSON text, the generator returned by json-generator must yield an end-of-file object in two situations:
In other words, the generator returned by json-generator will parse at most one JSON value or one top-level structure. If PORT is not finished, as in the case of JSON lines, the user should call json-generator again with the same PORT-OR-GENERATOR.
(srfi 180) procedure (json-number-of-character-limit ) ⟹ procedure?
Parameter holding a number that represents the maximum number of characters for a given JSON text that can be read by json-generator, json-fold, and json-read. If the value returned by this parameter is reached, the implementation must raise an error that satisfies json-error?.
The default value of json-number-of-character-limit is +inf.0.
A proper value should be set on a per-application basis to mitigate the risks of denial-of-service attacks.
(srfi 180) procedure (json-nesting-depth-limit ) ⟹ procedure?
Parameter holding a number that represents the maximum nesting depth of JSON text that can be read by json-generator, json-fold, and json-read. If the value returned by this parameter is reached, the implementation must raise an error that satisfies json-error?.
The default value of json-nesting-depth-limit is +inf.0.
A proper value should be set on a per-application basis to mitigate the risks of denial-of-service attacks.
(srfi 180) procedure (json-null? obj ) ⟹ boolean?
Return #t if OBJ is the Scheme symbol 'null, which represents the JSON null in Scheme. In all other cases, return #f.
(srfi 180) procedure (json-error-reason (err json-error?) ) ⟹ string?
Return a string explaining the reason for the error. This should be human-readable.
(srfi 180) procedure (json-error? obj ) ⟹ boolean?
Returns #t if OBJ is an error object that is specific to this library.
library (srfi 185)
(srfi 185) procedure (string-append-linear! (dst string?) (string-or-char (or string?char?)) ... ) ⟹ string?
This procedure returns a string which extends dst by appending each additional string-or-char (in order) to the end of dst. A character argument and a string argument of length 1 are treated exactly the same way. The result can either be dst itself or a newly allocated string.
There is no requirement that this procedure execute in constant time, even amortised (i.e. average) constant time.
(srfi 185) procedure (string-replace-linear! (dst string?) (dst-start integer?) (dst-end integer?) (src string?) ) ⟹ string?
(srfi 185) procedure (string-replace-linear! (dst string?) (dst-start integer?) (dst-end integer?) (src string?) (src-start integer?) ) ⟹ string?
(srfi 185) procedure (string-replace-linear! (dst string?) (dst-start integer?) (dst-end integer?) (src string?) (src-start integer?) (src-end integer?) ) ⟹ string?
Returns a string which has the same characters as dst, except that the characters between dst-start and dst-end have been replaced with the characters of the string src between src-start and src-end. The result can either be dst itself or a newly allocated string.
The number of characters from src may be different than the number replaced in dst, so the result may be larger or smaller than the previous length of dst. The special case where dst-start is equal to dst-end corresponds to insertion; the case where src-start is equal to src-end corresponds to deletion. 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.)
When src is a string then (string-append-linear! dst src) is equivalent to (string-replace-linear! dst (string-length dst) (string-length dst) src).
(srfi 185) syntax (string-append! () ((_ place string-or-char ...)) )
string-or-char ⟹ string?
string-or-char ⟹ char?
This macro sets place to the result of invoking (string-append-linear! place string-or-char ...). It returns an unspecified value.
(srfi 185) syntax (string-replace! () ((_ dst-place dst-start dst-end src)) ((_ dst-place dst-start dst-end src src-start)) ((_ dst-place dst-start dst-end src src-start src-end)) )
dst-start ⟹ integer?
dst-end ⟹ integer?
src ⟹ string?
src-start ⟹ integer?
src-end ⟹ integer?
This macro sets dst-place to the result of applying string-replace-linear! to its arguments. The result is an unspecified value.
library (srfi 190)
(srfi 190) syntax (coroutine-generator () ((_ body) procedure? ) )
Creates a generator from a coroutine. When evaluated, immediately returns a generator g. When g is called, the definitions and expressions in <body> are evaluated until the yielding procedure of the coroutine generator is called. Calling the yielding procedure of the coroutine generator causes the evaluation of <body> to be suspended, and g returns the value passed to yield.
Whether this generator is finite or infinite depends on the behavior of <body>. If the last expression in body> returns, it is the end of the sequence — g returns an end-of-file object from then on.
(srfi 190) procedure (yield ) ⟹ procedure?
(return value ) ⟹ undefined
Evaluates to the yielding procedure in the (expansion of the) <body> of a coroutine generator. It is an error to evaluate yield outside the body of a coroutine generator.
(srfi 190) syntax (define-coroutine-generator () ((_ name body)) ((_ (name . formals) body)) )
Expands into
(define <name> (coroutine-generator <body>))
and
(define (<name> . <formals>) (coroutine-generator <body>))
respectively.
library (srfi 193)
(srfi 193) procedure (command-line ) ⟹ list?
return ⟹ (list string? )
This procedure is equivalent to the R6RS and R7RS command-line procedure, but specified in more detail.
R6RS definition: "Returns a nonempty list of strings. The first element is an implementation-specific name for the running top-level program. The remaining elements are command-line arguments according to the operating system’s conventions."
R7RS definition: "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."
Additional stipulations by this SRFI:
(srfi 193) procedure (command-name ) ⟹ string? / #f /
return ⟹ (list string? )
Returns a friendly version of (car (command-line)) evaluated in the current lexical environment.
If (car (command-line)) is a zero-length string, #f is returned to indicate "not a command".
Otherwise a friendly command name is typically derived from a filename as follows:
For example, both the Windows filename C:\Program Files\Fantastic Scheme\fantastic-scheme-1.0.EXE and the Unix filename /usr/local/bin/fantastic-scheme-1.0 would be typically shortened to fantastic-scheme-1.0.
(srfi 193) procedure (command-args ) ⟹ list?
return ⟹ (list string? )
Returns (cdr (command-line)) evaluated in the current lexical environment.
(srfi 193) procedure (script-file ) ⟹ string? / #f /
Returns an absolute pathname pointing to the calling script. Symbolic links are not resolved.
(The script may or may not be a command; use command-name to find out.)
If the calling program is not a script, #f is returned.
Implementations must resolve the absolute pathname of a script before running that script. The script may change the working directory, thereby changing the interpretation of relative pathnames.
(srfi 193) procedure (script-directory ) ⟹ string? / #f /
Returns only the non-filename part of script-file as a string. As with script-file, this is an absolute pathname.
The string should end with a directory separator (a forward slash on Unix; a backslash on Windows; an appropriate character on other operating systems) so that string-append can be easily used to build pathnames based on it: for example, (string-append (script-directory) "my-data-file"). However, if appending such a separator would make the pathname invalid on the underlying operating system, the separator is not added.
If the calling program is not a script, #f is returned.
library (srfi 196)
(srfi 196) procedure (range (length integer?) (indexer procedure?) ) ⟹ range?
(indexer (index integer?) ) ⟹ *
Returns a range whose length (number of elements) is length. The indexer procedure returns the nth element (where 0 ≤ n < length) of the range, given n. This procedure must run in O(1) time. The range returned is compact, although indexer may close over arbitrarily large data structures. The average accessing time of the resulting range is the average time needed to run indexer.
(srfi 196) procedure (numeric-range (start number?) (end number?) ) ⟹ range?
(srfi 196) procedure (numeric-range (start number?) (end number?) (step number?) ) ⟹ range?
Returns a numeric range, a special case of a range specified by an inclusive lower bound start, an exclusive upper bound end, and a step value (default 1), all of which can be exact or inexact real numbers. This constructor produces the sequence
start, (+ start step), (+ start (* 2 step)), …, (+ start (* n step)),
where n is the greatest integer such that (+ start (* n step)) < end if step is positive, or such that (+ start (* n step)) > end if step is negative. It is is an error if an n satisfying this condition cannot be determined, or if step is numerically zero. This procedure must run in O(1) time. The average accessing time of the resulting range must be O(1).
Note that an effect of this definition is that the elements of a range over inexact numbers are enumerated by multiplying the index by the step value rather than by adding the step value to itself repeatedly. This reduces the likelihood of roundoff errors.
(srfi 196) procedure (iota-range (length integer?) ) ⟹ range?
(srfi 196) procedure (iota-range (length integer?) (start number?) ) ⟹ range?
(srfi 196) procedure (iota-range (length integer?) (start number?) (step number?) ) ⟹ range?
Returns an iota-numeric range, a special case of a range specified by a length (a non-negative exact integer) as well as an inclusive lower bound start (default 0) and a step value (default 1), both of which can be exact or inexact real numbers. This constructor produces the sequence
start, (+ start step), (+ start (* 2 step)), …, (+ start (* (- length 1) step)),
This procedure must run in O(1) time. The average accessing time of the resulting range must be O(1).
Note that an effect of this definition is that the elements of a range over inexact numbers are enumerated by multiplying the index by the step value rather than by adding the step value to itself repeatedly. This reduces the likelihood of roundoff errors.
(srfi 196) procedure (vector-range (vector vector?) ) ⟹ range?
Returns a range whose elements are those of vector. The procedure must run in O(1) time. The average accessing time of the resulting range must be O(1). It is an error to mutate vector.
(srfi 196) procedure (string-range (string string?) ) ⟹ range?
Returns a range whose elements are those of string. It is an error to mutate string. This procedure must run in O(n) time, where n is the length of string. The average accessing time of the resulting range must be O(1).
In a Scheme that guarantees O(1) random access to strings, range-ref on a range created by string-range can simply call string-ref, and the resulting range is compact. But if only O(n) access is available, this procedure may have to copy the string's characters into a vector, resulting in an expanded range.
(srfi 196) procedure (range-append (range range?) ... ) ⟹ range?
Returns a range whose elements are the elements of the ranges in order. This procedure must run in O(n) + O(k) time, where n is the total number of elements in all the ranges and k is the number of ranges. The result is usually expanded but may be compact. The average accessing time of the resulting range is asymptotically bounded by maximum of the average accessing times of the ranges.
(srfi 196) procedure (range-reverse (range range?) ) ⟹ range?
Returns a range whose elements are the elements of the range but in reverse order. This procedure must run in O(s) time, where s is the total accessing time of range. The resulting range may be expanded, and should have O(1) average accessing time.
(srfi 196) procedure (range? obj ) ⟹ boolean?
Returns #t if obj is a range and #f otherwise. This procedure must run in O(1) time.
(srfi 196) procedure (range=? (equal procedure?) (range1 range?) (range2 range?) ... ) ⟹ boolean?
(equal el1 el2 ) ⟹ boolean?
Returns #t if all the ranges are of the same length and if their corresponding values are the same in the sense of equal, and #f otherwise. The runtime of this procedure is O(s) + O(k), where s is the sum of the total accessing times of the ranges and k is the number of ranges.
(srfi 196) procedure (range-length (range range?) ) ⟹ integer?
Returns the length (number of elements) of range. This procedure must run in O(1) time.
(srfi 196) procedure (range-ref (range range?) (n integer?) ) ⟹ *
Returns the nth element of range. It is an error if n is less than 0 or greater than or equal to the length of range. The running time of this procedure must be asymptotically equal to the average accessing time of range.
(srfi 196) procedure (range-first (range range?) ) ⟹ *
Equivalent (in running time as well) to (range-ref range 0).
(srfi 196) procedure (range-last (range range?) ) ⟹ *
Equivalent (in running time as well) to (range-ref range (- (range-length range) 1)).
(srfi 196) procedure (range-split-at (range range?) (index integer?) ) ⟹ (values range?range?)
Returns two values: (range-take range index) and (range-drop range index). It is an error if index is not an exact integer between 0 and the length of range, both inclusive. This procedure must run in O(1) time.
(srfi 196) procedure (subrange (range range?) (start integer?) (end integer?) ) ⟹ range?
Returns a range which contains the elements of range from index start, inclusive, through index end, exclusive. This procedure must run in O(1) time. The average accessing time of the resulting range is asymptotically bounded by the average accessing time of range.
(srfi 196) procedure (range-segment (range range?) (length integer?) ) ⟹ list?
return ⟹ (list (range range?) )
Returns a list of ranges representing the consecutive subranges of length length. The last range is allowed to be shorter than length. The procedure must run in O(k) time, where k is the number of ranges returned. The average accessing time of the ranges is asymptotically bounded by the average accessing time of range.
(srfi 196) procedure (range-take (range range?) (count integer?) ) ⟹ range?
(srfi 196) procedure (range-take-right (range range?) (count integer?) ) ⟹ range?
Returns a range which contains the first/last count elements of range. The average accessing time of the resulting ranges is asymptotically bounded by the average accessing time of range.
(srfi 196) procedure (range-drop (range range?) (count integer?) ) ⟹ range?
(srfi 196) procedure (range-drop-right (range range?) (count integer?) ) ⟹ range?
Returns a range which contains all except the first/last count elements of range. These procedures must run in O(1) time. The average accessing time of the resulting ranges is asymptotically bounded by the average accessing time respectively of range.
(srfi 196) procedure (range-count (pred procedure?) (range1 range?) (range2 range?) ... ) ⟹ integer?
(pred obj ) ⟹ boolean?
Applies pred element-wise to the elements of ranges and returns the number of applications which returned true values. If more than one range is given and not all ranges have the same length, range-count terminates when the shortest range is exhausted. The runtime of this procedure is O(s) where s is the sum of the total accessing times of the ranges.
(srfi 196) procedure (range-any (pred procedure?) (range1 range?) (range2 range?) ... ) ⟹ *
(pred obj ) ⟹ boolean?
Invokes pred element-wise to the elements of the ranges until one call returns a true value, and then returns that value. Otherwise, #f is returned. If more than one range is given and not all ranges have the same length, range-any terminates when the shortest range is exhausted. The runtime of this procedure is O(s) where s is the sum of the total accessing times of the ranges.
(srfi 196) procedure (range-every (pred procedure?) (range1 range?) (range2 range?) ... ) ⟹ *
(pred obj ) ⟹ boolean?
Applies pred element-wise to the elements of the ranges and returns true if pred returns true on every application. Specifically it returns the last value returned by pred, or #t if pred was never invoked. Otherwise, #f is returned. If more than one range is given and not all ranges have the same length, range-every terminates when the shortest range is exhausted. The runtime of this procedure is O(s) + O(k), where s is the sum of the total accessing times of the ranges and k is the number of ranges.
(srfi 196) procedure (range-map (proc procedure?) (range1 range?) (range2 range?) ... ) ⟹ range?
(proc el1 el2 ... ) ⟹ *
(srfi 196) procedure (range-map->list (proc procedure?) (range1 range?) (range2 range?) ... ) ⟹ list?
(proc el1 el2 ... ) ⟹ *
(srfi 196) procedure (range-map->vector (proc procedure?) (range1 range?) (range2 range?) ... ) ⟹ vector?
(proc el1 el2 ... ) ⟹ *
Applies proc element-wise to the elements of the ranges and returns a range/list/vector of the results, in order. If more than one range is given and not all ranges have the same length, these procedures terminate when the shortest range is exhausted. The dynamic order in which proc is actually applied to the elements is unspecified. The runtime of these procedures is O(s) where s is the sum of the total accessing times of the ranges. The range-map procedure eagerly computes its result and returns an expanded range. Its average accessing time is O(1).
(srfi 196) procedure (range-for-each (proc procedure?) (range1 range?) (range2 range?) ... ) ⟹ undefined
(proc el1 el2 ... ) ⟹ undefined
Applies proc element-wise to the elements of the ranges in order. Returns an unspecified result. If more than one range is given and not all ranges have the same length, range-for-each terminates when the shortest range is exhausted. The runtime of this procedure is O(s) where s is the sum of the total accessing times of the ranges.
(srfi 196) procedure (range-filter-map (proc procedure?) (range1 range?) (range2 range?) ... ) ⟹ range?
(proc el1 el2 ... ) ⟹ *
(srfi 196) procedure (range-filter-map->list (proc procedure?) (range1 range?) (range2 range?) ... ) ⟹ list?
(proc el1 el2 ... ) ⟹ *
Applies proc element-wise to the elements of the ranges and returns a range/list of the true values returned by proc. If more than one range is given and not all ranges have the same length, these procedures terminate when the shortest range is exhausted. The dynamic order in which proc is actually applied to the elements is unspecified. The range-filter-map procedure eagerly computes its result and returns an expanded range. The runtime of these procedures is O(n) where n is the sum of the total accessing times of the ranges.
(srfi 196) procedure (range-filter (proc procedure?) (range range?) ) ⟹ range?
(proc el ) ⟹ boolean?
(srfi 196) procedure (range-filter->list (proc procedure?) (range range?) ) ⟹ list?
(proc el ) ⟹ boolean?
(srfi 196) procedure (range-remove (proc procedure?) (range range?) ) ⟹ range?
(proc el ) ⟹ boolean?
(srfi 196) procedure (range-remove->list (proc procedure?) (range range?) ) ⟹ list?
(proc el ) ⟹ boolean?
Returns a range/list containing the elements of range that satisfy / do not satisfy pred. The runtime of these procedures is O(s) where s is the sum of the total accessing times of the ranges.
The range-filter and range-remove procedures eagerly compute their results and return expanded ranges. Their average accessing time is O(1).
(srfi 196) procedure (range-fold (kons procedure?) nil (range1 range?) (range2 range?) ... ) ⟹ *
(kons state el1 el2 ... ) ⟹ *
(srfi 196) procedure (range-fold-right (kons procedure?) nil (range1 range?) (range2 range?) ... ) ⟹ *
(kons state el1 el2 ... ) ⟹ *
Folds kons over the elements of ranges in order / reverse order. kons is applied as (kons state (range-ref range1 i) (range-ref range2 i) …) where state is the result of the previous invocation and i is the current index. For the first invocation, nil is used as the first argument. Returns the result of the last invocation, or nil if there was no invocation. If more than one range is given and not all ranges have the same length, these procedures terminate when the shortest range is exhausted. The runtime of these procedures must be O(s) where s is the sum of the total accessing times of the ranges.
(srfi 196) procedure (range-index (pred procedure?) (range1 range?) (range2 range?) ... ) ⟹ #f / integer? /
(pred el1 el2 ... ) ⟹ boolean?
(srfi 196) procedure (range-index-right (pred procedure?) (range1 range?) (range2 range?) ... ) ⟹ #f / integer? /
(pred el1 el2 ... ) ⟹ boolean?
Applies pred element-wise to the elements of ranges and returns the index of the first/last element at which pred returns true. Otherwise, returns #f. If more than one range is given and not all ranges have the same length, range-index terminates when the shortest range is exhausted. It is an error if the ranges passed to range-index-right do not all have the same lengths. The runtime of these procedures must be O(s) where s is the sum of the total accessing times of the ranges.
(srfi 196) procedure (range-take-while (pred procedure?) (range range?) ) ⟹ range?
(pred el ) ⟹ boolean?
(srfi 196) procedure (range-take-while-right (pred procedure?) (range range?) ) ⟹ range?
(pred el ) ⟹ boolean?
Returns a range containing the leading/trailing elements of range that satisfy pred up to the first/last one that does not. The runtime of these procedures is asymptotically bounded by the total accessing time of the range. The average accessing time of the resulting range is O(1).
(srfi 196) procedure (range-drop-while (pred procedure?) (range range?) ) ⟹ range?
(pred el ) ⟹ boolean?
(srfi 196) procedure (range-drop-while-right (pred procedure?) (range range?) ) ⟹ range?
(pred el ) ⟹ boolean?
Returns a range that omits leading/trailing elements of range that satisfy pred until the first/last one that does not. The runtime of these procedures is asymptotically bounded by the total accessing time of the range. The average accessing time of the resulting range is O(1).
(srfi 196) procedure (range->list (range range?) ) ⟹ list?
(srfi 196) procedure (range->vector (range range?) ) ⟹ vector?
(srfi 196) procedure (range->string (range range?) ) ⟹ string?
Returns a list/vector/string containing the elements of range in order. It is an error to modify the result of range->vector or of range->string. In the case of range->string, it is an error if any element of range is not a character. The running times of these procedures is O(s) where s is the total accessing time for range.
(srfi 196) procedure (vector->range (vector vector?) ) ⟹ range?
Returns an expanded range whose elements are those of vector. Note that, unlike vector-range, it is not an error to mutate vector; future mutations of vector are guaranteed not to affect the range returned by vector->range. This procedure must run in O(n) where n is the length of vector. Otherwise, this procedure is equivalent to vector-range.
(srfi 196) procedure (range->generator (range range?) ) ⟹ procedure?
(return ) ⟹ *
Returns a SRFI 158 generator that generates the elements of range in order. This procedure must run in O(1) time, and the running time of each call of the generator is asymptotically bounded by the average accessing time of range.
library (srfi 197)
(srfi 197) syntax (chain () ((_ initial-value step ...)) ((_ initial-value placeholder step ...)) ((_ initial-value placeholder ellipsis step ...)) )
(datum ...)
Syntax: <initial-value> is an expression.
<placeholder> and <ellipsis> are literal symbols; these are the placeholder symbol and ellipsis symbol. If <placeholder> or <ellipsis> are not present, they default to _ and ..., respectively.
The syntax of <step> is (<datum> ...), where each <datum> is either the placeholder symbol, the ellipsis symbol, or an expression. A <step> must contain at least one <datum>. The ellipsis symbol is only allowed at the end of a <step>, and it must immediately follow a placeholder symbol.
Semantics: chain evaluates each <step> in order from left to right, passing the result of each step to the next.
Each <step> is evaluated as an application, and the return value(s) of that application are passed to the next step as its pipeline values. <initial-value> is the pipeline value of the first step. The return value(s) of chain are the return value(s) of the last step.
The placeholder symbols in each <step> are replaced with that step's pipeline values, in the order they appear. It is an error if the number of placeholders for a step does not equal the number of pipeline values for that step, unless the step contains no placeholders, in which case it will ignore its pipeline values.
(srfi 197) syntax (chain-and () ((_ initial-value step ...)) ((_ initial-value placeholder step ...)) )
(datum ...)
Syntax: <initial-value> is an expression. <placeholder> is a literal symbol; this is the placeholder symbol. If <placeholder> is not present, the placeholder symbol is _. The syntax of <step> is (<datum> ... [<_> <datum> ...]), where <_> is the placeholder symbol.
Semantics: A variant of chain that short-circuits and returns #f if any step returns #f. chain-and is to chain as SRFI 2 and-let* is to let*.
Each <step> is evaluated as an application. If the step evaluates to #f, the remaining steps are not evaluated, and chain-and returns #f. Otherwise, the return value of the step is passed to the next step as its pipeline value. <initial-value> is the pipeline value of the first step. If no step evaluates to #f, the return value of chain-and is the return value of the last step.
The <_> placeholder in each <step> is replaced with that step's pipeline value. If a <step> does not contain <_>, it will ignore its pipeline value, but chain-and will still check whether that pipeline value is #f.
Because chain-and checks the return value of each step, it does not support steps with multiple return values. It is an error if a step returns more than one value.
(srfi 197) syntax (chain-when () ((_ initial-value (guard step) ...)) ((_ initial-value placeholder (guard step) ...)) ((_ initial-value (step) ...)) ((_ initial-value placeholder (step) ...)) )
(datum ...)
Syntax: <initial-value> and <guard> are expressions. <placeholder> is a literal symbol; this is the placeholder symbol. If <placeholder> is not present, the placeholder symbol is _. The syntax of <step> is (<datum> ... [<_> <datum> ...]), where <_> is the placeholder symbol.
Semantics: A variant of chain in which each step has a guard expression and will be skipped if the guard expression evaluates to #f.
Each <step> is evaluated as an application. The return value of the step is passed to the next step as its pipeline value. <initial-value> is the pipeline value of the first step.
The <_> placeholder in each <step> is replaced with that step's pipeline value. If a <step> does not contain <_>, it will ignore its pipeline value
If a step's <guard> is present and evaluates to #f, that step will be skipped, and its pipeline value will be reused as the pipeline value of the next step. The return value of chain-when is the return value of the last non-skipped step, or <initial-value> if all steps are skipped.
Because chain-when may skip steps, it does not support steps with multiple return values. It is an error if a step returns more than one value.
(srfi 197) syntax (chain-lambda () ((_ initial-value step ...) procedure? ) ((_ initial-value placeholder step ...) procedure? ) ((_ initial-value placeholder ellipsis step ...) procedure? ) )
(datum ...)
Syntax: <placeholder> and <ellipsis> are literal symbols; these are the placeholder symbol and ellipsis symbol. If <placeholder> or <ellipsis> are not present, they default to _ and ..., respectively.
The syntax of <step> is (<datum> ...), where each <datum> is either the placeholder symbol, the ellipsis symbol, or an expression. A <step> must contain at least one <datum>. The ellipsis symbol is only allowed at the end of a <step>, and it must immediately follow a placeholder symbol.
Semantics: Creates a procedure from a sequence of chain steps. When called, a chain-lambda procedure evaluates each <step> in order from left to right, passing the result of each step to the next.
Each <step> is evaluated as an application, and the return value(s) of that application are passed to the next step as its pipeline values. The procedure's arguments are the pipeline values of the first step. The return value(s) of the procedure are the return value(s) of the last step.
The placeholder symbols in each <step> are replaced with that step's pipeline values, in the order they appear. It is an error if the number of placeholders for a step does not equal the number of pipeline values for that step, unless the step contains no placeholders, in which case it will ignore its pipeline values.
If a <step> ends with a placeholder symbol followed by an ellipsis symbol, that placeholder sequence is replaced with all remaining pipeline values that do not have a matching placeholder.
The number of placeholders in the first <step> determines the arity of the procedure. If the first step ends with an ellipsis symbol, the procedure is variadic.
(srfi 197) syntax (nest () ((_ step ... initial-value)) ((_ placeholder step ... initial-value)) )
(datum ...)
Syntax: <placeholder> is a literal symbol; this is the placeholder symbol. If <placeholder> is not present, the placeholder symbol is _. The syntax of <step> is (<datum> ... <_> <datum> ...), where <_> is the placeholder symbol. <initial-value> is expression.
Semantics: nest is similar to chain, but sequences its steps in the opposite order. Unlike chain, nest literally nests expressions; as a result, it does not provide the same strict evaluation order guarantees as chain.
A nest expression is evaluated by lexically replacing the <_> in the last <step> with <initial-value>, then replacing the <_> in the next-to-last <step> with that replacement, and so on until the <_> in the first <step> has been replaced. It is an error if the resulting final replacement is not an expression, which is then evaluated and its values are returned.
Because it produces an actual nested form, nest can build expressions that chain cannot. For example, nest can build a quoted data structure:
nest can also safely include special forms like if, let, lambda, or parameterize in a pipeline.
(srfi 197) syntax (nest-reverse () ((_ initial-value step ...)) ((_ initial-value placeholder step ...)) )
(datum ...)
Syntax: <initial-value> is an expression. <placeholder> is a literal symbol; this is the placeholder symbol. If <placeholder> is not present, the placeholder symbol is _. The syntax of <step> is (<datum> ... <_> <datum> ...), where <_> is the placeholder symbol.
Semantics: nest-reverse is variant of nest that nests in reverse order, which is the same order as chain.
A nest-reverse expression is evaluated by lexically replacing the <_> in the first <step> with <initial-value>, then replacing the <_> in the second <step> with that replacement, and so on until the <_> in the last <step> has been replaced. It is an error if the resulting final replacement is not an expression, which is then evaluated and its values are returned.
library (srfi 219)
(srfi 219) syntax (define () ((_ variable expression)) ((_ (variable parameter1 ...) body)) ((_ (variable parameter1 ... . parameter) body)) ((_ ((variable inner-param1 ...) outter-param1 ...) body)) ((_ ((variable inner-param1 ...) outter-param1 ... . outter-rest) body)) ((_ ((variable inner-param1 ... . inner-rest) outter-param1 ...) body)) ((_ ((variable inner-param1 ... . inner-rest) outter-param1 ... . outter-rest) body)) )
The shorthand version of define behaves as follows:
(define symbol expr)
defines symbol with the value expr
(define (symbol . args) expr ...)
defines symbol with the value (lambda args expr ...)
(define ((symbol . args1) . args) expr ...)
defines symbol with the value (lambda args1 (lambda args expr ...))
(define (((symbol . args2) . args1) . args) expr ...)
defines symbol with the value (lambda args2 (lambda args1 (lambda args expr ...)))
and so on.
library (srfi 236)
(srfi 236) syntax (independently () ((_ expression ...)) )
Evaluates the ⟨expressions⟩s in an unspecified order and discards their return values. The result of the independently expression is unspecified.
Note: Although the order of evaluation is otherwise unspecified, the effect of any concurrent evaluation of the ⟨expressions⟩ is constrained to be consistent with some sequential order of evaluation. The order of evaluation may be chosen differently for each evaluation of the independently form.
library (srfi 239)
(srfi 239) syntax (list-case () ((_ expression list-case-clause ...) * ) )
((variable . variable) body) (() body) (variable body)
A list-case expression is evaluated as follows: The ⟨expression⟩ is evaluated. The further evaluation then depends on the type of the result:
If the result is a pair and a clause of the form [(⟨variable1⟩ . ⟨variable2⟩) ⟨body⟩] is present, the ⟨variables⟩ are bound to locations holding the car and the cdr of the pair, the ⟨body⟩ is evaluated and its results returned.
If the result is () and clause of the form [() ⟨body⟩] is present, the ⟨body⟩ is evaluated and its results returned.
If the result is neither a pair nor () and a clause of the form [⟨variable⟩ ⟨body⟩] is present, the ⟨variable⟩ is bound to a location holding the result, the ⟨body⟩ is evaluated and its results returned.
If no corresponding clause is present, an exception of type &assertion-violation is raised.
The region of the bindings consists of the corresponding ⟨body⟩. If _ appears in place of a ⟨variable⟩, the corresponding location is not bound to any variable.
If the list-case expression is in tail context, the ⟨bodies⟩ are in tail context as well.
library (srfi 253)
(srfi 253) syntax (check-arg () ((_ predicate arg caller)) ((_ predicate arg)) )
(predicate obj ) ⟹ *
Guarantees that the arg (evaluated) conforms to the predicate (evaluated). Implementations can enforce the predicate check in all the code that follows, but are not required to. It is an error if predicate returns #f when called on arg. Otherwise, return value is unspecified. Implementations may use optional caller (evaluated) argument as the error who/origin if/when signaling a checking error.
(srfi 253) syntax (values-checked () ((_ (predicate ...) value ...) (values *...) ) )
(predicate obj ) ⟹ *
Guarantees that the values (evaluated) abide by the given predicates (the number of values and predicates should match) and returns them as multiple values. It is an error if any of the predicates returns false. Implementations may choose to coerce the values when the types are compatible (e.g. integer -> inexact).
(srfi 253) syntax (check-case (=> else ) ((_ key (predicate expression ...) ...)) ((_ key (predicate expression ...) ... (else expression ...))) )
(predicate obj ) ⟹ *
check-case checks whether the value satisfies one of the predicates. If any of the predicates is satisfied, it evaluates the body corresponding to the first one that is satisfied. If none of the predicates is satisfied and there’s an else clause, it evaluates to the body of that clause; and if there’s it is an error if there’s no else clause and no other clause is satisfied.
(srfi 253) syntax (lambda-checked () ((_ (arg ...) body ...) procedure? ) )
name (name predicate)
(predicate obj ) ⟹ *
A regular lambda, but with any argument (except the rest argument) optionally having the form (name predicate) (as compared to default single-symbol form). Arguments of this extended form are guaranteed to satisfy the respective (evaluated) predicate. At least on procedure application time. This guarantee might be extended for all the procedure body, including for any modification and shadowing, at implementors' will. It is an error if either of the arguments does not satisfy the predicate.
(srfi 253) syntax (case-lambda-checked () ((_ clause ...) procedure? ) )
((arg ...) body ...) ((arg arg ... . args) body ...) (args body ...)
name (name predicate)
(predicate obj ) ⟹ *
Same as case-lambda, but with any argument taking a form of (name predicate) to be checked. See lambda-checked for other details.
(srfi 253) syntax (define-checked () ((_ (proc-name arg ...) body ...) procedure? ) ((_ name predicate value)) )
name (name predicate)
(predicate obj ) ⟹ *
Defines a procedure or variable satisfying the given predicates. For procedures, effectively equal to define+lambda-checked. For variables, checks the value (and, if implementation supports that, all the subsequent modifications) for the predicate match.
(srfi 253) syntax (define-record-type-checked () ((_ type-name (constructor arg-name ...) predicate-name field ...)) )
(name predicate accessor) (name predicate accessor modifier)
(predicate obj ) ⟹ *
Defines a record type with checked constructor and field accessors/modifiers. type-name, constructor, and predicate are the same as R7RS define-record-type's (note especially the constructor—checks are not allowed in it, only arg-name symbols!) Fields are either of the form (field-name predicate accessor-name) or (field-name predicate accessor-name modifier-name). These ensure that accessor and modifier return checked data and check new data respectively. It is an error if any of the checks are not successful.