[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 994cda9 228/316: Simplify -cons-pair?
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash 994cda9 228/316: Simplify -cons-pair? |
Date: |
Mon, 15 Feb 2021 15:58:06 -0500 (EST) |
branch: externals/dash
commit 994cda98cab17677baad3358841afe8d22fbdae9
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Simplify -cons-pair?
* dash.el (-cons-pair?): Simplify for speed.
* dev/examples.el (-cons-pair?): New test.
* README.md:
* dash.texi: Regenerate docs.
---
README.md | 13 +++++++++++++
dash.el | 12 +++++-------
dash.texi | 22 ++++++++++++++++++++++
dev/examples.el | 11 ++++++++++-
4 files changed, 50 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 0b29a8c..7562956 100644
--- a/README.md
+++ b/README.md
@@ -210,6 +210,7 @@ value rather than consuming a list to produce a single
value.
* [-is-prefix?](#-is-prefix-prefix-list) `(prefix list)`
* [-is-suffix?](#-is-suffix-suffix-list) `(suffix list)`
* [-is-infix?](#-is-infix-infix-list) `(infix list)`
+* [-cons-pair?](#-cons-pair-obj) `(obj)`
### Partitioning
@@ -1345,6 +1346,18 @@ Alias: `-is-infix-p`
(-is-infix? '(3 4 5) '(1 2 3 4 5)) ;; => t
```
+#### -cons-pair? `(obj)`
+
+Return non-nil if `obj` is a true cons pair.
+That is, a cons (`a` . `b`) where `b` is not a list.
+Alias: `-cons-pair-p`.
+
+```el
+(-cons-pair? '(1 . 2)) ;; => t
+(-cons-pair? '(1 2)) ;; => nil
+(-cons-pair? '(1)) ;; => nil
+```
+
## Partitioning
diff --git a/dash.el b/dash.el
index f249f5b..0097b42 100644
--- a/dash.el
+++ b/dash.el
@@ -2724,14 +2724,12 @@ the new seed."
(declare (debug (form form)))
`(-unfold (lambda (it) ,form) ,seed))
-(defun -cons-pair? (con)
- "Return non-nil if CON is true cons pair.
-That is (A . B) where B is not a list.
-
-Alias: `-cons-pair-p'"
+(defun -cons-pair? (obj)
+ "Return non-nil if OBJ is a true cons pair.
+That is, a cons (A . B) where B is not a list.
+Alias: `-cons-pair-p'."
(declare (pure t) (side-effect-free t))
- (and (listp con)
- (not (listp (cdr con)))))
+ (nlistp (cdr-safe obj)))
(defalias '-cons-pair-p '-cons-pair?)
diff --git a/dash.texi b/dash.texi
index 175035e..1b0addf 100644
--- a/dash.texi
+++ b/dash.texi
@@ -1903,6 +1903,28 @@ Alias: @code{-is-infix-p}
@end example
@end defun
+@anchor{-cons-pair?}
+@defun -cons-pair? (obj)
+Return non-nil if @var{obj} is a true cons pair.
+That is, a cons (@var{a} . @var{b}) where @var{b} is not a list.
+Alias: @code{-cons-pair-p}.
+
+@example
+@group
+(-cons-pair? '(1 . 2))
+ @result{} t
+@end group
+@group
+(-cons-pair? '(1 2))
+ @result{} nil
+@end group
+@group
+(-cons-pair? '(1))
+ @result{} nil
+@end group
+@end example
+@end defun
+
@node Partitioning
@section Partitioning
diff --git a/dev/examples.el b/dev/examples.el
index fb2d896..575684d 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -618,7 +618,16 @@ value rather than consuming a list to produce a single
value."
(-is-infix? '(2 3 4) '(1 2 3 4 5)) => t
(-is-infix? '(3 4 5) '(1 2 3 4 5)) => t
(-is-infix? '(2 3 4) '(1 2 4 5)) => nil
- (-is-infix? '(2 4) '(1 2 3 4 5)) => nil))
+ (-is-infix? '(2 4) '(1 2 3 4 5)) => nil)
+
+ (defexamples -cons-pair?
+ (-cons-pair? '(1 . 2)) => t
+ (-cons-pair? '(1 2)) => nil
+ (-cons-pair? '(1)) => nil
+ (-cons-pair? ()) => nil
+ (-cons-pair? "") => nil
+ (-cons-pair? '(1 2 . 3)) => nil
+ (-cons-pair? '(() . "")) => t))
(def-example-group "Partitioning"
"Functions partitioning the input list into a list of lists."
- [elpa] externals/dash b3c58ff 221/316: Fix docstring of -list, (continued)
- [elpa] externals/dash b3c58ff 221/316: Fix docstring of -list, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 26f065f 129/316: Merge pull request #282 from yyoncho/anamorphic-doto, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 4abffdc 123/316: Update docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 677c156 134/316: Merge pull request #290 from leungbk/rotate, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 1549860 139/316: Merge pull request #296 from cireu/fix-hash-opt-expander, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 93e0465 137/316: Remove dependecy `macroexp`, ELPA Syncer, 2021/02/15
- [elpa] externals/dash a358b79 143/316: Speed up `-uniq` with hash-table., ELPA Syncer, 2021/02/15
- [elpa] externals/dash 77f3bf4 142/316: Merge pull request #302 from bbatsov/patch-1, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 38dc929 222/316: Fix, improve, and extend anaphoric folds, ELPA Syncer, 2021/02/15
- [elpa] externals/dash d308676 225/316: Fix signal argument and case where start is null, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 994cda9 228/316: Simplify -cons-pair?,
ELPA Syncer <=
- [elpa] externals/dash 11907f4 145/316: Speed up `-uniq` with hash-table. (#305), ELPA Syncer, 2021/02/15
- [elpa] externals/dash ad21e13 146/316: Ignore all .elc and TAGS files, ELPA Syncer, 2021/02/15
- [elpa] externals/dash fae51b5 147/316: Make -inits not destroy its argument, ELPA Syncer, 2021/02/15
- [elpa] externals/dash ce1294b 152/316: Optimize non-destructive -inits, ELPA Syncer, 2021/02/15
- [elpa] externals/dash a743ae3 153/316: Merge pull request #313 from SwiftLawnGnome/master, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 62707a6 154/316: Avoid interning unused symbols in destructuring, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 9631947 155/316: Merge pull request #317 from cireu/feat/intern-soft, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0ee27a4 157/316: Clarify docs on -zip-pair future behaviour, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 5f65fdf 159/316: Merge pull request #321 from wbolster/some-macro-indentation, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 13e5366 161/316: Merge pull request #323 from tarsiiformes/typos, ELPA Syncer, 2021/02/15