Yeah, golfing at late night..

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

(defn new-gen
  [a]
  (->> a
    (mapcat (juxt transform-left transform-right))
    (remove (fn [n] (some #(= (:val n) (:val %)) (parents n))))
    (distinct-by :val)))

I modified your distinct to not capture a core name. Also it now exploits that 
seen is a set. Also your contains? is called some.

Hope this helps.

Sincerely
Meikel

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

Reply via email to