master
Matus Goljer 9 years ago
parent b45b38a5db
commit 3075aea1a3
  1. 19
      README.md
  2. 13
      dash.el
  3. 4
      dev/examples.el

@ -218,6 +218,7 @@ Other list functions not fit to be classified elsewhere.
* [-zip-with](#-zip-with-fn-list1-list2) `(fn list1 list2)` * [-zip-with](#-zip-with-fn-list1-list2) `(fn list1 list2)`
* [-zip](#-zip-rest-lists) `(&rest lists)` * [-zip](#-zip-rest-lists) `(&rest lists)`
* [-zip-fill](#-zip-fill-fill-value-rest-lists) `(fill-value &rest lists)` * [-zip-fill](#-zip-fill-fill-value-rest-lists) `(fill-value &rest lists)`
* [-unzip](#-unzip-lists) `(lists)`
* [-cycle](#-cycle-list) `(list)` * [-cycle](#-cycle-list) `(list)`
* [-pad](#-pad-fill-value-rest-lists) `(fill-value &rest lists)` * [-pad](#-pad-fill-value-rest-lists) `(fill-value &rest lists)`
* [-table](#-table-fn-rest-lists) `(fn &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)) (-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)` #### -cycle `(list)`
Return an infinite copy of `list` that will cycle through the Return an infinite copy of `list` that will cycle through the

@ -1119,6 +1119,19 @@ longest input list."
(declare (pure t) (side-effect-free t)) (declare (pure t) (side-effect-free t))
(apply '-zip (apply '-pad (cons fill-value lists)))) (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) (defun -cycle (list)
"Return an infinite copy of LIST that will cycle through the "Return an infinite copy of LIST that will cycle through the
elements and repeat from the beginning." elements and repeat from the beginning."

@ -620,6 +620,10 @@ new list."
(defexamples -zip-fill (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))) (-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 (defexamples -cycle
(-take 5 (-cycle '(1 2 3))) => '(1 2 3 1 2) (-take 5 (-cycle '(1 2 3))) => '(1 2 3 1 2)
(-take 7 (-cycle '(1 "and" 3))) => '(1 "and" 3 1 "and" 3 1) (-take 7 (-cycle '(1 "and" 3))) => '(1 "and" 3 1 "and" 3 1)

Loading…
Cancel
Save