[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash cf7ca23 415/426: [Fix #97] Add -remove-item
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash cf7ca23 415/426: [Fix #97] Add -remove-item |
Date: |
Tue, 04 Aug 2015 19:39:19 +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 c08fcba 299/426: Fixed documentation of `-last-item'., (continued)
- [elpa] externals/dash c08fcba 299/426: Fixed documentation of `-last-item'., Phillip Lord, 2015/08/04
- [elpa] externals/dash f96196a 289/426: Merge pull request #75 from Fuco1/prefix, Phillip Lord, 2015/08/04
- [elpa] externals/dash afe2781 388/426: Merge pull request #109 from bbatsov/threading-indentation, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6b64ea7 303/426: Add functions for flexibly zipping uneven lists, Phillip Lord, 2015/08/04
- [elpa] externals/dash cd137e0 310/426: `-slice` should not fill the returned list with nils if to > length, Phillip Lord, 2015/08/04
- [elpa] externals/dash 5219ac0 422/426: [-let] Eliminate useless re-binding of symbols when sources are immutable, Phillip Lord, 2015/08/04
- [elpa] externals/dash a06e66e 382/426: Add test for clean byte compilation, Phillip Lord, 2015/08/04
- [elpa] externals/dash 43dcd37 295/426: Only eval NUM in --dotimes once, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4ecfea6 296/426: Merge pull request #79 from Fuco1/debug-forms, Phillip Lord, 2015/08/04
- [elpa] externals/dash 624c501 306/426: Add `-table` and `-table-flat`, Phillip Lord, 2015/08/04
- [elpa] externals/dash cf7ca23 415/426: [Fix #97] Add -remove-item,
Phillip Lord <=
- [elpa] externals/dash 2eefbec 386/426: Don't use an inline comment on a line of its own, Phillip Lord, 2015/08/04
- [elpa] externals/dash bbc1d9c 309/426: `--each-while` should also expose `it-index`, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6bdcfa5 286/426: Add -split-on, -split-when, Phillip Lord, 2015/08/04
- [elpa] externals/dash bd85b7c 302/426: Make -zip support infinite (circular) lists, Phillip Lord, 2015/08/04
- [elpa] externals/dash 19fbc24 426/426: Fix anaphoric -spice-list macro, Phillip Lord, 2015/08/04
- [elpa] externals/dash 36b7f49 419/426: [-let] Reuse the ignore-place predicate, Phillip Lord, 2015/08/04
- [elpa] externals/dash 703bb59 297/426: Convert -zip to support variable-length arguments, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3132ae0 314/426: Alias -tail to nthcdr, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4098ea0 285/426: Merge pull request #74 from YoungFrog/dashfontifix, Phillip Lord, 2015/08/04
- [elpa] externals/dash 0c045f2 369/426: Highlight with el instead of cl, Phillip Lord, 2015/08/04