Skip to content

Instantly share code, notes, and snippets.

@souenzzo souenzzo/xform.clj
Created May 31, 2019

Embed
What would you like to do?
(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
You can’t perform that action at this time.