Skip to content

Instantly share code, notes, and snippets.

@samrat
Last active January 1, 2016 22:19
Show Gist options
  • Save samrat/8209544 to your computer and use it in GitHub Desktop.
Save samrat/8209544 to your computer and use it in GitHub Desktop.
(defn max-key-val
"Like max-key, but returns [x (f x)] for which (f x) is greatest"
[f & args]
(let [z (zipmap args (map f args))]
(reduce (fn [max i]
(if (> (second i) (second max))
i
max))
(first z)
(rest z))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment