[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 677c156 134/316: Merge pull request #290 from leun
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash 677c156 134/316: Merge pull request #290 from leungbk/rotate |
Date: |
Mon, 15 Feb 2021 15:57:43 -0500 (EST) |
branch: externals/dash
commit 677c1561142db89cb151f50ce21f24096ca1a328
Merge: f1ffdf7 016e0de
Author: Matus Goljer <dota.keys@gmail.com>
Commit: GitHub <noreply@github.com>
Merge pull request #290 from leungbk/rotate
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 fbc9e31 197/316: Merge branch externals/dash from GNU ELPA, (continued)
- [elpa] externals/dash fbc9e31 197/316: Merge branch externals/dash from GNU ELPA, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 2fb97f0 202/316: ; Fix typo in last change, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 9c6a7c3 207/316: Add Makefile, ELPA Syncer, 2021/02/15
- [elpa] externals/dash f2cd73d 211/316: Make --dotimes more hygienic, ELPA Syncer, 2021/02/15
- [elpa] externals/dash b34ddf5 210/316: Improve formatting of ellipses, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 8879c41 216/316: Use actual dash-functional.el version in README, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 5a64259 218/316: ; Move -doto/--doto next to other threading macros, ELPA Syncer, 2021/02/15
- [elpa] externals/dash b3c58ff 221/316: Fix docstring of -list, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 26f065f 129/316: Merge pull request #282 from yyoncho/anamorphic-doto, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 4abffdc 123/316: Update docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 677c156 134/316: Merge pull request #290 from leungbk/rotate,
ELPA Syncer <=
- [elpa] externals/dash 1549860 139/316: Merge pull request #296 from cireu/fix-hash-opt-expander, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 93e0465 137/316: Remove dependecy `macroexp`, ELPA Syncer, 2021/02/15
- [elpa] externals/dash a358b79 143/316: Speed up `-uniq` with hash-table., ELPA Syncer, 2021/02/15
- [elpa] externals/dash 77f3bf4 142/316: Merge pull request #302 from bbatsov/patch-1, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 38dc929 222/316: Fix, improve, and extend anaphoric folds, ELPA Syncer, 2021/02/15
- [elpa] externals/dash d308676 225/316: Fix signal argument and case where start is null, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 994cda9 228/316: Simplify -cons-pair?, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 11907f4 145/316: Speed up `-uniq` with hash-table. (#305), ELPA Syncer, 2021/02/15
- [elpa] externals/dash ad21e13 146/316: Ignore all .elc and TAGS files, ELPA Syncer, 2021/02/15
- [elpa] externals/dash fae51b5 147/316: Make -inits not destroy its argument, ELPA Syncer, 2021/02/15