New to Clojure, how is this function that I wrote? Any suggestions for
improvement; is it too complicated?
It filters a sequence, leaving only the first occurrence of each item in
the seq that has a matching prefix (get-form-id-without-timestamp gets just
the id prefix).
(defn only-keep-unique-ids [ids]
(let [seen-ids (atom #{})
filter-fn #(let [raw-form-id (get-form-id-without-timestamp %)
is-unique (not (contains? @seen-ids raw-form-id))]
(do (swap! seen-ids conj raw-form-id)
is-unique))]
(filter filter-fn ids)))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.