Last active
November 6, 2019 11:01
-
-
Save TheSeamau5/b98f880af560c238e183fd11769fddce to your computer and use it in GitHub Desktop.
Evaluate a function with given parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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