(let [xparir-transform (fn [{:keys [initial-value transform-fn]}] | |
(fn [rf] | |
(let [old (volatile! initial-value)] | |
(fn | |
([] (rf)) | |
([result] (rf result)) | |
([result input] | |
(let [new (transform-fn input @old)] | |
(vreset! old input) | |
(rf result new)))))))] | |
(sequence (xparir-transform {:initial-value [] | |
:transform-fn (fn [current prev] | |
(let [eq? (= (last current) | |
(last prev))] | |
(conj current (not eq?))))}) | |
[[1] [2] [2] [2] [3] [4]])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment