aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Teirlinck2004-01-20 23:06:28 +0000
committerLuc Teirlinck2004-01-20 23:06:28 +0000
commit42101e875de1fa1388dd76a6f4f18054c16d24ef (patch)
tree875a5ad7b99b6aa738db3af78e940c5394a4897a
parent9fa0334c27652ebd66cb7e60a3020efab45f7503 (diff)
downloademacs-42101e875de1fa1388dd76a6f4f18054c16d24ef.tar.gz
emacs-42101e875de1fa1388dd76a6f4f18054c16d24ef.zip
(Sets And Lists): Add delete-dups.
-rw-r--r--lispref/lists.texi17
1 files changed, 16 insertions, 1 deletions
diff --git a/lispref/lists.texi b/lispref/lists.texi
index b123de5ab10..cb033118984 100644
--- a/lispref/lists.texi
+++ b/lispref/lists.texi
@@ -1223,7 +1223,8 @@ useful example of @code{sort}.
1223 A list can represent an unordered mathematical set---simply consider a 1223 A list can represent an unordered mathematical set---simply consider a
1224value an element of a set if it appears in the list, and ignore the 1224value an element of a set if it appears in the list, and ignore the
1225order of the list. To form the union of two sets, use @code{append} (as 1225order of the list. To form the union of two sets, use @code{append} (as
1226long as you don't mind having duplicate elements). Other useful 1226long as you don't mind having duplicate elements). You can remove
1227@code{equal} duplicates using @code{delete-dups}. Other useful
1227functions for sets include @code{memq} and @code{delq}, and their 1228functions for sets include @code{memq} and @code{delq}, and their
1228@code{equal} versions, @code{member} and @code{delete}. 1229@code{equal} versions, @code{member} and @code{delete}.
1229 1230
@@ -1433,6 +1434,20 @@ equal, and unibyte strings are converted to multibyte prior to
1433comparison. 1434comparison.
1434@end defun 1435@end defun
1435 1436
1437@defun delete-dups list
1438This function destructively removes all @code{equal} duplicates from
1439@var{list} and returns the result. Of several @code{equal}
1440occurrences of an element in @var{list}, @code{delete-dups} keeps the
1441last one.
1442
1443The value of @var{list} after a call to this function is undefined.
1444Usually, we store the return value back in @var{list}:
1445
1446@example
1447(setq list (delete-dups list))
1448@end example
1449@end defun
1450
1436 See also the function @code{add-to-list}, in @ref{Setting Variables}, 1451 See also the function @code{add-to-list}, in @ref{Setting Variables},
1437for another way to add an element to a list stored in a variable. 1452for another way to add an element to a list stored in a variable.
1438 1453