[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))
- [elpa] externals/dash 1d4881f 413/439: Update README, (continued)
- [elpa] externals/dash 1d4881f 413/439: Update README, Phillip Lord, 2015/08/04
- [elpa] externals/dash 36b7f49 419/439: [-let] Reuse the ignore-place predicate, Phillip Lord, 2015/08/04
- [elpa] externals/dash b308794 416/439: [Fix #73] Add a mention of -filter to -keep docstring, Phillip Lord, 2015/08/04
- [elpa] externals/dash 51a07b1 408/439: Merge pull request #127 from occidens/fixfn, Phillip Lord, 2015/08/04
- [elpa] externals/dash 8530742 410/439: Add @wasamasa and @occidens to list of contributors, Phillip Lord, 2015/08/04
- [elpa] externals/dash db784f8 403/439: Merge pull request #124 from occidens/skiptests, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9ebd172 421/439: [-let] Generate differently named symbols for temporary sources (makes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7d7a457 402/439: Allow run-tests.sh to skip tests, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3a3f528 396/439: Add info manual, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4bd6273 397/439: Invoke makeinfo on the generated .texi, Phillip Lord, 2015/08/04
- [elpa] externals/dash cf7ca23 415/439: [Fix #97] Add -remove-item,
Phillip Lord <=
- [elpa] externals/dash 90056bd 401/439: Merge pull request #121 from holomorph/master, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3992e3c 406/439: Make `-fixfn' more robust at handling floats, Phillip Lord, 2015/08/04
- [elpa] externals/dash 1fde888 407/439: Merge pull request #125 from wasamasa/feature-some, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2cc124b 423/439: [-let] Generate better code when skipping conses, Phillip Lord, 2015/08/04
- [elpa] externals/dash c61fc34 417/439: Add -remove-first/last, -map-first/last, -replace-first/last, Phillip Lord, 2015/08/04
- [elpa] externals/dash 40896b8 418/439: Fix the -let debug declaration, Phillip Lord, 2015/08/04