On Fri, 25 Jul 2014, Richard Barker wrote:

> Using partition-by will give you a lazy sequence.
> 
> (defn only-keep-unique-ids [ids]
>   (map first (partition-by #(get-form-id-without-timestamp %) ids)))

This will only work if all entries with the same calculated key are
contiguous.

user> (defn prefix [st] (subs st 0 3))
user> (defn firsts-of-partitions [f coll]                                       
                                   
        (map first (partition-by f coll)))
user> (firsts-of-partitions prefix ["foobar" "foobaz" "wombat" "womble"])
("foobar" "wombat")
user> (firsts-of-partitions prefix ["foobar" "wombat" "foobaz" "womble"])
("foobar" "wombat" "foobaz" "womble")

Paul

-- 
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