Hello,
I am wondering whether there is a nice way of passing arguments to a function that is itself an argument to a function. So, currently, I have a piece of code that looks like this:
function func_manip(func)
# Uses the function in some way
end
function linear_func(x, a)
return x*a
end
for i in 0:10
f(x) = linear_func(x, i)
func_manip(f)
end
My guts tells me that this is not the most elegant way of doing this. I was thinking that maybe there would be a way of doing something where instead of defining the f
function, I could simply specify which arguments I pass with the inputted function in func_manip
. So something like:
function func_manip(func)
# Uses the function in some way
end
function linear_func(x, a)
return x*a
end
for i in 0:10
func_manip(f(::, i))
end
Otherwise, I thought about adding another argument to the func_manip
that I would be plugging into func
inside func_manip
, but for the precise application I was working on, it was making the code a bit crowded. Maybe there is another method that essentially does the same thing.
Any help is appreciated!