Skip to content

Instantly share code, notes, and snippets.

@drcode
Last active May 17, 2022 14:42
Show Gist options
  • Save drcode/475b6011b7393739023572d59bb1fccb to your computer and use it in GitHub Desktop.
Save drcode/475b6011b7393739023572d59bb1fccb to your computer and use it in GitHub Desktop.
(defn foo [coll]
(map concat (reductions conj () (cycle (reverse coll))) (repeat (cycle coll))))
;; > (map (partial take 10) (take 10 (foo [:a :b :c :d])))
;; ((:a :b :c :d :a :b :c :d :a :b)
;; (:d :a :b :c :d :a :b :c :d :a)
;; (:c :d :a :b :c :d :a :b :c :d)
;; (:b :c :d :a :b :c :d :a :b :c)
;; (:a :b :c :d :a :b :c :d :a :b)
;; (:d :a :b :c :d :a :b :c :d :a)
;; (:c :d :a :b :c :d :a :b :c :d)
;; (:b :c :d :a :b :c :d :a :b :c)
;; (:a :b :c :d :a :b :c :d :a :b)
;; (:d :a :b :c :d :a :b :c :d :a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment