Last active
February 18, 2016 14:38
-
-
Save Jannis/bae398ae0e682d0c0c49 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
(defn pad-by | |
([pred pad] | |
(fn [rf] | |
(let [pv (volatile! ::none)] | |
(fn | |
([] (rf)) | |
([result] (rf result)) | |
([result input] | |
(let [prior @pv] | |
(vreset! pv input) | |
(if (pred prior input) | |
(rf (rf result pad) input) | |
(rf result input)))))))) | |
([pred pad coll] (sequence (pad-by pred pad) coll))) | |
(defn parse-props-spec | |
[spec] | |
(transduce (pad-by #(= (type %1) (type %2) nil)) conj [] spec) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment