[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash eb1231e 087/316: Add -reductions[-r][-from]
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash eb1231e 087/316: Add -reductions[-r][-from] |
Date: |
Mon, 15 Feb 2021 15:57:32 -0500 (EST) |
branch: externals/dash
commit eb1231eca425b2ee6cb41ae757fccf0ef9185d51
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
Add -reductions[-r][-from]
---
dash.el | 36 ++++++++++++++++++++++++++++++++++++
dev/examples.el | 20 ++++++++++++++++++++
2 files changed, 56 insertions(+)
diff --git a/dash.el b/dash.el
index 7e0c75d..f40dad1 100644
--- a/dash.el
+++ b/dash.el
@@ -235,6 +235,38 @@ See also: `-reduce-r-from', `-reduce'"
(declare (debug (form form)))
`(-reduce-r (lambda (&optional it acc) ,form) ,list))
+(defun -reductions-from (fn init list)
+ "Return a list of the intermediate values of the reduction.
+
+See `-reduce-from' for explanation of the arguments.
+
+See also: `-reductions', `-reductions-r', `-reduce-r'"
+ (nreverse (--reduce-from (cons (funcall fn (car acc) it) acc) (list init)
list)))
+
+(defun -reductions (fn list)
+ "Return a list of the intermediate values of the reduction.
+
+See `-reduce' for explanation of the arguments.
+
+See also: `-reductions-from', `-reductions-r', `-reduce-r'"
+ (-reductions-from fn (car list) (cdr list)))
+
+(defun -reductions-r-from (fn init list)
+ "Return a list of the intermediate values of the reduction.
+
+See `-reduce-r-from' for explanation of the arguments.
+
+See also: `-reductions-r', `-reductions', `-reduce'"
+ (--reduce-r-from (cons (funcall fn it (car acc)) acc) (list init) list))
+
+(defun -reductions-r (fn list)
+ "Return a list of the intermediate values of the reduction.
+
+See `-reduce-r' for explanation of the arguments.
+
+See also: `-reductions-r-from', `-reductions', `-reduce'"
+ (-reductions-r-from fn (-last-item list) (-butlast list)))
+
(defmacro --filter (form list)
"Anaphoric form of `-filter'.
@@ -2483,6 +2515,10 @@ structure such as plist or alist."
"--reduce-r-from"
"-reduce-r"
"--reduce-r"
+ "-reductions-from"
+ "-reductions-r-from"
+ "-reductions"
+ "-reductions-r"
"-filter"
"--filter"
"-select"
diff --git a/dev/examples.el b/dev/examples.el
index a560ec3..d629cba 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -333,6 +333,26 @@ new list."
(-reduce-r '+ '(1)) => 1
(--reduce-r (format "%s-%s" it acc) '()) => "nil-nil")
+ (defexamples -reductions-from
+ (-reductions-from (lambda (a i) (format "(%s FN %s)" a i)) "INIT" '(1 2 3
4)) => '("INIT" "(INIT FN 1)" "((INIT FN 1) FN 2)" "(((INIT FN 1) FN 2) FN 3)"
"((((INIT FN 1) FN 2) FN 3) FN 4)")
+ (-reductions-from 'max 0 '(2 1 4 3)) => '(0 2 2 4 4)
+ (-reductions-from '* 1 '(1 2 3 4)) => '(1 1 2 6 24))
+
+ (defexamples -reductions-r-from
+ (-reductions-r-from (lambda (i a) (format "(%s FN %s)" i a)) "INIT" '(1 2
3 4)) => '("(1 FN (2 FN (3 FN (4 FN INIT))))" "(2 FN (3 FN (4 FN INIT)))" "(3
FN (4 FN INIT))" "(4 FN INIT)" "INIT")
+ (-reductions-r-from 'max 0 '(2 1 4 3)) => '(4 4 4 3 0)
+ (-reductions-r-from '* 1 '(1 2 3 4)) => '(24 24 12 4 1))
+
+ (defexamples -reductions
+ (-reductions (lambda (a i) (format "(%s FN %s)" a i)) '(1 2 3 4)) => '(1
"(1 FN 2)" "((1 FN 2) FN 3)" "(((1 FN 2) FN 3) FN 4)")
+ (-reductions '+ '(1 2 3 4)) => '(1 3 6 10)
+ (-reductions '* '(1 2 3 4)) => '(1 2 6 24))
+
+ (defexamples -reductions-r
+ (-reductions-r (lambda (i a) (format "(%s FN %s)" i a)) '(1 2 3 4)) =>
'("(1 FN (2 FN (3 FN 4)))" "(2 FN (3 FN 4))" "(3 FN 4)" 4)
+ (-reductions-r '+ '(1 2 3 4)) => '(10 9 7 4)
+ (-reductions-r '* '(1 2 3 4)) => '(24 24 12 4))
+
(defexamples -count
(-count 'even? '(1 2 3 4 5)) => 2
(--count (< it 4) '(1 2 3 4)) => 3)
- [elpa] externals/dash 73a28ae 043/316: Fix function application in documentation, (continued)
- [elpa] externals/dash 73a28ae 043/316: Fix function application in documentation, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 53e641c 044/316: [Fix #202] -table-flat works on input of dimension 1, ELPA Syncer, 2021/02/15
- [elpa] externals/dash f04df47 048/316: Fix the debug declaration for -->, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 81ef1ef 055/316: Replace string-to-int with string-to-number (#216), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 13a4718 059/316: Add new partition-before, -after methods., ELPA Syncer, 2021/02/15
- [elpa] externals/dash ca2f767 064/316: Show (VAR VAL) in the function signature, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0297166 068/316: Docs: Clarify that we don't modify the original list, ELPA Syncer, 2021/02/15
- [elpa] externals/dash a57c2c3 082/316: Merge pull request #245 from duianto/patch-1, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 5b549bc 085/316: Add missing fontification keywords, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0574686 089/316: Make tails and inits return all prefixes including the empty one., ELPA Syncer, 2021/02/15
- [elpa] externals/dash eb1231e 087/316: Add -reductions[-r][-from],
ELPA Syncer <=
- [elpa] externals/dash 4e90743 093/316: Ensure ' in docstring code snippets is not replaced, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 138c22a 097/316: Merge pull request #261 from basil-conto/blc/common-prefix, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 3789b15 102/316: Change Emacs tested and supported versions., ELPA Syncer, 2021/02/15
- [elpa] externals/dash e9919f6 104/316: Release 2.14.0, ELPA Syncer, 2021/02/15
- [elpa] externals/dash a55452a 107/316: Merge pull request #270 from magnars/travis/use-emacs-26, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 14f76df 118/316: Update docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 8af9987 116/316: Add '-each-r' and '-each-r-while'., ELPA Syncer, 2021/02/15
- [elpa] externals/dash 8873749 120/316: Improve and simplify right-associative reductions, ELPA Syncer, 2021/02/15
- [elpa] externals/dash e52909f 110/316: Add smarter key destructuring, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 6302243 127/316: Release 2.15.0, ELPA Syncer, 2021/02/15