Skip to content

Instantly share code, notes, and snippets.

@amalloy
Created November 25, 2011 22:02
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 amalloy/1394517 to your computer and use it in GitHub Desktop.
Save amalloy/1394517 to your computer and use it in GitHub Desktop.
(defmacro defcurried [name args & body]
`(def ~name
~(reduce (fn [body arg]
`(fn [~arg]
~body))
(cons `do body)
(reverse args))))
user> (macroexpand '(defcurried foo [x y] (+ x y)))
(def foo
(fn [x]
(fn [y]
(do (+ x y)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment