Skip to content

Instantly share code, notes, and snippets.

@souenzzo
Created November 8, 2018 18:43
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 souenzzo/6502f968e3687265af133667b1f1253d to your computer and use it in GitHub Desktop.
Save souenzzo/6502f968e3687265af133667b1f1253d to your computer and use it in GitHub Desktop.
(defn drop-between [start? pred? stop?]
(fn [rf]
(let [drop? (volatile! false)]
(fn
([] (rf))
([result] (rf result))
([result input]
(when (stop? input)
(vreset! drop? false))
(when (start? input)
(vreset! drop? true))
(if (and @drop? (pred? input))
result
(rf result input)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment