emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/dash ce4a344 258/316: Eliminate odd? from examples


From: ELPA Syncer
Subject: [elpa] externals/dash ce4a344 258/316: Eliminate odd? from examples
Date: Mon, 15 Feb 2021 15:58:12 -0500 (EST)

branch: externals/dash
commit ce4a34422945ac65bd2600e13b8c18f21117e32d
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>

    Eliminate odd? from examples
    
    * dev/examples.el (odd?): Remove function.
    (-drop-while, -partition-after-pred, -partition-before-pred)
    (-each-while, -each-r-while): Replace odd? with built-in
    functions (#342).
    
    * README.md:
    * dash.texi: Regenerate docs.
---
 README.md       | 16 ++++++++--------
 dash.texi       | 28 ++++++++++++++--------------
 dev/examples.el | 29 ++++++++++++++---------------
 3 files changed, 36 insertions(+), 37 deletions(-)

diff --git a/README.md b/README.md
index 91e31bc..d355116 100644
--- a/README.md
+++ b/README.md
@@ -1509,9 +1509,9 @@ other value (the body).
 Partition directly after each time `pred` is true on an element of `list`.
 
 ```el
-(-partition-after-pred #'odd? '()) ;; => '()
-(-partition-after-pred #'odd? '(1)) ;; => '((1))
-(-partition-after-pred #'odd? '(0 1)) ;; => '((0 1))
+(-partition-after-pred #'booleanp '()) ;; => '()
+(-partition-after-pred #'booleanp '(t t)) ;; => '((t) (t))
+(-partition-after-pred #'booleanp '(0 0 t t 0 t)) ;; => '((0 0 t) (t) (0 t))
 ```
 
 #### -partition-before-pred `(pred list)`
@@ -1519,9 +1519,9 @@ Partition directly after each time `pred` is true on an 
element of `list`.
 Partition directly before each time `pred` is true on an element of `list`.
 
 ```el
-(-partition-before-pred #'odd? '()) ;; => '()
-(-partition-before-pred #'odd? '(1)) ;; => '((1))
-(-partition-before-pred #'odd? '(0 1)) ;; => '((0) (1))
+(-partition-before-pred #'booleanp '()) ;; => '()
+(-partition-before-pred #'booleanp '(0 t)) ;; => '((0) (t))
+(-partition-before-pred #'booleanp '(0 0 t 0 t t)) ;; => '((0 0) (t 0) (t) (t))
 ```
 
 #### -partition-before-item `(item list)`
@@ -2686,7 +2686,7 @@ Its anaphoric counterpart is `--each-while`.
 ```el
 (let (l) (-each-while '(2 4 5 6) #'even? (lambda (x) (push x l))) l) ;; => '(4 
2)
 (let (l) (--each-while '(1 2 3 4) (< it 3) (push it l)) l) ;; => '(2 1)
-(let ((s 0)) (--each-while '(1 3 4 5) (odd? it) (setq s (+ s it))) s) ;; => 4
+(let ((s 0)) (--each-while '(1 3 4 5) (< it 5) (setq s (+ s it))) s) ;; => 8
 ```
 
 #### -each-indexed `(list fn)`
@@ -2725,7 +2725,7 @@ Its anaphoric counterpart is `--each-r-while`.
 ```el
 (let (l) (-each-r-while '(2 4 5 6) #'even? (lambda (x) (push x l))) l) ;; => 
'(6)
 (let (l) (--each-r-while '(1 2 3 4) (>= it 3) (push it l)) l) ;; => '(3 4)
-(let ((s 0)) (--each-r-while '(1 2 3 5) (odd? it) (setq s (+ s it))) s) ;; => 8
+(let ((s 0)) (--each-r-while '(1 2 3 5) (> it 1) (setq s (+ s it))) s) ;; => 10
 ```
 
 #### -dotimes `(num fn)`
diff --git a/dash.texi b/dash.texi
index ba418e1..a37ab85 100644
--- a/dash.texi
+++ b/dash.texi
@@ -2188,16 +2188,16 @@ Partition directly after each time @var{pred} is true 
on an element of @var{list
 
 @example
 @group
-(-partition-after-pred #'odd? '())
+(-partition-after-pred #'booleanp '())
     @result{} '()
 @end group
 @group
-(-partition-after-pred #'odd? '(1))
-    @result{} '((1))
+(-partition-after-pred #'booleanp '(t t))
+    @result{} '((t) (t))
 @end group
 @group
-(-partition-after-pred #'odd? '(0 1))
-    @result{} '((0 1))
+(-partition-after-pred #'booleanp '(0 0 t t 0 t))
+    @result{} '((0 0 t) (t) (0 t))
 @end group
 @end example
 @end defun
@@ -2208,16 +2208,16 @@ Partition directly before each time @var{pred} is true 
on an element of @var{lis
 
 @example
 @group
-(-partition-before-pred #'odd? '())
+(-partition-before-pred #'booleanp '())
     @result{} '()
 @end group
 @group
-(-partition-before-pred #'odd? '(1))
-    @result{} '((1))
+(-partition-before-pred #'booleanp '(0 t))
+    @result{} '((0) (t))
 @end group
 @group
-(-partition-before-pred #'odd? '(0 1))
-    @result{} '((0) (1))
+(-partition-before-pred #'booleanp '(0 0 t 0 t t))
+    @result{} '((0 0) (t 0) (t) (t))
 @end group
 @end example
 @end defun
@@ -4059,8 +4059,8 @@ Its anaphoric counterpart is @code{--each-while}.
     @result{} '(2 1)
 @end group
 @group
-(let ((s 0)) (--each-while '(1 3 4 5) (odd? it) (setq s (+ s it))) s)
-    @result{} 4
+(let ((s 0)) (--each-while '(1 3 4 5) (< it 5) (setq s (+ s it))) s)
+    @result{} 8
 @end group
 @end example
 @end defun
@@ -4128,8 +4128,8 @@ Its anaphoric counterpart is @code{--each-r-while}.
     @result{} '(3 4)
 @end group
 @group
-(let ((s 0)) (--each-r-while '(1 2 3 5) (odd? it) (setq s (+ s it))) s)
-    @result{} 8
+(let ((s 0)) (--each-r-while '(1 2 3 5) (> it 1) (setq s (+ s it))) s)
+    @result{} 10
 @end group
 @end example
 @end defun
diff --git a/dev/examples.el b/dev/examples.el
index 76f4b20..56e95da 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -36,7 +36,6 @@
 
 ;; FIXME: These definitions ought to be exported along with the
 ;; examples, if they are going to be used there.
-(defun odd? (num) (= 1 (% num 2)))
 (defun even? (num) (= 0 (% num 2)))
 (defun square (num) (* num num))
 
@@ -291,7 +290,7 @@ new list."
     (--drop-while nil '(1 2)) => '(1 2)
     (--drop-while t '(1)) => ()
     (--drop-while t '(1 2)) => ()
-    (let ((l (list 1 2))) (setcar (-drop-while #'odd? l) 0) l) => '(1 0)
+    (let ((l (list t 2))) (setcar (-drop-while #'booleanp l) 0) l) => '(t 0)
     (let ((l (list 1 2))) (eq (--drop-while nil l) l)) => t)
 
   (defexamples -select-by-indices
@@ -761,19 +760,19 @@ value rather than consuming a list to produce a single 
value."
     (-partition-by-header 'even? '(2 1 1 1 4 1 3 5 6 6 1)) => '((2 1 1 1) (4 1 
3 5) (6 6 1)))
 
   (defexamples -partition-after-pred
-    (-partition-after-pred #'odd? '()) => '()
-    (-partition-after-pred #'odd? '(1)) => '((1))
-    (-partition-after-pred #'odd? '(0 1)) => '((0 1))
-    (-partition-after-pred #'odd? '(1 1)) => '((1) (1))
-    (-partition-after-pred #'odd? '(0 0 0 1 0 1 1 0 1)) => '((0 0 0 1) (0 1) 
(1) (0 1)))
+    (-partition-after-pred #'booleanp '()) => '()
+    (-partition-after-pred #'booleanp '(t t)) => '((t) (t))
+    (-partition-after-pred #'booleanp '(0 0 t t 0 t)) => '((0 0 t) (t) (0 t))
+    (-partition-after-pred #'booleanp '(t)) => '((t))
+    (-partition-after-pred #'booleanp '(0 t)) => '((0 t)))
 
   (defexamples -partition-before-pred
-    (-partition-before-pred #'odd? '()) => '()
-    (-partition-before-pred #'odd? '(1)) => '((1))
-    (-partition-before-pred #'odd? '(0 1)) => '((0) (1))
-    (-partition-before-pred #'odd? '(1 1)) => '((1) (1))
-    (-partition-before-pred #'odd? '(0 1 0)) => '((0) (1 0))
-    (-partition-before-pred #'odd? '(0 0 0 1 0 1 1 0 1)) => '((0 0 0) (1 0) 
(1) (1 0) (1)))
+    (-partition-before-pred #'booleanp '()) => '()
+    (-partition-before-pred #'booleanp '(0 t)) => '((0) (t))
+    (-partition-before-pred #'booleanp '(0 0 t 0 t t)) => '((0 0) (t 0) (t) 
(t))
+    (-partition-before-pred #'booleanp '(t)) => '((t))
+    (-partition-before-pred #'booleanp '(t t)) => '((t) (t))
+    (-partition-before-pred #'booleanp '(0 t 0)) => '((0) (t 0)))
 
   (defexamples -partition-before-item
     (-partition-before-item 3 '()) => '()
@@ -1525,7 +1524,7 @@ value rather than consuming a list to produce a single 
value."
   (defexamples -each-while
     (let (l) (-each-while '(2 4 5 6) #'even? (lambda (x) (push x l))) l) => 
'(4 2)
     (let (l) (--each-while '(1 2 3 4) (< it 3) (push it l)) l) => '(2 1)
-    (let ((s 0)) (--each-while '(1 3 4 5) (odd? it) (setq s (+ s it))) s) => 4
+    (let ((s 0)) (--each-while '(1 3 4 5) (< it 5) (setq s (+ s it))) s) => 8
     (let (s) (-each-while () (lambda (_) t) (lambda (_) (setq s t))) s) => nil
     (let (s) (--each-while () t (setq s t)) s) => nil
     (let (s) (--each-while '(1) t (setq s it)) s) => 1
@@ -1552,7 +1551,7 @@ value rather than consuming a list to produce a single 
value."
   (defexamples -each-r-while
     (let (l) (-each-r-while '(2 4 5 6) #'even? (lambda (x) (push x l))) l) => 
'(6)
     (let (l) (--each-r-while '(1 2 3 4) (>= it 3) (push it l)) l) => '(3 4)
-    (let ((s 0)) (--each-r-while '(1 2 3 5) (odd? it) (setq s (+ s it))) s) => 
8
+    (let ((s 0)) (--each-r-while '(1 2 3 5) (> it 1) (setq s (+ s it))) s) => 
10
     (let (s) (-each-r-while () (lambda (_) t) (lambda (_) (setq s t))) s) => 
nil
     (let (s) (--each-r-while () t (setq s t)) s) => nil
     (let (s) (--each-r-while '(1) t (setq s it)) s) => 1



reply via email to

[Prev in Thread] Current Thread [Next in Thread]