Skip to content

Instantly share code, notes, and snippets.

@pbalduino
Created April 4, 2013 14:26
Show Gist options
  • Save pbalduino/5310785 to your computer and use it in GitHub Desktop.
Save pbalduino/5310785 to your computer and use it in GitHub Desktop.
Type hint in Clojure
(defn len [x]
(.length x))
(defn len2 [^String x]
(.length x))
(time (reduce + (map len (repeat 1000000 "asdf"))))
; "Elapsed time: 8711.592674 msecs"
(time (reduce + (map len2 (repeat 1000000 "asdf"))))
; "Elapsed time: 838.759954 msecs"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment