Dear all

I come from the R community, and try to switch to Julia )

Assume I have a function f1 (fictive function below)

f1 = function(x, y ; a = 1.5, b = 5)

coef = a * sum(x’y) + b

(coef = coef, mod = 1)

end

where x, y are vectors, e.g.

x = [1, 10, -2] ; y = [.5, 7, 22.3] ;

and that I want to replicate this function over vectors (instead of single elements)

of parameters a and b, for instance

a = [1, 2] ; b = [.5, -.5] ;

Using map, I can do

map((a, b) → f1(x, y ; a = a, b = b), a, b)

or with another syntax

(Julia: Passing keyword arguments to function through the map() function - Stack Overflow)

map(a, b) do a, b

f1(x, y ; a = a, b = b)

end

I can also build the following meta function ‘metaf’ (using the second syntax

since in real I have successive steps in the map)

metaf = function(x, y, fun ; a, b)

map(a, b) do a, b

fun(x, y ; a = a, b = b)

end

end

metaf(x, y, f1 ; a = a, b = b)

What I would like is such a metaf function but being **generic** for any function ‘fun’ that can have

its own arguments (different from ‘a’ and ‘b’ of function ‘f1’ above).

.

Something like

metaf(x, y, fun = f2 ; gamma, alpha, theta)

metaf(x, y, fun = OtherFun ; C)

etc.

Is it possible to do this with map in the previous metaf function?

Or may be map is not the efficient way?

I tried to incorporate things like ‘args…’ in metaf but without success

Thanks for any ideas