This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Source for wiki ListsCowan version 2

author

cowan

comment


    

ipnr

69.195.55.172

name

ListsCowan

readonly

0

text

This proposal is a tiny extension to SRFI 1.  The procedures come from Common Lisp, with a little renaming.  Some Common Lisp procedures are already in SRFI 1 and don't appear here.

== Association lists ==

`(make-alist `''keys values''`)`

Returns a newly allocated alist whose pairs are constructed from the elements of the lists ''keys'' and ''values''.  (Common Lisp PAIRLIS.)

`Reverse-assq`, `reverse-assv`, and `reverse-assoc` are the same as `assq`, `assv`, and `assoc` respectively, except that the key is matched against the cdr rather than the car of the pairs in the alist.  (Common Lisp RASSOC.)

== Predicates ==

`(atom? `''obj''`)`

Returns `#f` if ''obj'' is a pair, and `#t` otherwise.  (Common Lisp ATOM.)

`(end? `''obj''`)`

Returns `#t` if ''obj'' is the empty list, `#f` if ''obj'' is a pair.  It signals an error otherwise.  (Common Lisp ENDP.)

== Substitution ==

`(substitute `''newobj oldobj list''`)`

`(substitute! `''newobj oldobj list''`)`

`Substitute` returns a newly constructed list in which all elements of ''list'' that are the same (in the sense of `eqv?`) as ''oldobj'' have been replaced by ''newobj''.  `Substitute!` does the same thing, but may destructively modify ''list''.  (Common Lisp SUBSTITUTE, NSUBSTITUTE.)

`(transform `''transformer predicate list''`)`

`(transform! `''transformer predicate list''`)`

`Transform` returns a newly constructed list in which all elements of ''list'' on which ''predicate'' returns `#t` have been replaced by the result of calling ''transformer'' on the element.  `Transform!` does the same, but may destructively modify ''list''.  (Closely related to Common Lisp SUBSTITUTE-IF, NSUBSTITUTE-IF.)

== Issues ==

Should these procedures, if accepted, be merged into the SRFI 1 package?

time

2012-11-23 15:40:45

version

2