Created
July 9, 2010 10:16
-
-
Save abhin4v/469317 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 capitalize [#^String s] | |
"capitalizes String s" | |
(if (and s (not (zero? (count s)))) | |
(apply str (conj (rest s) (Character/toUpperCase (.charAt s 0)))) | |
s)) | |
(defn trim [s] | |
"trims leading and trailing whitespace in the String s" | |
(let [trim-leading | |
(fn [s] | |
(apply str (drop-while #(Character/isWhitespace %) s))) | |
trim-trailing | |
(fn [s] | |
(let [reverse-str #(apply str (reverse %))] | |
(reverse-str (trim-leading (reverse-str s)))))] | |
(trim-trailing (trim-leading s)))) | |
(defn all-interfaces [#^Class cls] | |
"returns a set of all interfaces implemented by class cls" | |
(let [interfaces (.getInterfaces cls)] | |
(set (apply concat interfaces | |
(map all-interfaces interfaces)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment