Skip to content

Instantly share code, notes, and snippets.

@luxbock
Last active August 29, 2015 14:00
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 luxbock/11249913 to your computer and use it in GitHub Desktop.
Save luxbock/11249913 to your computer and use it in GitHub Desktop.
user> (defmacro fundef [a b]
`(defn ~(symbol (str "plus-" a "-" b)) [arg#] (+ ~a ~b arg#)))
#'user/fundef
user> (fundef 1 2)
#'user/plus-1-2
user> (plus-1-2 3)
6
user> (map #(fundef %1 %2) (range 3) (range 3))
(#'user/plus-p1__10068#-p2__10069# #'user/plus-p1__10068#-p2__10069# #'user/plus-p1__10068#-p2__10069#)
user> (plus-0-0 1)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: plus-0-0 in this context, compiling:(/private/var/folders/j2/zvt92c1s39d_0kdmhrhbgtkm0000gn/T/form-init2306553905059976750.clj:1:1)
user>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment