Skip to content

Instantly share code, notes, and snippets.

@mishok13
Last active August 29, 2015 14:09
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 mishok13/d66156a6bf45f83c7247 to your computer and use it in GitHub Desktop.
Save mishok13/d66156a6bf45f83c7247 to your computer and use it in GitHub Desktop.
Banging my head, how to make this macro behave the same way regardless of what is passed?
user> (require '[plumbing.core :refer [fnk]])
nil
user> (defmacro fnk-creator
[args]
`(fnk [~@(map symbol (:params args))] [~@(map symbol (:params args))]))
#'user/fnk-creator
user> (def x {:params ["foo"]})
#'user/x
user> (macroexpand-1 '(fnk-creator x))
(plumbing.core/fnk [] [])
user> (macroexpand-1 '(fnk-creator {:params ["foo"]}))
(plumbing.core/fnk [foo] [foo])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment