Created
April 1, 2015 23:53
-
-
Save purplejacket/36de7061061ec9c49734 to your computer and use it in GitHub Desktop.
The Clojure apply function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn apply | |
"Applies fn f to the argument list formed by prepending intervening arguments to args." | |
{:added "1.0" | |
:static true} | |
([^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))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment