[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash cd137e0 310/439: `-slice` should not fill the retu
From: |
Phillip Lord |
Subject: |
[elpa] externals/dash cd137e0 310/439: `-slice` should not fill the returned list with nils if to > length |
Date: |
Tue, 04 Aug 2015 20:29:32 +0000 |
branch: externals/dash
commit cd137e0d50c572246ea513499dd13d14690c1792
Author: Matus Goljer <address@hidden>
Commit: Matus Goljer <address@hidden>
`-slice` should not fill the returned list with nils if to > length
---
dash.el | 11 ++++-------
dev/examples.el | 5 ++++-
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/dash.el b/dash.el
index 41aea86..7c1a772 100644
--- a/dash.el
+++ b/dash.el
@@ -436,8 +436,7 @@ Returns `nil` both if all items match the predicate, and if
none of the items ma
"Return copy of LIST, starting from index FROM to index TO.
FROM or TO may be negative."
(let ((length (length list))
- (new-list nil)
- (index 0))
+ (new-list nil))
;; to defaults to the end of the list
(setq to (or to length))
;; handle negative indices
@@ -447,11 +446,9 @@ FROM or TO may be negative."
(setq to (mod to length)))
;; iterate through the list, keeping the elements we want
- (while (< index to)
- (when (>= index from)
- (!cons (car list) new-list))
- (!cdr list)
- (setq index (1+ index)))
+ (--each-while list (< it-index to)
+ (when (>= it-index from)
+ (push it new-list)))
(nreverse new-list)))
(defun -take (n list)
diff --git a/dev/examples.el b/dev/examples.el
index 4de5882..28fceb6 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -70,7 +70,10 @@
(defexamples -slice
(-slice '(1 2 3 4 5) 1) => '(2 3 4 5)
(-slice '(1 2 3 4 5) 0 3) => '(1 2 3)
- (-slice '(1 2 3 4 5) 1 -1) => '(2 3 4))
+ (-slice '(1 2 3 4 5) 1 -1) => '(2 3 4)
+ (-slice '(1 2 3 4 5) 0 10) => '(1 2 3 4 5) ;; "to > length" should not
fill in nils!
+ (-slice '(1 2 3 4 5) -3) => '(3 4 5)
+ (-slice '(1 2 3 4 5) -3 -1) => '(3 4))
(defexamples -take
(-take 3 '(1 2 3 4 5)) => '(1 2 3)
- [elpa] externals/dash 703bb59 297/439: Convert -zip to support variable-length arguments, (continued)
- [elpa] externals/dash 703bb59 297/439: Convert -zip to support variable-length arguments, Phillip Lord, 2015/08/04
- [elpa] externals/dash 4ecfea6 296/439: Merge pull request #79 from Fuco1/debug-forms, Phillip Lord, 2015/08/04
- [elpa] externals/dash c08fcba 299/439: Fixed documentation of `-last-item'., Phillip Lord, 2015/08/04
- [elpa] externals/dash c952a54 300/439: Merge pull request #90 from tmalsburg/last-item-doc, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2dfd748 298/439: Merge pull request #87 from steventlamb/topic/make_zip_n_ary, Phillip Lord, 2015/08/04
- [elpa] externals/dash bd85b7c 302/439: Make -zip support infinite (circular) lists, Phillip Lord, 2015/08/04
- [elpa] externals/dash f0dd4cc 301/439: Add -annotate, Phillip Lord, 2015/08/04
- [elpa] externals/dash f780322 305/439: Add `-flatten-n`, Phillip Lord, 2015/08/04
- [elpa] externals/dash fb51f8f 304/439: Merge pull request #88 from steventlamb/topic/zip_cycle_pad, Phillip Lord, 2015/08/04
- [elpa] externals/dash 00549e4 307/439: Add missing fontification keywords, Phillip Lord, 2015/08/04
- [elpa] externals/dash cd137e0 310/439: `-slice` should not fill the returned list with nils if to > length,
Phillip Lord <=
- [elpa] externals/dash 6b64ea7 303/439: Add functions for flexibly zipping uneven lists, Phillip Lord, 2015/08/04
- [elpa] externals/dash 63ec298 308/439: Merge pull request #92 from Fuco1/outer-product, Phillip Lord, 2015/08/04
- [elpa] externals/dash 7185db8 311/439: [Issue #83] Add `step` to `-slice`, Phillip Lord, 2015/08/04
- [elpa] externals/dash a3021eb 313/439: Merge pull request #93 from lunaryorn/patch-1, Phillip Lord, 2015/08/04
- [elpa] externals/dash 624c501 306/439: Add `-table` and `-table-flat`, Phillip Lord, 2015/08/04
- [elpa] externals/dash 0384eee 312/439: Improve Travis CI configuration, Phillip Lord, 2015/08/04
- [elpa] externals/dash 3132ae0 314/439: Alias -tail to nthcdr, Phillip Lord, 2015/08/04
- [elpa] externals/dash 2ecc073 316/439: Reorder the partition examples to follow more logical order, add tests, Phillip Lord, 2015/08/04
- [elpa] externals/dash bbc1d9c 309/439: `--each-while` should also expose `it-index`, Phillip Lord, 2015/08/04
- [elpa] externals/dash d948086 315/439: Add -iteratefn, Phillip Lord, 2015/08/04