Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
(defn stateful-filter [pred event-key cache events]
(when (seq events)
(let [event (first events)
ekey (event-key event)]
(if (pred (get cache ekey) event)
(cons event (stateful-filter pred event-key
(assoc cache ekey event) (rest events)))
(stateful-filter pred event-key cache (rest events)))))))
#(or (nil? %1)
(nil? %2)
(> (- (second %2) (second %1)) 10))
'[[a 1] [b 2] [a 3] [b 5] [a 11] [a 12] [b 13] [a 14] [b 16]])
;=> ([a 1] [b 2] [a 12] [b 13])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment