|
|
|
|
@ -1104,11 +1104,12 @@ elements of LIST. Keys are compared by `equal'." |
|
|
|
|
(defun -interleave (&rest lists) |
|
|
|
|
"Return a new list of the first item in each list, then the second etc." |
|
|
|
|
(declare (pure t) (side-effect-free t)) |
|
|
|
|
(let (result) |
|
|
|
|
(while (-none? 'null lists) |
|
|
|
|
(--each lists (!cons (car it) result)) |
|
|
|
|
(setq lists (-map 'cdr lists))) |
|
|
|
|
(nreverse result))) |
|
|
|
|
(when lists |
|
|
|
|
(let (result) |
|
|
|
|
(while (-none? 'null lists) |
|
|
|
|
(--each lists (!cons (car it) result)) |
|
|
|
|
(setq lists (-map 'cdr lists))) |
|
|
|
|
(nreverse result)))) |
|
|
|
|
|
|
|
|
|
(defmacro --zip-with (form list1 list2) |
|
|
|
|
"Anaphoric form of `-zip-with'. |
|
|
|
|
@ -1150,16 +1151,17 @@ of cons cells. Otherwise, return the groupings as a list of lists. |
|
|
|
|
Please note! This distinction is being removed in an upcoming 3.0 |
|
|
|
|
release of Dash. If you rely on this behavior, use -zip-pair instead." |
|
|
|
|
(declare (pure t) (side-effect-free t)) |
|
|
|
|
(let (results) |
|
|
|
|
(while (-none? 'null lists) |
|
|
|
|
(setq results (cons (mapcar 'car lists) results)) |
|
|
|
|
(setq lists (mapcar 'cdr lists))) |
|
|
|
|
(setq results (nreverse results)) |
|
|
|
|
(if (= (length lists) 2) |
|
|
|
|
;; to support backward compatability, return |
|
|
|
|
;; a cons cell if two lists were provided |
|
|
|
|
(--map (cons (car it) (cadr it)) results) |
|
|
|
|
results))) |
|
|
|
|
(when lists |
|
|
|
|
(let (results) |
|
|
|
|
(while (-none? 'null lists) |
|
|
|
|
(setq results (cons (mapcar 'car lists) results)) |
|
|
|
|
(setq lists (mapcar 'cdr lists))) |
|
|
|
|
(setq results (nreverse results)) |
|
|
|
|
(if (= (length lists) 2) |
|
|
|
|
;; to support backward compatability, return |
|
|
|
|
;; a cons cell if two lists were provided |
|
|
|
|
(--map (cons (car it) (cadr it)) results) |
|
|
|
|
results)))) |
|
|
|
|
|
|
|
|
|
(defalias '-zip-pair '-zip) |
|
|
|
|
|
|
|
|
|
|