Skip to content

Instantly share code, notes, and snippets.

@vinayh
Created July 4, 2015 18:38
Show Gist options
  • Save vinayh/cd6ab88c40580aa21a93 to your computer and use it in GitHub Desktop.
Save vinayh/cd6ab88c40580aa21a93 to your computer and use it in GitHub Desktop.
Source of apply
(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