Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
(defn stateful-filter [pred event-key cache events]
(lazy-seq
(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)))))))
(stateful-filter
#(or (nil? %1)
(nil? %2)
(> (- (second %2) (second %1)) 10))
first
{}
'[[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
Something went wrong with that request. Please try again.