mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-08 04:30:45 -08:00
(Sets And Lists): Add delete-dups.
This commit is contained in:
parent
9fa0334c27
commit
42101e875d
1 changed files with 16 additions and 1 deletions
|
|
@ -1223,7 +1223,8 @@ useful example of @code{sort}.
|
|||
A list can represent an unordered mathematical set---simply consider a
|
||||
value an element of a set if it appears in the list, and ignore the
|
||||
order of the list. To form the union of two sets, use @code{append} (as
|
||||
long as you don't mind having duplicate elements). Other useful
|
||||
long as you don't mind having duplicate elements). You can remove
|
||||
@code{equal} duplicates using @code{delete-dups}. Other useful
|
||||
functions for sets include @code{memq} and @code{delq}, and their
|
||||
@code{equal} versions, @code{member} and @code{delete}.
|
||||
|
||||
|
|
@ -1431,6 +1432,20 @@ be a string and that it ignores differences in letter-case and text
|
|||
representation: upper-case and lower-case letters are treated as
|
||||
equal, and unibyte strings are converted to multibyte prior to
|
||||
comparison.
|
||||
@end defun
|
||||
|
||||
@defun delete-dups list
|
||||
This function destructively removes all @code{equal} duplicates from
|
||||
@var{list} and returns the result. Of several @code{equal}
|
||||
occurrences of an element in @var{list}, @code{delete-dups} keeps the
|
||||
last one.
|
||||
|
||||
The value of @var{list} after a call to this function is undefined.
|
||||
Usually, we store the return value back in @var{list}:
|
||||
|
||||
@example
|
||||
(setq list (delete-dups list))
|
||||
@end example
|
||||
@end defun
|
||||
|
||||
See also the function @code{add-to-list}, in @ref{Setting Variables},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue