El sábado, 16 de mayo de 2015, 18:26:48 (UTC-5), Eka Palamadai escribió:
>
> I am trying to write a function f1 that takes a function f2 and arguments
> of f2 as parameters,
> modifies some arguments of f2, and calls f2 with the modified arguments.
>
> function f1(f2::Function, args...)
> #iterate through the args and modify some of the contents of args
> f2(args)
> end
>
Depending on what you mean by "modifying", you don't need metaprogramming
for this.
For example:
modify(x::Int) = 2x
modify(x::Float64) = 3x
function f1(args...)
new_args = [modify(arg) for arg in args]
f2(new_args...)
end
function f2(a, b)
@show a, b
end
f1(2, 3.5)
This gives
(4,10.5)
David.
>
> Any suggestions on how to do this?
>
> Thanks.
>
>
>
>
>
>
>