diff options
author | Luc Teirlinck <teirllm@auburn.edu> | 2004-01-20 23:06:28 +0000 |
---|---|---|
committer | Luc Teirlinck <teirllm@auburn.edu> | 2004-01-20 23:06:28 +0000 |
commit | 42101e875de1fa1388dd76a6f4f18054c16d24ef (patch) | |
tree | 875a5ad7b99b6aa738db3af78e940c5394a4897a /lispref/lists.texi | |
parent | 9fa0334c27652ebd66cb7e60a3020efab45f7503 (diff) |
(Sets And Lists): Add delete-dups.
Diffstat (limited to 'lispref/lists.texi')
-rw-r--r-- | lispref/lists.texi | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lispref/lists.texi b/lispref/lists.texi index b123de5ab1..cb03311898 100644 --- a/lispref/lists.texi +++ b/lispref/lists.texi @@ -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}. @@ -1433,6 +1434,20 @@ 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}, for another way to add an element to a list stored in a variable. |