assoc, assoc_equal
assoc, assoc_equal — search an association list for a sublist.
assoc (s_exp, list)
assoc_equal (s_exp, list)
s_expAny Gamma or Lisp expression.
listAn association list.
A list whose members are the remainder of the association list starting
at the element whose car is eq or equal to the s_exp.
An association list is a list whose elements are also lists, each of
which typically contains exactly two elements. assoc
searches an association list for a sublist whose car is eq to the given
s_exp. assoc_equal uses
equal instead of eq for the comparison. If no matching sublist is found,
returns nil.
A symbol-indexed association list (or sym-alist) is an association list
where the car of each element is a symbol. This is a common construct for
implementing property lists and lookup tables. Since symbols are always
unique, sym-alists can be searched with assoc instead
of assoc_equal.
Gamma>a = 10;10Gamma>b = 20;20Gamma>c = 30;30Gamma>x = list (list(a,15), list(b,25), list(c, 35));((10 15) (20 25) (30 35))Gamma>assoc (b,x);((20 25) (30 35))Gamma>assoc (20,x);nilGamma>assoc_equal(20,x);((20 25) (30 35))Gamma>