diff options
author | Rich Hickey <richhickey@gmail.com> | 2009-08-29 10:31:08 -0400 |
---|---|---|
committer | Rich Hickey <richhickey@gmail.com> | 2009-08-29 10:31:08 -0400 |
commit | a2f8dcd6bd9c2ed9e50bd473ec9a3d9b4f7428de (patch) | |
tree | 8943e540039dd93ac8b624088e05212a81c8e261 /src | |
parent | b942b1758040f3f96dacb7e0cecb148913ba5f1e (diff) |
added arity overloads to comp
Diffstat (limited to 'src')
-rw-r--r-- | src/clj/clojure/core.clj | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/clj/clojure/core.clj b/src/clj/clojure/core.clj index 992989e5..587e0953 100644 --- a/src/clj/clojure/core.clj +++ b/src/clj/clojure/core.clj @@ -1508,13 +1508,28 @@ of those fns. The returned fn takes a variable number of args, applies the rightmost of fns to the args, the next fn (right-to-left) to the result, etc." - [& fs] - (let [fs (reverse fs)] + ([f] f) + ([f g] + (fn + ([] (f (g))) + ([x] (f (g x))) + ([x y] (f (g x y))) + ([x y z] (f (g x y z))) + ([x y z & args] (f (apply g x y z args))))) + ([f g h] + (fn + ([] (f (g (h)))) + ([x] (f (g (h x)))) + ([x y] (f (g (h x y)))) + ([x y z] (f (g (h x y z)))) + ([x y z & args] (f (g (apply h x y z args)))))) + ([f1 f2 f3 & fs] + (let [fs (reverse (list* f1 f2 f3 fs))] (fn [& args] (loop [ret (apply (first fs) args) fs (next fs)] (if fs (recur ((first fs) ret) (next fs)) - ret))))) + ret)))))) (defn partial "Takes a function f and fewer than the normal arguments to f, and |