Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Jannis
Last active February 18, 2016 14:38
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 Jannis/bae398ae0e682d0c0c49 to your computer and use it in GitHub Desktop.
Save Jannis/bae398ae0e682d0c0c49 to your computer and use it in GitHub Desktop.
(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