[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 55d8cc9 088/316: Running sum and product can only
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash 55d8cc9 088/316: Running sum and product can only be computed from non-empty lists |
Date: |
Mon, 15 Feb 2021 15:57:32 -0500 (EST) |
branch: externals/dash
commit 55d8cc9294437ffd718acfeeb8b143da0637a125
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
Running sum and product can only be computed from non-empty lists
---
dash.el | 16 ++++++++++++----
dev/examples.el | 8 ++++----
2 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/dash.el b/dash.el
index f40dad1..4136851 100644
--- a/dash.el
+++ b/dash.el
@@ -2222,9 +2222,13 @@ Return nil if N is less than 1."
(apply '+ list))
(defun -running-sum (list)
- "Return a list with running sums of items in LIST."
+ "Return a list with running sums of items in LIST.
+
+LIST must be non-empty."
(declare (pure t) (side-effect-free t))
- (-map '-sum (-inits list)))
+ (unless (consp list)
+ (error "LIST must be non-empty"))
+ (-reductions '+ list))
(defun -product (list)
"Return the product of LIST."
@@ -2232,9 +2236,13 @@ Return nil if N is less than 1."
(apply '* list))
(defun -running-product (list)
- "Return a list with running products of items in LIST."
+ "Return a list with running products of items in LIST.
+
+LIST must be non-empty."
(declare (pure t) (side-effect-free t))
- (-map '-product (-inits list)))
+ (unless (consp list)
+ (error "LIST must be non-empty"))
+ (-reductions '* list))
(defun -max (list)
"Return the largest value from LIST of numbers or markers."
diff --git a/dev/examples.el b/dev/examples.el
index d629cba..8e7b5dd 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -363,9 +363,9 @@ new list."
(-sum '(1 2 3 4)) => 10)
(defexamples -running-sum
- (-running-sum '()) => nil
+ (-running-sum '(1 2 3 4)) => '(1 3 6 10)
(-running-sum '(1)) => '(1)
- (-running-sum '(1 2 3 4)) => '(1 3 6 10))
+ (-running-sum '()) !!> error)
(defexamples -product
(-product '()) => 1
@@ -373,9 +373,9 @@ new list."
(-product '(1 2 3 4)) => 24)
(defexamples -running-product
- (-running-product '()) => nil
+ (-running-product '(1 2 3 4)) => '(1 2 6 24)
(-running-product '(1)) => '(1)
- (-running-product '(1 2 3 4)) => '(1 2 6 24))
+ (-running-product '()) !!> error)
(defexamples -min
(-min '(0)) => 0
- [elpa] externals/dash 6302243 127/316: Release 2.15.0, (continued)
- [elpa] externals/dash 6302243 127/316: Release 2.15.0, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 2758ee7 130/316: Alias `-cons-pair-p` to `-cons-pair?`, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 7267556 075/316: Fix infinite loop in -zip/-interleave when called with no arguments., ELPA Syncer, 2021/02/15
- [elpa] externals/dash fd5980e 136/316: Ensure `hash?` expander evaluates its arg only once., ELPA Syncer, 2021/02/15
- [elpa] externals/dash dca7bdc 135/316: Merge pull request #277 from yyoncho/custom-destructoring, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 7854ec7 148/316: Fix quote simplification in docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 4ce0e85 149/316: Actually remove mentions of Marmalade, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0273913 072/316: Update docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash e9b8611 077/316: Mention that -select and -remove are related, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 8ef3287 078/316: Merge pull request #237 from Wilfred/add-see-also, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 55d8cc9 088/316: Running sum and product can only be computed from non-empty lists,
ELPA Syncer <=
- [elpa] externals/dash 1b9061c 090/316: Update docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 528e5a5 095/316: Merge pull request #258 from Wilfred/quotes-in-docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash c77644b 092/316: Regenerate docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 27c2fe8 100/316: Add missing keywords, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 83190a2 106/316: Emacs 26.1 was released and pretest does no longer exist, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0505f5d 109/316: Merge pull request #271 from magnars/feature/-setq, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 148404c 114/316: [Fix #256] Allow `-let` bindings with no explicit value, ELPA Syncer, 2021/02/15
- [elpa] externals/dash f1ffdf7 131/316: Merge pull request #288 from cireu/master, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 6d2decb 122/316: Prefer number-to-string over int-to-string, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 3f7bc26 132/316: Provided option to extend destructoring, ELPA Syncer, 2021/02/15