Created
March 21, 2017 16:39
-
-
Save luxbock/33fecd25fce1ea91412ff86fb4df1e83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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