[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 0e5acda 260/316: Simplify -non-nil
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash 0e5acda 260/316: Simplify -non-nil |
Date: |
Mon, 15 Feb 2021 15:58:13 -0500 (EST) |
branch: externals/dash
commit 0e5acda7a5a6034d3eb0bd42ca17206dff51964b
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Simplify -non-nil
* dash.el (-non-nil): Use --filter for speed.
* dev/examples.el (-non-nil): Extend tests.
* README.md:
* dash.texi: Regenerate docs.
---
README.md | 6 ++++--
dash.el | 4 ++--
dash.texi | 12 ++++++++++--
dev/examples.el | 7 ++++++-
4 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 135bc88..036cbcd 100644
--- a/README.md
+++ b/README.md
@@ -586,10 +586,12 @@ The comparison is done with `equal`.
#### -non-nil `(list)`
-Return all non-nil elements of `list`.
+Return a copy of `list` with all nil items removed.
```el
-(-non-nil '(1 nil 2 nil nil 3 4 nil 5 nil)) ;; => '(1 2 3 4 5)
+(-non-nil '(nil 1 nil 2 nil nil 3 4 nil 5 nil)) ;; => '(1 2 3 4 5)
+(-non-nil '((nil))) ;; => '((nil))
+(-non-nil '()) ;; => '()
```
#### -slice `(list from &optional to step)`
diff --git a/dash.el b/dash.el
index 449b53a..a800a1d 100644
--- a/dash.el
+++ b/dash.el
@@ -530,9 +530,9 @@ If you want to select the original items satisfying a
predicate use `-filter'."
(--keep (funcall fn it) list))
(defun -non-nil (list)
- "Return all non-nil elements of LIST."
+ "Return a copy of LIST with all nil items removed."
(declare (pure t) (side-effect-free t))
- (-remove 'null list))
+ (--filter it list))
(defmacro --map-indexed (form list)
"Anaphoric form of `-map-indexed'."
diff --git a/dash.texi b/dash.texi
index e55522b..1d2ac44 100644
--- a/dash.texi
+++ b/dash.texi
@@ -603,13 +603,21 @@ The comparison is done with @code{equal}.
@anchor{-non-nil}
@defun -non-nil (list)
-Return all non-nil elements of @var{list}.
+Return a copy of @var{list} with all nil items removed.
@example
@group
-(-non-nil '(1 nil 2 nil nil 3 4 nil 5 nil))
+(-non-nil '(nil 1 nil 2 nil nil 3 4 nil 5 nil))
@result{} '(1 2 3 4 5)
@end group
+@group
+(-non-nil '((nil)))
+ @result{} '((nil))
+@end group
+@group
+(-non-nil '())
+ @result{} '()
+@end group
@end example
@end defun
diff --git a/dev/examples.el b/dev/examples.el
index ebe616b..eb813f3 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -209,7 +209,12 @@ new list."
(let ((l (list 1 2))) (setcar (-remove-item 2 l) 0) l) => '(1 2))
(defexamples -non-nil
- (-non-nil '(1 nil 2 nil nil 3 4 nil 5 nil)) => '(1 2 3 4 5))
+ (-non-nil '(nil 1 nil 2 nil nil 3 4 nil 5 nil)) => '(1 2 3 4 5)
+ (-non-nil '((()))) => '((()))
+ (-non-nil '()) => '()
+ (let ((l (list 1 2))) (setcar (-non-nil l) 0) l) => '(1 2)
+ (let ((l (list nil 1))) (setcar (-non-nil l) 0) l) => '(nil 1)
+ (let ((l (list 1 nil))) (setcar (-non-nil l) 0) l) => '(1 nil))
(defexamples -slice
(-slice '(1 2 3 4 5) 1) => '(2 3 4 5)
- [elpa] externals/dash ca36c57 239/316: Allow -lambda with no arguments, (continued)
- [elpa] externals/dash ca36c57 239/316: Allow -lambda with no arguments, ELPA Syncer, 2021/02/15
- [elpa] externals/dash bf8a462 243/316: Partially revert last change, ELPA Syncer, 2021/02/15
- [elpa] externals/dash d7d0acb 242/316: Don't call eval, ELPA Syncer, 2021/02/15
- [elpa] externals/dash bf8d876 238/316: Merge pull request #363 from blc/list, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 76ace7f 240/316: Fix error signaling, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 1ccf08d 244/316: ; Fix last change, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 2625bc5 247/316: Don't use insert-file-contents-literally, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 7583e65 248/316: Revert --map to using mapcar, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 6f5888c 251/316: Extend --filter and --remove docs and tests, ELPA Syncer, 2021/02/15
- [elpa] externals/dash db45ee7 252/316: Optimize -remove-first a bit, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0e5acda 260/316: Simplify -non-nil,
ELPA Syncer <=
- [elpa] externals/dash 9ad0d2b 266/316: Extend -map-indexed docs and tests, ELPA Syncer, 2021/02/15
- [elpa] externals/dash f61769d 256/316: * dash.el (dash--keywords): Prefer rx., ELPA Syncer, 2021/02/15
- [elpa] externals/dash 2aeb4e4 264/316: Use actual advertised function signature in README, ELPA Syncer, 2021/02/15
- [elpa] externals/dash a536770 267/316: Prefer relative image links in README, ELPA Syncer, 2021/02/15
- [elpa] externals/dash ce4a344 258/316: Eliminate odd? from examples, ELPA Syncer, 2021/02/15
- [elpa] externals/dash f3ae7bb 259/316: Alias -remove-item to remove, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 525ede2 265/316: Improve docstring Markdown formatting, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 4a32a5d 257/316: Write -remove-last in terms of --remove-last, ELPA Syncer, 2021/02/15
- [elpa] externals/dash cbd3b29 268/316: * .elpaignore: Exclude dev/ from GNU ELPA tarball., ELPA Syncer, 2021/02/15
- [elpa] externals/dash 2a10547 271/316: Fix handling nils of -some-->, ELPA Syncer, 2021/02/15