Skip to content

Instantly share code, notes, and snippets.

@abhin4v
Created July 9, 2010 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abhin4v/469317 to your computer and use it in GitHub Desktop.
Save abhin4v/469317 to your computer and use it in GitHub Desktop.
(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