Created
November 8, 2018 18:43
-
-
Save souenzzo/6502f968e3687265af133667b1f1253d 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 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