[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 0574686 089/316: Make tails and inits return all p
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash 0574686 089/316: Make tails and inits return all prefixes including the empty one. |
Date: |
Mon, 15 Feb 2021 15:57:32 -0500 (EST) |
branch: externals/dash
commit 057468608dd64b6fb66420fc46ec11ce1c4792df
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
Make tails and inits return all prefixes including the empty one.
It is easy for the user to drop the first/last item with cdr or
-butlast, so let's be consistent with how reductions work
---
dash.el | 9 +++------
dev/examples.el | 12 ++++++------
2 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/dash.el b/dash.el
index 4136851..aa6e9f5 100644
--- a/dash.el
+++ b/dash.el
@@ -2108,15 +2108,12 @@ or with `-compare-fn' if that's non-nil."
list))))
(defun -inits (list)
- "Return all non-empty prefixes of LIST."
+ "Return all prefixes of LIST."
(nreverse (-map 'reverse (-tails (nreverse list)))))
(defun -tails (list)
- "Return all non-empty suffixes of LIST"
- (-reduce-r-from
- (lambda (it acc)
- (cons (cons it (car acc)) acc))
- nil list))
+ "Return all suffixes of LIST"
+ (-reductions-r-from 'cons nil list))
(defun -contains? (list element)
"Return non-nil if LIST contains ELEMENT.
diff --git a/dev/examples.el b/dev/examples.el
index 8e7b5dd..3b63879 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -638,14 +638,14 @@ new list."
(-permutations '(a b c)) => '((a b c) (a c b) (b a c) (b c a) (c a b) (c b
a)))
(defexamples -inits
- (-inits '(1 2 3 4)) => '((1) (1 2) (1 2 3) (1 2 3 4))
- (-inits nil) => nil
- (-inits '(1)) => '((1)))
+ (-inits '(1 2 3 4)) => '(nil (1) (1 2) (1 2 3) (1 2 3 4))
+ (-inits nil) => '(nil)
+ (-inits '(1)) => '(nil (1)))
(defexamples -tails
- (-tails '(1 2 3 4)) => '((1 2 3 4) (2 3 4) (3 4) (4))
- (-tails nil) => nil
- (-tails '(1)) => '((1)))
+ (-tails '(1 2 3 4)) => '((1 2 3 4) (2 3 4) (3 4) (4) nil)
+ (-tails nil) => '(nil)
+ (-tails '(1)) => '((1) nil))
(defexamples -distinct
(-distinct '()) => '()
- [elpa] externals/dash 1422b70 042/316: Update info, (continued)
- [elpa] externals/dash 1422b70 042/316: Update info, ELPA Syncer, 2021/02/15
- [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 <=
- [elpa] externals/dash eb1231e 087/316: Add -reductions[-r][-from], ELPA Syncer, 2021/02/15
- [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