Created
April 4, 2011 19:32
-
-
Save amalloy/902251 to your computer and use it in GitHub Desktop.
Gisted version of jsa's comment on What is Clojure
This file contains hidden or 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 largest-size [kfn l item] | |
| (if (empty? l) | |
| item | |
| (if (nil? item) | |
| (recur kfn (next l) (first l)) | |
| (let [f (first l)] | |
| (recur kfn | |
| (next l) | |
| (if (> (kfn f) (kfn item)) f item)))))) | |
| (largest-size identity '(1 3 8 5 77 33 3 99 22) nil) | |
| => 99 | |
| (largest-size identity [1 3 8 5 77 33 3 99 22] nil) | |
| => 99 | |
| (largest-size val {:one 1 :two 3 :three 8 :four 5 :five 77 :six 33 :seven 3 :eight 99 :nine 22} nil) | |
| => [:eight 99] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment