I'm no Clojure guru, but why not just use set?
http://grimoire.arrdem.com/1.6.0/clojure.core/set/

But you want to get rid of the timestamp. Using map is probably right for 
that. So I think this is more idiomatic...

(defn only-keep-unique-ids [ids]
  (set (map #(get-form-id-without-timestamp %) ids)))

- boz


On Friday, July 25, 2014 2:32:43 PM UTC-7, Christopher Elwell wrote:
>
> 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 clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to