Hi,

On 9 Nov., 02:42, Greg <g...@kinostudios.com> wrote:

> The only thing is that while your distinct-by function doesn't seem to work...

Bleh. :( It *was* late in the night...

(defn distinct-by
  [keyfn coll]
  (let [step (fn step [xs seen]
    (lazy-seq
      ((fn [[f :as xs] seen]
         (when-let [s (seq xs)]
           (let [k (keyfn f)]
             (if (contains? seen k)
               (recur (rest s) seen)
               (cons f (step (rest s) (conj seen k)))))))
       xs seen)))]
  (step coll #{})))

Now this should do the trick. Of course we have to conj the key value
as it is returned by the keyfn. Otherwise compare apples with the
fruit truck.

Sincerely
Meikel

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

Reply via email to