user=> (def boring (constantly 10)) #'user/boring user=> (boring 1 2 3) 10 user=> (boring) 10 user=> (boring "Is anybody home?") 10
;; A really goofy way to find the size of a collection user=> (reduce + (map (constantly 1) [:a :b :c])) 3
(defn constantly "Returns a function that takes any number of arguments and returns x." {:added "1.0" :static true} [x] (fn [& args] x))
Comments top
No comments for constantly. Log in to add a comment.