Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@TheSeamau5
Last active November 6, 2019 11:01
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 TheSeamau5/b98f880af560c238e183fd11769fddce to your computer and use it in GitHub Desktop.
Save TheSeamau5/b98f880af560c238e183fd11769fddce to your computer and use it in GitHub Desktop.
Evaluate a function with given parameters
macro eval_with_params(expr, params...)
# Put the params before the expression
expr_with_params = [collect(params)..., expr]
# Wrap the expressions in :block Expressions
Expr(:block, expr_with_params...)
end
@eval_with_params(
x + y,
x = 1,
y = 5
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment