Skip to content

Instantly share code, notes, and snippets.

@robertpfeiffer
Created December 1, 2008 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertpfeiffer/30774 to your computer and use it in GitHub Desktop.
Save robertpfeiffer/30774 to your computer and use it in GitHub Desktop.
(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