emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r105093: Add a new, simple definition


From: Lars Magne Ingebrigtsen
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105093: Add a new, simple definition of `remove-duplicates'
Date: Mon, 11 Jul 2011 15:33:05 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105093
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Mon 2011-07-11 15:33:05 +0200
message:
  Add a new, simple definition of `remove-duplicates'
modified:
  lisp/ChangeLog
  lisp/subr.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-07-10 14:09:05 +0000
+++ b/lisp/ChangeLog    2011-07-11 13:33:05 +0000
@@ -1,3 +1,7 @@
+2011-07-11  Lars Magne Ingebrigtsen  <address@hidden>
+
+       * subr.el (remove-duplicates): New conveniency function.
+
 2011-07-10  Lars Magne Ingebrigtsen  <address@hidden>
 
        * tool-bar.el (tool-bar-mode): Clarify positive/negative arguments

=== modified file 'lisp/subr.el'
--- a/lisp/subr.el      2011-07-09 00:50:01 +0000
+++ b/lisp/subr.el      2011-07-11 13:33:05 +0000
@@ -173,7 +173,7 @@
     (progn
   ;; If we reload subr.el after having loaded CL, be careful not to
   ;; overwrite CL's extended definition of `dolist', `dotimes',
-  ;; `declare', `push' and `pop'.
+  ;; `declare', `push', `pop' and `remove-duplicates'.
 
 (defmacro dolist (spec &rest body)
   "Loop over a list.
@@ -250,6 +250,15 @@
 Treated as a declaration when used at the right place in a
 `defmacro' form.  \(See Info anchor `(elisp)Definition of declare'.)"
   nil)
+
+(defun remove-duplicates (list)
+  "Return a copy of LIST with all duplicate elements removed."
+  (let ((result nil))
+    (while list
+      (unless (member (car list) result)
+       (push (car list) result))
+      (pop list))
+    (nreverse result)))
 ))
 
 (defmacro ignore-errors (&rest body)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]