Skip to content

Commit

Permalink
cln: incorporate PR comments from 2022-06-07
Browse files Browse the repository at this point in the history
  • Loading branch information
hrehfeld committed Jun 9, 2022
1 parent ab87376 commit c994480
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dash.el
Expand Up @@ -1595,16 +1595,14 @@ elements of LIST. Keys are compared by `equal'."
(nreverse result))))

(defun -interleave-all (&rest lists)
"Return a new list of the first item in each of `lists', then the
second etc. Continue interleaving all elements of all lists by
skipping the non-existing elements of short lists."
"Return a new list containing an element of each of `LISTS' in turn, including all elements. "
(declare (pure t) (side-effect-free t))
(when lists
(let (result)
(while (--any? (consp it) lists)
(while (-none? 'null lists)
(while (--some (consp it) lists)
(while (--every it lists)
(--each lists (!cons (car it) result))
(setq lists (-map 'cdr lists)))
(setq lists (-map #'cdr lists)))
(setq lists (-filter #'consp lists)))
(nreverse result))))

Expand Down
8 changes: 8 additions & 0 deletions dev/examples.el
Expand Up @@ -1457,6 +1457,14 @@ related predicates."
(-interleave '(1 2 3) '("a" "b" "c" "d")) => '(1 "a" 2 "b" 3 "c")
(-interleave) => nil)

(defexamples -interleave-all
(-interleave-all '(1 2 3) '("a" "b")) => '(1 "a" 2 "b" 3)
(-interleave-all '(1 2 3) '("a" "b") '("A" "B" "C")) => '(1 "a" "A" 2 "b" "B" 3 "C")
(-interleave-all '(1) '("a" "b" "c" "d")) => '(1 "a" "b" "c" "d")
(-interleave '(1 2) '("a" "b")) => '(1 "a" 2 "b")
(-interleave '(1 2) '("a" "b") '("A" "B")) => '(1 "a" "A" 2 "b" "B")
(-interleave-all) => nil)

(defexamples -iota
(-iota 6) => '(0 1 2 3 4 5)
(-iota 4 2.5 -2) => '(2.5 0.5 -1.5 -3.5)
Expand Down

0 comments on commit c994480

Please sign in to comment.