diff --git a/src/main/cljs/cljs/core.cljs b/src/main/cljs/cljs/core.cljs index c5d186689..e0cef9cc0 100644 --- a/src/main/cljs/cljs/core.cljs +++ b/src/main/cljs/cljs/core.cljs @@ -4462,7 +4462,11 @@ reduces them without incurring seq initialization" (defn constantly "Returns a function that takes any number of arguments and returns x." - [x] (fn [& args] x)) + [x] (fn + ([] x) + ([_] x) + ([_ _] x) + ([_ _ & args] x))) (defn comp "Takes a set of functions and returns a fn that is the composition diff --git a/src/test/cljs/cljs/other_functions_test.cljs b/src/test/cljs/cljs/other_functions_test.cljs index 52b2736f6..eb4209492 100644 --- a/src/test/cljs/cljs/other_functions_test.cljs +++ b/src/test/cljs/cljs/other_functions_test.cljs @@ -96,9 +96,14 @@ (deftest test-constantly (let [c0 (constantly 10)] (are [x] (= 10 (c0 x)) - nil - 42 - "foo"))) + nil + 42 + "foo") + (are [x] (= 10 (c0 x :a :b :c)) + nil + 42 + "foo"))) + ;juxt (deftest test-juxt