Association Lists
-----------------
`(require 'alist)'
Alist functions provide utilities for treating a list of key-value
pairs as an associative database. These functions take an equality
predicate, PRED, as an argument. This predicate should be repeatable,
symmetric, and transitive.
Alist functions can be used with a secondary index method such as hash
tables for improved performance.
- Function: predicate->asso pred
Returns an "association function" (like `assq', `assv', or
`assoc') corresponding to PRED. The returned function returns a
key-value pair whose key is `pred'-equal to its first argument or
`#f' if no key in the alist is PRED-equal to the first argument.
- Function: alist-inquirer pred
Returns a procedure of 2 arguments, ALIST and KEY, which returns
the value associated with KEY in ALIST or `#f' if KEY does not
appear in ALIST.
- Function: alist-associator pred
Returns a procedure of 3 arguments, ALIST, KEY, and VALUE, which
returns an alist with KEY and VALUE associated. Any previous
value associated with KEY will be lost. This returned procedure
may or may not have side effects on its ALIST argument. An
example of correct usage is:
(define put (alist-associator string-ci=?))
(define alist '())
(set! alist (put alist "Foo" 9))
- Function: alist-remover pred
Returns a procedure of 2 arguments, ALIST and KEY, which returns
an alist with an association whose KEY is key removed. This
returned procedure may or may not have side effects on its ALIST
argument. An example of correct usage is:
(define rem (alist-remover string-ci=?))
(set! alist (rem alist "foo"))
- Function: alist-map proc alist
Returns a new association list formed by mapping PROC over the
keys and values of ALIST. PROC must be a function of 2 arguments
which returns the new value part.
- Function: alist-for-each proc alist
Applies PROC to each pair of keys and values of ALIST. PROC must
be a function of 2 arguments. The returned value is unspecified.