Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@noisesmith
Forked from dabd/gist:7700137
Last active December 29, 2015 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save noisesmith/7700208 to your computer and use it in GitHub Desktop.
Save noisesmith/7700208 to your computer and use it in GitHub Desktop.
(defn best
[f [h & t]]
(reduce #(if (f %1 %2) %1 %2) h t))
(defn most
[f [h & t :as 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])))
[h (f h)]
t)
[nil nil]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment