summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Hickey <richhickey@gmail.com>2009-08-29 10:59:08 -0400
committerRich Hickey <richhickey@gmail.com>2009-08-29 10:59:08 -0400
commit5ca86e045bd5742566c647dcc46b8e546a6a7c06 (patch)
treec8e429878093db17b926aecf5ef1ead1c9897305
parent646aa1260bbc82472f64d2867a3ec961c8b678b2 (diff)
added arity overloads to apply
-rw-r--r--src/clj/clojure/core.clj17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj
index da57823d..1666d4d1 100644
--- a/src/clj/clojure/core.clj
+++ b/src/clj/clojure/core.clj
@@ -396,8 +396,9 @@
:else (cons (first arglist) (spread (next arglist)))))
(defn list*
- "Creates a new list containing the items prepended to the rest, the last of which will be treated as a sequence."
- ([args] args)
+ "Creates a new list containing the items prepended to the rest, the
+ last of which will be treated as a sequence."
+ ([args] (seq args))
([a args] (cons a args))
([a b args] (cons a (cons b args)))
([a b c args] (cons a (cons b (cons c args))))
@@ -407,8 +408,16 @@
(defn apply
"Applies fn f to the argument list formed by prepending args to argseq."
{:arglists '([f args* argseq])}
- [#^clojure.lang.IFn f & args]
- (. f (applyTo (spread args))))
+ ([#^clojure.lang.IFn f args]
+ (. f (applyTo (seq args))))
+ ([#^clojure.lang.IFn f x args]
+ (. f (applyTo (list* x args))))
+ ([#^clojure.lang.IFn f x y args]
+ (. f (applyTo (list* x y args))))
+ ([#^clojure.lang.IFn f x y z args]
+ (. f (applyTo (list* x y z args))))
+ ([#^clojure.lang.IFn f a b c d & args]
+ (. f (applyTo (cons a (cons b (cons c (cons d (spread args)))))))))
(defn vary-meta
"Returns an object of the same type and value as obj, with