[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash d8bcf56 086/316: Add -running-sum and -running-pro
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash d8bcf56 086/316: Add -running-sum and -running-product |
Date: |
Mon, 15 Feb 2021 15:57:31 -0500 (EST) |
branch: externals/dash
commit d8bcf567ef96dc20011d830b88b8d975e2acb451
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
Add -running-sum and -running-product
---
README.md | 22 ++++++++++++++++++++++
dash.el | 12 ++++++++++++
dash.texi | 40 ++++++++++++++++++++++++++++++++++++++++
dev/examples.el | 10 ++++++++++
4 files changed, 84 insertions(+)
diff --git a/README.md b/README.md
index 17b9b24..c24960d 100644
--- a/README.md
+++ b/README.md
@@ -137,7 +137,9 @@ Functions reducing lists into single value.
* [-reduce-r](#-reduce-r-fn-list) `(fn list)`
* [-count](#-count-pred-list) `(pred list)`
* [-sum](#-sum-list) `(list)`
+* [-running-sum](#-running-sum-list) `(list)`
* [-product](#-product-list) `(list)`
+* [-running-product](#-running-product-list) `(list)`
* [-min](#-min-list) `(list)`
* [-min-by](#-min-by-comparator-list) `(comparator list)`
* [-max](#-max-list) `(list)`
@@ -927,6 +929,16 @@ Return the sum of `list`.
(-sum '(1 2 3 4)) ;; => 10
```
+#### -running-sum `(list)`
+
+Return a list with running sums of items in `list`.
+
+```el
+(-running-sum '()) ;; => nil
+(-running-sum '(1)) ;; => '(1)
+(-running-sum '(1 2 3 4)) ;; => '(1 3 6 10)
+```
+
#### -product `(list)`
Return the product of `list`.
@@ -937,6 +949,16 @@ Return the product of `list`.
(-product '(1 2 3 4)) ;; => 24
```
+#### -running-product `(list)`
+
+Return a list with running products of items in `list`.
+
+```el
+(-running-product '()) ;; => nil
+(-running-product '(1)) ;; => '(1)
+(-running-product '(1 2 3 4)) ;; => '(1 2 6 24)
+```
+
#### -min `(list)`
Return the smallest value from `list` of numbers or markers.
diff --git a/dash.el b/dash.el
index d016d00..7e0c75d 100644
--- a/dash.el
+++ b/dash.el
@@ -2189,11 +2189,21 @@ Return nil if N is less than 1."
(declare (pure t) (side-effect-free t))
(apply '+ list))
+(defun -running-sum (list)
+ "Return a list with running sums of items in LIST."
+ (declare (pure t) (side-effect-free t))
+ (-map '-sum (-inits list)))
+
(defun -product (list)
"Return the product of LIST."
(declare (pure t) (side-effect-free t))
(apply '* list))
+(defun -running-product (list)
+ "Return a list with running products of items in LIST."
+ (declare (pure t) (side-effect-free t))
+ (-map '-product (-inits list)))
+
(defun -max (list)
"Return the largest value from LIST of numbers or markers."
(declare (pure t) (side-effect-free t))
@@ -2651,7 +2661,9 @@ structure such as plist or alist."
"-list"
"-repeat"
"-sum"
+ "-running-sum"
"-product"
+ "-running-product"
"-max"
"-min"
"-max-by"
diff --git a/dash.texi b/dash.texi
index 6a60f65..ece320c 100644
--- a/dash.texi
+++ b/dash.texi
@@ -1216,6 +1216,26 @@ Return the sum of @var{list}.
@end example
@end defun
+@anchor{-running-sum}
+@defun -running-sum (list)
+Return a list with running sums of items in @var{list}.
+
+@example
+@group
+(-running-sum '())
+ @result{} nil
+@end group
+@group
+(-running-sum '(1))
+ @result{} '(1)
+@end group
+@group
+(-running-sum '(1 2 3 4))
+ @result{} '(1 3 6 10)
+@end group
+@end example
+@end defun
+
@anchor{-product}
@defun -product (list)
Return the product of @var{list}.
@@ -1236,6 +1256,26 @@ Return the product of @var{list}.
@end example
@end defun
+@anchor{-running-product}
+@defun -running-product (list)
+Return a list with running products of items in @var{list}.
+
+@example
+@group
+(-running-product '())
+ @result{} nil
+@end group
+@group
+(-running-product '(1))
+ @result{} '(1)
+@end group
+@group
+(-running-product '(1 2 3 4))
+ @result{} '(1 2 6 24)
+@end group
+@end example
+@end defun
+
@anchor{-min}
@defun -min (list)
Return the smallest value from @var{list} of numbers or markers.
diff --git a/dev/examples.el b/dev/examples.el
index 796d933..a560ec3 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -342,11 +342,21 @@ new list."
(-sum '(1)) => 1
(-sum '(1 2 3 4)) => 10)
+ (defexamples -running-sum
+ (-running-sum '()) => nil
+ (-running-sum '(1)) => '(1)
+ (-running-sum '(1 2 3 4)) => '(1 3 6 10))
+
(defexamples -product
(-product '()) => 1
(-product '(1)) => 1
(-product '(1 2 3 4)) => 24)
+ (defexamples -running-product
+ (-running-product '()) => nil
+ (-running-product '(1)) => '(1)
+ (-running-product '(1 2 3 4)) => '(1 2 6 24))
+
(defexamples -min
(-min '(0)) => 0
(-min '(3 2 1)) => 1
- [elpa] externals/dash b4faa93 066/316: Merge pull request #224 from Wilfred/when-let-docstring, (continued)
- [elpa] externals/dash b4faa93 066/316: Merge pull request #224 from Wilfred/when-let-docstring, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0df0ff1 067/316: Merge pull request #222 from zck/partition-before-after, ELPA Syncer, 2021/02/15
- [elpa] externals/dash dcb0ec1 069/316: Merge pull request #232 from Wilfred/improve_docs_wording, ELPA Syncer, 2021/02/15
- [elpa] externals/dash c026c46 073/316: Merge pull request #240 from basil-conto/239, ELPA Syncer, 2021/02/15
- [elpa] externals/dash bdcaf68 074/316: Merge pull request #236 from Wilfred/robust-docs-generation, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 3493fc9 076/316: Merge pull request #242 from magnars/fix-infinite-loop-zip-interleave, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 057e55c 081/316: Update examples.el, remove duplicate -third-item, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 4b46527 080/316: Merge pull request #238 from Wilfred/more-item-accesses, ELPA Syncer, 2021/02/15
- [elpa] externals/dash e7764ea 083/316: Formatting, ELPA Syncer, 2021/02/15
- [elpa] externals/dash f8c8dc0 084/316: Add -tails and -inits, ELPA Syncer, 2021/02/15
- [elpa] externals/dash d8bcf56 086/316: Add -running-sum and -running-product,
ELPA Syncer <=
- [elpa] externals/dash 72b8d39 096/316: Add -common-prefix, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 91d8cb0 091/316: Move inits and tails under reductions in the examples, ELPA Syncer, 2021/02/15
- [elpa] externals/dash e9c792f 094/316: Merge pull request #257 from Wilfred/update_docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash c1991d4 099/316: Merge pull request #262 from basil-conto/blc/common-prefix, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 48a5015 101/316: Merge pull request #265 from Wilfred/missing-keywords, ELPA Syncer, 2021/02/15
- [elpa] externals/dash beea1a3 098/316: Simplify --common-prefix implementation, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 87d5fea 103/316: Merge pull request #266 from phillord/feature/travis-update, ELPA Syncer, 2021/02/15
- [elpa] externals/dash a74f4cf 105/316: Bump version in package declaration, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 8c4e27f 108/316: Implement -setq, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 578428a 117/316: Add some implementation commentary to '-each-r'., ELPA Syncer, 2021/02/15