Search

( alist-cons key datum [ list? alist ] ) list?
(lambda (key datum alist) (cons (cons key datum) alist)) Cons a new alist entry mapping key -> datum onto alist.
( alist-cons key datum [ list? alist ] ) list?
(lambda (key datum alist) (cons (cons key datum) alist)) Cons a new alist entry mapping key -> datum onto alist.
( alist-copy [ list? alist ] ) list?
Make a fresh copy of alist. This means copying each pair that forms an association as well as the spine of the list.
( alist-copy [ list? alist ] ) list?
Make a fresh copy of alist. This means copying each pair that forms an association as well as the spine of the list.
( alist-delete key [ list? alist ] ) list? ( alist-delete key [ list? alist ] [ 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.
( alist-delete key [ list? alist ] ) list? ( alist-delete key [ list? alist ] [ 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.
( alist-delete! key [ list? alist ] ) list? ( alist-delete! key [ list? alist ] [ 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.
( alist-delete! key [ list? alist ] ) list? ( alist-delete! key [ list? alist ] [ 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.
( append [ list? list ] ... ) list? ( 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.
( append [ list? list ] ... ) list? ( 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.
( append [ list? list ] ... ) list? ( 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.
( append! [ list? list ] ... ) list? ( 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.
( append! [ list? list ] ... ) list? ( 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.
( append-map [ procedure? proc ] [ list? list1 ] [ list? list2 ] ... ) 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.
( append-map [ procedure? proc ] [ list? list1 ] [ list? list2 ] ... ) 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.
( append-map! [ procedure? proc ] [ list? list1 ] [ list? list2 ] ... ) 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.
( append-map! [ procedure? proc ] [ list? list1 ] [ list? list2 ] ... ) 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.
( append-reverse [ list? rev-head ] [ list? tail ] ) list? ( append-reverse [ list? rev-head ] 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.
( append-reverse [ list? rev-head ] [ list? tail ] ) list? ( append-reverse [ list? rev-head ] 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.
( append-reverse! [ list? rev-head ] [ list? tail ] ) list? ( append-reverse! [ list? rev-head ] 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.
( append-reverse! [ list? rev-head ] [ list? tail ] ) list? ( append-reverse! [ list? rev-head ] 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.
( assoc obj [ list? alist ] ) ( or list? #f ) ( assoc obj [ list? alist ] [ procedure? = ] ) ( or 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
( assoc obj [ list? alist ] ) ( or list? #f ) ( assoc obj [ list? alist ] [ procedure? = ] ) ( or 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
( break [ procedure? pred ] [ list? list ] ) ( values list? list? ) ( break [ procedure? pred ] [ circular-list? 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.
( break [ procedure? pred ] [ list? list ] ) ( values list? list? ) ( break [ procedure? pred ] [ circular-list? 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.
( break! [ procedure? pred ] [ 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.
( break! [ procedure? pred ] [ 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.
( 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.
( delete obj [ list? list ] ) list? ( 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.
( delete obj [ list? list ] ) list? ( 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.
( delete! obj [ list? list ] ) list? ( 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.
( delete! obj [ list? list ] ) list? ( 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.
( delete-duplicates [ list? list ] ) list? ( 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.
( delete-duplicates [ list? list ] ) list? ( 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.
( delete-duplicates! [ list? list ] ) list? ( 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.