Next: Byte, Previous: Array Interpolation, Up: Data Structures [Contents][Index]

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.

Next: Byte, Previous: Array Interpolation, Up: Data Structures [Contents][Index]