[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash 3075aea 040/316: Add -unzip
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash 3075aea 040/316: Add -unzip |
Date: |
Mon, 15 Feb 2021 15:57:21 -0500 (EST) |
branch: externals/dash
commit 3075aea1a3de5a6d01e604cb4b7cb4fce5db400e
Author: Matus Goljer <matus.goljer@gmail.com>
Commit: Matus Goljer <matus.goljer@gmail.com>
Add -unzip
---
README.md | 19 +++++++++++++++++++
dash.el | 13 +++++++++++++
dev/examples.el | 4 ++++
3 files changed, 36 insertions(+)
diff --git a/README.md b/README.md
index e5a207c..f0d64a6 100644
--- a/README.md
+++ b/README.md
@@ -218,6 +218,7 @@ Other list functions not fit to be classified elsewhere.
* [-zip-with](#-zip-with-fn-list1-list2) `(fn list1 list2)`
* [-zip](#-zip-rest-lists) `(&rest lists)`
* [-zip-fill](#-zip-fill-fill-value-rest-lists) `(fill-value &rest lists)`
+* [-unzip](#-unzip-lists) `(lists)`
* [-cycle](#-cycle-list) `(list)`
* [-pad](#-pad-fill-value-rest-lists) `(fill-value &rest lists)`
* [-table](#-table-fn-rest-lists) `(fn &rest lists)`
@@ -1536,6 +1537,24 @@ longest input list.
(-zip-fill 0 '(1 2 3 4 5) '(6 7 8 9)) ;; => '((1 . 6) (2 . 7) (3 . 8) (4 . 9)
(5 . 0))
```
+#### -unzip `(lists)`
+
+Unzip `lists`.
+
+This works just like [`-zip`](#-zip-rest-lists) but takes a list of lists
instead of
+a variable number of arguments, such that
+
+ (-unzip (-zip `l1` `l2` `l3` ...))
+
+is identity (given that the lists are the same length).
+
+See also: [`-zip`](#-zip-rest-lists)
+
+```el
+(-unzip (-zip '(1 2 3) '(a b c) '("e" "f" "g"))) ;; => '((1 2 3) (a b c) ("e"
"f" "g"))
+(-unzip '((1 2) (3 4) (5 6) (7 8) (9 10))) ;; => '((1 3 5 7 9) (2 4 6 8 10))
+```
+
#### -cycle `(list)`
Return an infinite copy of `list` that will cycle through the
diff --git a/dash.el b/dash.el
index d64a4e3..53849ee 100644
--- a/dash.el
+++ b/dash.el
@@ -1119,6 +1119,19 @@ longest input list."
(declare (pure t) (side-effect-free t))
(apply '-zip (apply '-pad (cons fill-value lists))))
+(defun -unzip (lists)
+ "Unzip LISTS.
+
+This works just like `-zip' but takes a list of lists instead of
+a variable number of arguments, such that
+
+ (-unzip (-zip L1 L2 L3 ...))
+
+is identity (given that the lists are the same length).
+
+See also: `-zip'"
+ (apply '-zip lists))
+
(defun -cycle (list)
"Return an infinite copy of LIST that will cycle through the
elements and repeat from the beginning."
diff --git a/dev/examples.el b/dev/examples.el
index c846d08..52976cc 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -620,6 +620,10 @@ new list."
(defexamples -zip-fill
(-zip-fill 0 '(1 2 3 4 5) '(6 7 8 9)) => '((1 . 6) (2 . 7) (3 . 8) (4 . 9)
(5 . 0)))
+ (defexamples -unzip
+ (-unzip (-zip '(1 2 3) '(a b c) '("e" "f" "g"))) => '((1 2 3) (a b c) ("e"
"f" "g"))
+ (-unzip '((1 2) (3 4) (5 6) (7 8) (9 10))) => '((1 3 5 7 9) (2 4 6 8 10)))
+
(defexamples -cycle
(-take 5 (-cycle '(1 2 3))) => '(1 2 3 1 2)
(-take 7 (-cycle '(1 "and" 3))) => '(1 "and" 3 1 "and" 3 1)
- [elpa] externals/dash 502be58 029/316: Make -each-indexed indent like -each, (continued)
- [elpa] externals/dash 502be58 029/316: Make -each-indexed indent like -each, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 4ae329a 032/316: Release 2.13.0, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 0100584 033/316: Correct typo of 'does' to 'do' in -map-when docs, ELPA Syncer, 2021/02/15
- [elpa] externals/dash b7ba212 036/316: Edebug support for threading macros (#188), ELPA Syncer, 2021/02/15
- [elpa] externals/dash d4bccfe 037/316: Add annotations to pure functions. (#199), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 4b805e1 041/316: Update README, ELPA Syncer, 2021/02/15
- [elpa] externals/dash bcc74b5 045/316: [#200] Define setters for -first-item and -last-item, ELPA Syncer, 2021/02/15
- [elpa] externals/dash a9f90d7 016/316: Add -select-column(s), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 27b1ea5 030/316: Update changelog for 2.12.x., ELPA Syncer, 2021/02/15
- [elpa] externals/dash 52e7eb4 031/316: Merge pull request #191 from Wilfred/update_changelog, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 3075aea 040/316: Add -unzip,
ELPA Syncer <=
- [elpa] externals/dash 2996a0d 035/316: Add a LICENSE file (#194), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 9dfb01a 050/316: Correct use of eval-after-load, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 75cde71 052/316: Ensure that -first-item is as fast as car, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 05dc0aa 062/316: Add copyright assignment statement to documentation, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 4de2189 027/316: [Feature #185] -cut <> in first slot is a function, ELPA Syncer, 2021/02/15
- [elpa] externals/dash b45b38a 039/316: Fix typo, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 07c61f5 046/316: [#200] Add tests for generalized variables, ELPA Syncer, 2021/02/15
- [elpa] externals/dash ff323e0 049/316: Fix setf on emacs23 (#205), ELPA Syncer, 2021/02/15
- [elpa] externals/dash 958e3fb 051/316: Merge pull request #206 from Silex/master, ELPA Syncer, 2021/02/15
- [elpa] externals/dash 98e819e 053/316: Merge pull request #210 from Wilfred/car_opcode_with_first_item, ELPA Syncer, 2021/02/15