[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 016e0de 133/316: Generalize `-rotate` for `|n|` gr
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash 016e0de 133/316: Generalize `-rotate` for `|n|` greater than `(length list)`. |
Date: |
Mon, 15 Feb 2021 15:57:43 -0500 (EST) |
branch: externals/dash
commit 016e0dee0358b805139765a72cca51831f6f3f1a
Author: Brian Leung <bkleung89@gmail.com>
Commit: Brian Leung <bkleung89@gmail.com>
Generalize `-rotate` for `|n|` greater than `(length list)`.
---
dash.el | 8 +++++---
dev/examples.el | 4 +++-
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/dash.el b/dash.el
index 5822361..fcfe5d2 100644
--- a/dash.el
+++ b/dash.el
@@ -921,9 +921,11 @@ See also: `-drop'"
"Rotate LIST N places to the right. With N negative, rotate to the left.
The time complexity is O(n)."
(declare (pure t) (side-effect-free t))
- (if (> n 0)
- (append (last list n) (butlast list n))
- (append (-drop (- n) list) (-take (- n) list))))
+ (when list
+ (let* ((len (length list))
+ (n-mod-len (mod n len))
+ (new-tail-len (- len n-mod-len)))
+ (append (-drop new-tail-len list) (-take new-tail-len list)))))
(defun -insert-at (n x list)
"Return a list with X inserted into LIST at position N.
diff --git a/dev/examples.el b/dev/examples.el
index a250b34..2c8a94d 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -694,7 +694,9 @@ new list."
(defexamples -rotate
(-rotate 3 '(1 2 3 4 5 6 7)) => '(5 6 7 1 2 3 4)
- (-rotate -3 '(1 2 3 4 5 6 7)) => '(4 5 6 7 1 2 3))
+ (-rotate -3 '(1 2 3 4 5 6 7)) => '(4 5 6 7 1 2 3)
+ (-rotate 16 '(1 2 3 4 5 6 7)) => '(6 7 1 2 3 4 5)
+ (-rotate -16 '(1 2 3 4 5 6 7)) => '(3 4 5 6 7 1 2))
(defexamples -repeat
(-repeat 3 :a) => '(:a :a :a)
- [elpa] externals/dash 528e5a5 095/316: Merge pull request #258 from Wilfred/quotes-in-docs, (continued)
- [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
- [elpa] externals/dash a6e1436 124/316: Add -common-suffix, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 016e0de 133/316: Generalize `-rotate` for `|n|` greater than `(length list)`.,
ELPA Syncer <=
- [elpa] externals/dash bbf8016 138/316: Remove dependecy `cl-lib` in tests., ELPA Syncer, 2021/02/15
- [elpa] externals/dash f3e9cd2 151/316: Fix doc and test harnesses (#309), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 070b569 156/316: Add missing indent declaration for ‘-some->’ and siblings, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 800c25d 166/316: feat(docs): simplify (function x) to #'x, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 53323ec 169/316: Fix typo and its copies, ELPA Syncer, 2021/02/15
- [elpa] externals/dash fe9bbc2 170/316: Merge pull request #334 from tarsiiformes/typo, ELPA Syncer, 2021/02/15
- [elpa] externals/dash e4e5269 180/316: Finish last change to package keywords, ELPA Syncer, 2021/02/15
- [elpa] externals/dash b329938 182/316: Update CI configuration, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 7629dae 183/316: Add dir-locals-file with useful settings, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 84721fc 206/316: Optimize -repeat a bit, ELPA Syncer, 2021/02/15