@c -*-texinfo-*-
@c This is part of the GNU Emacs Lisp Reference Manual.
-@c Copyright (C) 1990-1995, 1998-1999, 2001-2014 Free Software
+@c Copyright (C) 1990-1995, 1998-1999, 2001-2016 Free Software
@c Foundation, Inc.
@c See the file elisp.texi for copying conditions.
@node Lists
We say that ``the @sc{car} of this cons cell is'' whatever object
its @sc{car} slot currently holds, and likewise for the @sc{cdr}.
- A list is a series of cons cells ``chained together'', so that each
+ A list is a series of cons cells chained together, so that each
cell refers to the next one. There is one cons cell for each element
of the list. By convention, the @sc{car}s of the cons cells hold the
elements of the list, and the @sc{cdr}s are used to chain the list
@node List-related Predicates
@section Predicates on Lists
+@cindex predicates for lists
+@cindex list predicates
The following predicates test whether a Lisp object is an atom,
whether it is a cons cell or is a list, or whether it is the
@node List Variables
@section Modifying List Variables
+@cindex modify a list
+@cindex list modification
These functions, and one macro, provide convenient ways
to modify a list which is stored in a variable.
@cindex destructive list operations
You can modify the @sc{car} and @sc{cdr} contents of a cons cell with the
-primitives @code{setcar} and @code{setcdr}. We call these ``destructive''
+primitives @code{setcar} and @code{setcdr}. These are destructive
operations because they change existing list structure.
@cindex CL note---@code{rplaca} vs @code{setcar}
@node Setcar
@subsection Altering List Elements with @code{setcar}
+@cindex replace list element
+@cindex list, replace element
Changing the @sc{car} of a cons cell is done with @code{setcar}. When
used on a list, @code{setcar} replaces one element of a list with a
@node Setcdr
@subsection Altering the CDR of a List
+@cindex replace part of list
The lowest-level primitive for modifying a @sc{cdr} is @code{setcdr}:
@cindex reordering, of elements in lists
@cindex modification of lists
- Here are some functions that rearrange lists ``destructively'' by
-modifying the @sc{cdr}s of their component cons cells. We call these
-functions ``destructive'' because they chew up the original lists passed
+ Here are some functions that rearrange lists destructively by
+modifying the @sc{cdr}s of their component cons cells. These functions
+are destructive because they chew up the original lists passed
to them as arguments, relinking their cons cells to form a new list that
is the returned value.
@code{rassoc} is like @code{assoc} except that it compares the @sc{cdr} of
each @var{alist} association instead of the @sc{car}. You can think of
-this as ``reverse @code{assoc}'', finding the key for a given value.
+this as reverse @code{assoc}, finding the key for a given value.
@end defun
@defun assq key alist
@end smallexample
@end defun
+@defun alist-get key value &optional default
+This function is like @code{assq}, but instead of returning the entire
+association for @var{key}, @code{(@var{key} . @var{value})}, it
+returns just the @var{value}. It returns @var{default} if @var{key}
+is not found in @var{alist}, defaulting to @code{nil} if @var{default}
+is omitted.
+@end defun
+
@defun rassq value alist
This function returns the first association with value @var{value} in
@var{alist}. It returns @code{nil} if no association in @var{alist} has
@code{rassq} is like @code{assq} except that it compares the @sc{cdr} of
each @var{alist} association instead of the @sc{car}. You can think of
-this as ``reverse @code{assq}'', finding the key for a given value.
+this as reverse @code{assq}, finding the key for a given value.
For example:
@node Plist Access
@subsection Property Lists Outside Symbols
+@cindex plist access
+@cindex accessing plist properties
The following functions can be used to manipulate property lists.
They all compare property names using @code{eq}.