emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/dash cf7ca23 415/439: [Fix #97] Add -remove-item


From: Phillip Lord
Subject: [elpa] externals/dash cf7ca23 415/439: [Fix #97] Add -remove-item
Date: Tue, 04 Aug 2015 20:31:31 +0000

branch: externals/dash
commit cf7ca2317a0005948cef4b1eb8db89a5976105e3
Author: Matus Goljer <address@hidden>
Commit: Matus Goljer <address@hidden>

    [Fix #97] Add -remove-item
---
 README.md       |   13 +++++++++++++
 dash.el         |    7 +++++++
 dash.texi       |   22 ++++++++++++++++++++++
 dev/examples.el |    9 +++++++--
 4 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 325850a..50fcfae 100644
--- a/README.md
+++ b/README.md
@@ -59,6 +59,7 @@ Functions returning a sublist of the original list.
 
 * [-filter](#-filter-pred-list) `(pred list)`
 * [-remove](#-remove-pred-list) `(pred list)`
+* [-remove-item](#-remove-item-item-list) `(item list)`
 * [-non-nil](#-non-nil-list) `(list)`
 * [-slice](#-slice-list-from-optional-to-step) `(list from &optional to step)`
 * [-take](#-take-n-list) `(n list)`
@@ -418,6 +419,18 @@ Alias: `-reject`
 (--remove (= 0 (% it 2)) '(1 2 3 4)) ;; => '(1 3)
 ```
 
+#### -remove-item `(item list)`
+
+Remove all occurences of `item` from `list`.
+
+Comparison is done with `equal`.
+
+```el
+(-remove-item 3 '(1 2 3 2 3 4 5 3)) ;; => '(1 2 2 4 5)
+(-remove-item 'foo '(foo bar baz foo)) ;; => '(bar baz)
+(-remove-item "bob" '("alice" "bob" "eve" "bob" "dave")) ;; => '("alice" "eve" 
"dave")
+```
+
 #### -non-nil `(list)`
 
 Return all non-nil elements of `list`.
diff --git a/dash.el b/dash.el
index d3721e3..1029ef2 100644
--- a/dash.el
+++ b/dash.el
@@ -226,6 +226,12 @@ Alias: `-reject'"
 (defalias '-reject '-remove)
 (defalias '--reject '--remove)
 
+(defun -remove-item (item list)
+  "Remove all occurences of ITEM from LIST.
+
+Comparison is done with `equal'."
+  (--remove (equal it item) list))
+
 (defmacro --keep (form list)
   "Anaphoric form of `-keep'."
   (declare (debug (form form)))
@@ -1983,6 +1989,7 @@ structure such as plist or alist."
                              "--remove"
                              "-reject"
                              "--reject"
+                             "-remove-item"
                              "-non-nil"
                              "-keep"
                              "--keep"
diff --git a/dash.texi b/dash.texi
index 656acaf..7fd4a5c 100644
--- a/dash.texi
+++ b/dash.texi
@@ -424,6 +424,28 @@ Alias: @code{-reject}
 @end example
 @end defun
 
address@hidden
address@hidden -remove-item (item list)
+Remove all occurences of @var{item} from @var{list}.
+
+Comparison is done with @code{equal}.
+
address@hidden
address@hidden
+(-remove-item 3 '(1 2 3 2 3 4 5 3))
+    @result{} '(1 2 2 4 5)
address@hidden group
address@hidden
+(-remove-item 'foo '(foo bar baz foo))
+    @result{} '(bar baz)
address@hidden group
address@hidden
+(-remove-item "bob" '("alice" "bob" "eve" "bob" "dave"))
+    @result{} '("alice" "eve" "dave")
address@hidden group
address@hidden example
address@hidden defun
+
 @anchor{-non-nil}
 @defun -non-nil (list)
 Return all non-nil elements of @var{list}.
diff --git a/dev/examples.el b/dev/examples.el
index 1cd9436..eeab347 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -17,8 +17,8 @@
 (defun approx-equal (u v)
   (or (= u v)
       (< (/ (abs (- u v))
-           (max (abs u) (abs v)))
-        epsilon)))
+        (max (abs u) (abs v)))
+     epsilon)))
 
 (def-example-group "Maps"
   "Functions in this category take a transforming function, which
@@ -80,6 +80,11 @@ new list."
     (let ((mod 2)) (-remove (lambda (num) (= 0 (% num mod))) '(1 2 3 4))) => 
'(1 3)
     (let ((mod 2)) (--remove (= 0 (% it mod)) '(1 2 3 4))) => '(1 3))
 
+  (defexamples -remove-item
+    (-remove-item 3 '(1 2 3 2 3 4 5 3)) => '(1 2 2 4 5)
+    (-remove-item 'foo '(foo bar baz foo)) => '(bar baz)
+    (-remove-item "bob" '("alice" "bob" "eve" "bob" "dave")) => '("alice" 
"eve" "dave"))
+
   (defexamples -non-nil
     (-non-nil '(1 nil 2 nil nil 3 4 nil 5 nil)) => '(1 2 3 4 5))
 



reply via email to

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