Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Last active October 25, 2016 18: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 shankardevy/b1b84032e3a22e1863444b69453a4f0d to your computer and use it in GitHub Desktop.
Save shankardevy/b1b84032e3a22e1863444b69453a4f0d to your computer and use it in GitHub Desktop.
Generating functions based on macro
defmodule LearnMacro do
defmacro gen_func(func_name, arguments, do: expression) do
quote do
def unquote(:"#{func_name}")(unquote_splicing(arguments)), do: unquote(expression)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment