update : f.(x) syntax has been merged and is available in julia v0.5, see document or WIP .
@ vectorize_1arg in julia Base can make arrays acceptable by your functions. Wrap your h so this macro can solve the problem.
Here is an example from julia document
julia> square(x) = x^2 square (generic function with 1 method) julia> @vectorize_1arg Number square square (generic function with 4 methods) julia> methods(square) # 4 methods for generic function "square": square{T<:Number}(::AbstractArray{T<:Number,1}) at operators.jl:380 square{T<:Number}(::AbstractArray{T<:Number,2}) at operators.jl:381 square{T<:Number}(::AbstractArray{T<:Number,N}) at operators.jl:383 square(x) at none:1 julia> square([1 2 4; 5 6 7]) 2x3 Array{Int64,2}: 1 4 16 25 36 49
If you are looking for a more โelegantโ method, here is a discussion about adding new grammars for this problem.
source share