On 28 Gru, 20:57, Robert Campbell <[email protected]> wrote:
> How might I add a third and final condition, where those candidates
> with equal scores AND equal counts are all returned together?
Reduce can work with functions like
f : x * y -> x
So we can modify function closest to be like that (untested):
(closest [ v1s v2]
(if (empty v1s)
v2
(cond
(and (= (matching (first v1s)) (matching v2))
(= (count (first v1s)) (count v2))) (into
v1s v2))
(or (> (matching (first v1s)) (matching v2))
(and (= (matching (first v1s)) (matching v2))
(< (count (first v1s)) (count v2))))
[v1]
:else [v2])))
Also, we use matching on the same arguments a lot, so it would be good
to memoize that function.
--
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