Skip to content

Instantly share code, notes, and snippets.

@alco
Last active August 29, 2015 14:05
Show Gist options
  • Save alco/cfcd38b6b930192d14a3 to your computer and use it in GitHub Desktop.
Save alco/cfcd38b6b930192d14a3 to your computer and use it in GitHub Desktop.
vars = ...
ignored_vars = ...
quote bind_quoted: [name: name, body: Macro.escape(body)] do
name = String.to_atom(name)
# This unquote is deferred for later, but unquote_splicing needs to be run
def unquote(name)(0, result, unquote_splicing(ignored_vars)) do
result
end
# Same here
def unquote(name)(n, _, unquote_splicing(vars)) do
unquote(name)(n-1, unquote(body), unquote_splicing(vars))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment