Apply function array over data array

I have an array of functions and an array of numerical data. I’d like to just apply the functions over the data and return the results in an array. I ended up creating a helper function and use the dot-notation to run them all… it works but it just seems a bit awkward. Perhaps there’s a simpler way?

julia> x = [1,2,3]
3-element Array{Int64,1}:
 1
 2
 3

julia> f = [x -> x, x -> x^2, x -> x^3]
3-element Array{Function,1}:
 #5
 #6
 #7

julia> g(f, x) = f(x)
g (generic function with 1 method)

julia> g.(f, x)
3-element Array{Int64,1}:
  1
  4
 27

map.(f,x)

4 Likes