384 |
@end defun |
@end defun |
385 |
|
|
386 |
@defun last list &optional n |
@defun last list &optional n |
387 |
This function returns the last link of @var{list}. The |
This function returns the last link of @var{list}. The @code{car} of |
388 |
@code{car} of this link is the list's last element. If @var{list} is |
this link is the list's last element. If @var{list} is null, |
389 |
null, @code{nil} is returned. If @var{n} is non-nil the |
@code{nil} is returned. If @var{n} is non-@code{nil}, the |
390 |
@var{n}-th-to-last link is returned instead, or the whole @var{list} if |
@var{n}th-to-last link is returned instead, or the whole of @var{list} |
391 |
@var{n} is bigger than @var{list}'s length. |
if @var{n} is bigger than @var{list}'s length. |
392 |
@end defun |
@end defun |
393 |
|
|
394 |
@defun safe-length list |
@defun safe-length list |
733 |
destructively. See @ref{Sets And Lists}. |
destructively. See @ref{Sets And Lists}. |
734 |
@end defun |
@end defun |
735 |
|
|
736 |
|
@defun copy-tree tree &optional vecp |
737 |
|
This function returns a copy the tree @code{tree}. If @var{tree} is a |
738 |
|
cons cell, this makes a new cons cell with the same @sc{car} and |
739 |
|
@sc{cdr}, then recursively copies the @sc{car} and @sc{cdr} in the |
740 |
|
same way. |
741 |
|
|
742 |
|
Normally, when @var{tree} is anything other than a cons cell, |
743 |
|
@code{copy-tree} simply returns @var{tree}. However, if @var{vecp} is |
744 |
|
non-@code{nil}, it copies vectors too (and operates recursively on |
745 |
|
their elements). |
746 |
|
@end defun |
747 |
|
|
748 |
|
@defun number-sequence from to &optional separation |
749 |
|
This returns a list of numbers starting with @var{from} |
750 |
|
and incrementing by @var{separation} (or by 1 if @var{separation} |
751 |
|
is @code{nil} or omitted), and ending at or just before @var{to}. |
752 |
|
For example, |
753 |
|
|
754 |
|
@example |
755 |
|
(number-sequence 4 9) |
756 |
|
@result{} (4 5 6 7 8 9) |
757 |
|
(number-sequence 1.5 6 2) |
758 |
|
@result{} (1.5 3.5 5.5) |
759 |
|
@end example |
760 |
|
@end defun |
761 |
|
|
762 |
@node Modifying Lists |
@node Modifying Lists |
763 |
@section Modifying Existing List Structure |
@section Modifying Existing List Structure |
764 |
@cindex destructive list operations |
@cindex destructive list operations |
1670 |
@defun assq-delete-all key alist |
@defun assq-delete-all key alist |
1671 |
@tindex assq-delete-all |
@tindex assq-delete-all |
1672 |
This function deletes from @var{alist} all the elements whose @sc{car} |
This function deletes from @var{alist} all the elements whose @sc{car} |
1673 |
is @code{eq} to @var{key}. It returns @var{alist}, modified |
is @code{eq} to @var{key}, much as if you used @code{delq} to delete |
1674 |
in this way. Note that it modifies the original list structure |
such each element one by one. It returns the shortened alist, and |
1675 |
of @var{alist}. |
often modifies the original list structure of @var{alist}. For |
1676 |
|
correct results, use the return value of @code{assq-delete-all} rather |
1677 |
|
than looking at the saved value of @var{alist}. |
1678 |
|
|
1679 |
@example |
@example |
1680 |
(assq-delete-all 'foo |
(setq alist '((foo 1) (bar 2) (foo 3) (lose 4))) |
1681 |
'((foo 1) (bar 2) (foo 3) (lose 4))) |
@result{} ((foo 1) (bar 2) (foo 3) (lose 4)) |
1682 |
|
(assq-delete-all 'foo alist) |
1683 |
@result{} ((bar 2) (lose 4)) |
@result{} ((bar 2) (lose 4)) |
1684 |
|
alist |
1685 |
|
@result{} ((foo 1) (bar 2) (lose 4)) |
1686 |
@end example |
@end example |
1687 |
@end defun |
@end defun |
1688 |
|
|
1689 |
|
@ignore |
1690 |
|
arch-tag: 31fb8a4e-4aa8-4a74-a206-aa00451394d4 |
1691 |
|
@end ignore |