Copyright (C) 2000-2012 |
GNU Info (cl)Association ListsAssociation Lists ================= An "association list" is a list representing a mapping from one set of values to another; any list whose elements are cons cells is an association list. - Function: assoc* item a-list &key :test :test-not :key This function searches the association list A-LIST for an element whose `car' matches (in the sense of `:test', `:test-not', and `:key', or by comparison with `eql') a given ITEM. It returns the matching element, if any, otherwise `nil'. It ignores elements of A-LIST which are not cons cells. (This corresponds to the behavior of `assq' and `assoc' in Emacs Lisp; Common Lisp's `assoc' ignores `nil's but considers any other non-cons elements of A-LIST to be an error.) - Function: rassoc* item a-list &key :test :test-not :key This function searches for an element whose `cdr' matches ITEM. If A-LIST represents a mapping, this applies the inverse of the mapping to ITEM. The `assoc-if', `assoc-if-not', `rassoc-if', and `rassoc-if-not' functions are defined similarly. Two simple functions for constructing association lists are: - Function: acons key value alist This is equivalent to `(cons (cons KEY VALUE) ALIST)'. - Function: pairlis keys values &optional alist This is equivalent to `(nconc (mapcar* 'cons KEYS VALUES) ALIST)'. |