Created
December 1, 2008 17:30
-
-
Save robertpfeiffer/30774 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 curryfun [arity fun] | |
(fn [& args] | |
(let [argcount (count args)] | |
(cond (= arity argcount) | |
(apply fun args) | |
(< argcount arity) | |
(curryfun (- arity argcount) | |
(fn [& args2] (apply fun (concat args args2)))) | |
(> argcount arity) | |
(apply (apply fun (take arity args)) | |
(drop arity args)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment