I have the following problem. I have a function foo(x; y = 1) and would like to obtain a function that calls foo while keeping x constant, but still allows me to specify different values for y. I would like something like:
PSEUDOCODE:
foo(x; y = 1) = x + y
x = 1
foo_closure( ; y = 1) = foo(x; y = 1)
foo_closure() -> 2
foo_closure(y = 1) -> 2
foo_closure(y = 2) -> 3
Is this possible?
The reason I want this is that I can broadcast over y
I have one more question. Using the example from above, I would like to broadcast over a different values for the keyword argument.
# Create a function with one kwarg
foo(x; y = 1) = x .+ y
# Fix x
x = 1
# Define closure
foo_closure(; kwargs...) = foo(x; kwargs...)
# Create range of values I want to broadcast over
test_var = range(0, stop = 1, length = 2)