[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
predicates on lists
From: |
David Roderick |
Subject: |
predicates on lists |
Date: |
Wed, 26 Mar 2008 12:20:04 +0000 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.990 (windows-nt) |
Elisp 5.8
-- Function: assoc-default key alist &optional test default
This function searches ALIST for a match for KEY. For each
element of ALIST, it compares the element (if it is an atom) or
the element's CAR (if it is a cons) against KEY, by calling TEST
with two arguments: the element or its CAR, and KEY. The
arguments are passed in that order so that you can get useful
results using `string-match' with an alist that contains regular
expressions (*note Regexp Search::). If TEST is omitted or `nil',
`equal' is used for comparison.
I am a bit confused. I thought that an element inside of an associated
list is a dotted pair of its CAR and CDR, and the KEY is the CAR. The
argument as key in the above function confused me. Having solved this
problem, and realizing that this function is complicated, am I correct
in thinking that an atom is (atom OBJECT) == (not (consp OBJECT))
This is confusing because an atom is a fundamental building block
outside of Elisp, and a cons cell is a fundamental building block by
Elisp.
It seems that anything which is not a cons cell should be a molecule.
Ok, now that I have got this silly questioning over and done with, a
further query arises in my brain.
you can get useful
results using `string-match' with an alist that contains regular
expressions (*note Regexp Search::).
Does the string-match contain a regular expression or does the alisp
contain a regular expression?
My guess is the string-match may contain a regular expression, but
this process of deduction might be
eliminated if the explanation was revised.
--
from
David Roderick
- predicates on lists,
David Roderick <=