Created
November 29, 2013 00:56
-
-
Save dabd/7700137 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn best | |
[f coll] | |
(if (seq coll) | |
(reduce #(if (f %1 %2) %1 %2) coll) | |
nil)) | |
(defn most | |
[f coll] | |
(if (seq coll) | |
(reduce (fn [[wins wins-score] x] | |
(let [x-score (f x)] | |
(if (> wins-score x-score) | |
[wins wins-score] | |
[x x-score]))) | |
[(first coll) (f (first coll))] (rest coll)) | |
[nil nil])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment