[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 82a12a2 076/426: Add !drop-while
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 82a12a2 076/426: Add !drop-while |
Date: |
Tue, 04 Aug 2015 19:36:49 +0000 |
branch: externals/dash
commit 82a12a251f312810f008cacc5a254b332b91e7cf
Author: Magnar Sveen <address@hidden>
Commit: Magnar Sveen <address@hidden>
Add !drop-while
---
README.md | 11 +++++++++++
bang.el | 12 ++++++++++++
examples.el | 5 +++++
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
index 15da0c9..0370383 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,7 @@ Or you can just dump `bang.el` in your load path somewhere.
* [!concat](#concat-rest-lists) `(&rest lists)`
* [!mapcat](#mapcat-fn-list) `(fn list)`
* [!take-while](#take-while-fn-list) `(fn list)`
+* [!drop-while](#drop-while-fn-list) `(fn list)`
* [!interpose](#interpose-sep-list) `(sep list)`
* [!replace-where](#replace-where-pred-rep-list) `(pred rep list)`
* [!first](#first-fn-list) `(fn list)`
@@ -173,6 +174,16 @@ Returns a new list of successive items from `list` while
(`fn` item) returns a n
(!!take-while (< it 4) '(1 2 3 4 3 2 1)) ;; => '(1 2 3)
```
+### !drop-while `(fn list)`
+
+Returns the tail of `list` starting from the first item for which (`fn` item)
returns nil.
+
+```cl
+(!drop-while 'even? '(1 2 3 4)) ;; => '(1 2 3 4)
+(!drop-while 'even? '(2 4 5 6)) ;; => '(5 6)
+(!!drop-while (< it 4) '(1 2 3 4 3 2 1)) ;; => '(4 3 2 1)
+```
+
### !interpose `(sep list)`
Returns a new list of all elements in `list` separated by `sep`.
diff --git a/bang.el b/bang.el
index 4fc290f..0cd4c0f 100644
--- a/bang.el
+++ b/bang.el
@@ -159,6 +159,18 @@ Thus function FN should return a collection."
"Returns a new list of successive items from LIST while (FN item) returns a
non-nil value."
(!!take-while (funcall fn it) list))
+(defmacro !!drop-while (form list)
+ "Anaphoric form of `!drop-while'."
+ (let ((l (make-symbol "list")))
+ `(let ((,l ,list))
+ (while (and ,l (let ((it (car ,l))) ,form))
+ (setq ,l (cdr ,l)))
+ ,l)))
+
+(defun !drop-while (fn list)
+ "Returns the tail of LIST starting from the first item for which (FN item)
returns nil."
+ (!!drop-while (funcall fn it) list))
+
(defun !interpose (sep list)
"Returns a new list of all elements in LIST separated by SEP."
(let (result)
diff --git a/examples.el b/examples.el
index 32f9221..c2578b3 100644
--- a/examples.el
+++ b/examples.el
@@ -63,6 +63,11 @@
(!take-while 'even? '(2 4 5 6)) => '(2 4)
(!!take-while (< it 4) '(1 2 3 4 3 2 1)) => '(1 2 3))
+(defexamples !drop-while
+ (!drop-while 'even? '(1 2 3 4)) => '(1 2 3 4)
+ (!drop-while 'even? '(2 4 5 6)) => '(5 6)
+ (!!drop-while (< it 4) '(1 2 3 4 3 2 1)) => '(4 3 2 1))
+
(defexamples !interpose
(!interpose "-" '()) => '()
(!interpose "-" '("a")) => '("a")
- [elpa] externals/dash ec6a85f 074/426: Add threading macro !!-> with `it` as placeholder., (continued)
- [elpa] externals/dash ec6a85f 074/426: Add threading macro !!-> with `it` as placeholder., Phillip Lord, 2015/08/04
- [elpa] externals/dash 6238f8f 077/426: Add !split-with, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4e76865 075/426: Add !take-while, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3802890 082/426: Simplify !concat, Phillip Lord, 2015/08/04
- [elpa] externals/dash ec835e4 081/426: Add !split-at, Phillip Lord, 2015/08/04
- [elpa] externals/dash 0dab44c 084/426: Add -flatten, Phillip Lord, 2015/08/04
- [elpa] externals/dash 047eeea 066/426: Run tests on Emacs 24., Phillip Lord, 2015/08/04
- [elpa] externals/dash 9410f7e 073/426: Add !replace-where, Phillip Lord, 2015/08/04
- [elpa] externals/dash 123eaaa 078/426: Docs: Refer to !replace-where from !!replace-where., Phillip Lord, 2015/08/04
- [elpa] externals/dash 70488c2 063/426: Add !rpartial, Phillip Lord, 2015/08/04
- [elpa] externals/dash 82a12a2 076/426: Add !drop-while,
Phillip Lord <=
- [elpa] externals/dash fea1aa3 086/426: Add -interleave, Phillip Lord, 2015/08/04
- [elpa] externals/dash 38cc9e7 088/426: Simplify -interleave with -none?, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9ff9fd0 085/426: Move functions that are not strictly list related last., Phillip Lord, 2015/08/04
- [elpa] externals/dash 0c55a4b 090/426: 1.0.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4b5e24b 087/426: Docs: move -any? -all? -none? and -each up., Phillip Lord, 2015/08/04
- [elpa] externals/dash f8d74ff 091/426: Docs: update example text to match example code., Phillip Lord, 2015/08/04
- [elpa] externals/dash eacb6f2 092/426: Docs: Better generation of github urls., Phillip Lord, 2015/08/04
- [elpa] externals/dash 8c75026 080/426: Add !drop, Phillip Lord, 2015/08/04
- [elpa] externals/dash a2941cd 097/426: Typo, Phillip Lord, 2015/08/04
- [elpa] externals/dash b9b6330 079/426: Add !take, Phillip Lord, 2015/08/04