[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 3adad97 334/426: Add -non-nil
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash 3adad97 334/426: Add -non-nil |
Date: |
Tue, 04 Aug 2015 19:38:41 +0000 |
branch: externals/dash
commit 3adad97d371be9a875f48f8d926c437a7d6c7f6b
Author: Matus Goljer <address@hidden>
Commit: Matus Goljer <address@hidden>
Add -non-nil
---
README.md | 9 +++++++++
dash.el | 5 +++++
dev/examples.el | 3 +++
3 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/README.md b/README.md
index 2e58b9d..d30cd76 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)`
+* [-non-nil](#-non-nil-list) `(list)`
* [-slice](#-slice-list-from-optional-to-step) `(list from &optional to step)`
* [-take](#-take-n-list) `(n list)`
* [-drop](#-drop-n-list) `(n list)`
@@ -411,6 +412,14 @@ Alias: `-reject`
(--remove (= 0 (% it 2)) '(1 2 3 4)) ;; => '(1 3)
```
+#### -non-nil `(list)`
+
+Return all non-nil elements of `list`.
+
+```cl
+(-non-nil '(1 nil 2 nil nil 3 4 nil 5 nil)) ;; => '(1 2 3 4 5)
+```
+
#### -slice `(list from &optional to step)`
Return copy of `list`, starting from index `from` to index `to`.
diff --git a/dash.el b/dash.el
index 43e0349..76a8e75 100644
--- a/dash.el
+++ b/dash.el
@@ -239,6 +239,10 @@ Alias: `-reject'"
"Return a new list of the non-nil results of applying FN to the items in
LIST."
(--keep (funcall fn it) list))
+(defun -non-nil (list)
+ "Return all non-nil elements of LIST."
+ (-remove 'null list))
+
(defmacro --map-indexed (form list)
"Anaphoric form of `-map-indexed'."
(declare (debug (form form)))
@@ -1579,6 +1583,7 @@ structure such as plist or alist."
"--remove"
"-reject"
"--reject"
+ "-non-nil"
"-keep"
"--keep"
"-map-indexed"
diff --git a/dev/examples.el b/dev/examples.el
index fba6639..5e1197d 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -69,6 +69,9 @@ 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 -non-nil
+ (-non-nil '(1 nil 2 nil nil 3 4 nil 5 nil)) => '(1 2 3 4 5))
+
(defexamples -slice
(-slice '(1 2 3 4 5) 1) => '(2 3 4 5)
(-slice '(1 2 3 4 5) 0 3) => '(1 2 3)
- [elpa] externals/dash 7e4adb5 319/426: Add missing keywords to highlight list, (continued)
- [elpa] externals/dash 7e4adb5 319/426: Add missing keywords to highlight list, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2ecc073 316/426: Reorder the partition examples to follow more logical order, add tests, Phillip Lord, 2015/08/04
- [elpa] externals/dash eea928a 320/426: Add -replace, Phillip Lord, 2015/08/04
- [elpa] externals/dash d9879e9 329/426: Release 2.8.0, Phillip Lord, 2015/08/04
- [elpa] externals/dash f8873a0 327/426: Update readme-template with changes from last release, Phillip Lord, 2015/08/04
- [elpa] externals/dash 25c114c 330/426: Implementing a shallow copy counterpart to -clone., Phillip Lord, 2015/08/04
- [elpa] externals/dash f257fb9 328/426: Add -butlast, Phillip Lord, 2015/08/04
- [elpa] externals/dash 174747e 323/426: Add -splice and -splice-list, Phillip Lord, 2015/08/04
- [elpa] externals/dash ab99be6 335/426: Add -fix, Phillip Lord, 2015/08/04
- [elpa] externals/dash b1e585d 337/426: Update copyright notice, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3adad97 334/426: Add -non-nil,
Phillip Lord <=
- [elpa] externals/dash 166bccd 333/426: Add -tree-map-nodes, Phillip Lord, 2015/08/04
- [elpa] externals/dash 05fa92f 342/426: [-let] Transpose nreverse/flatten, Phillip Lord, 2015/08/04
- [elpa] externals/dash f0831d3 339/426: Add -lambda, Phillip Lord, 2015/08/04
- [elpa] externals/dash 9ebcce6 325/426: Add some niceties to font-locking of examples, Phillip Lord, 2015/08/04
- [elpa] externals/dash 6fc652d 331/426: Merge pull request #95 from Wilfred/shallow-copy-function, Phillip Lord, 2015/08/04
- [elpa] externals/dash 5637bd6 322/426: Add alias from -find to -first, Phillip Lord, 2015/08/04
- [elpa] externals/dash a4be872 338/426: Add `-let` and `-let*`, Phillip Lord, 2015/08/04
- [elpa] externals/dash 947ffda 341/426: Add support for &rest match for non-list sequences (like . for improper lists), Phillip Lord, 2015/08/04
- [elpa] externals/dash 9065e1b 344/426: [-let] Final cdr shift optimization, Phillip Lord, 2015/08/04
- [elpa] externals/dash d37947a 332/426: Add -tree-seq, Phillip Lord, 2015/08/04