(defn new-gen [a]
(distinct #(= (:val %1) (:val %2))
(for [f a
n [(transform-left f) (transform-right f)]
:when (not (contains? #(= (:val n) %) (map :val (parents n))))]
n)))
is more functional but possibly slower.
If you really just want the first one in traversal order with each
distinct value, though, you could just use
(defn new-gen [a]
(distinct #(= (:val %1) (:val %2))
(apply concat
(for [f a]
[(transform-left f) (transform-right f)]))))
which makes distinct do all the heavy lifting (the whole rest of it is
just the traversal).
--
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