Skip to content

Instantly share code, notes, and snippets.

@luxbock
Created March 21, 2017 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luxbock/33fecd25fce1ea91412ff86fb4df1e83 to your computer and use it in GitHub Desktop.
Save luxbock/33fecd25fce1ea91412ff86fb4df1e83 to your computer and use it in GitHub Desktop.
(defnav every-nth [n]
(select* [this structure next-fn]
(next-fn (take-nth n structure)))
(transform* [this structure next-fn]
(let [xform (comp
(map-indexed
(fn [i x]
(if (zero? (mod i n))
(next-fn x)
x)))
(filter #(not (identical? % sp/NONE))))])
(if (vector? structure)
(into [] xform structure)
(sequence xform structure))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment