This is a somewhat unusual usage, but I’m wondering if given

julia> M = [sin cos; cos sin]
2×2 Matrix{Function}:
sin cos
cos sin

is there an easy way to broadcast the function evaluation over the elements for one specific argument? I want the result

julia> [x(pi/3) for x in M]
2×2 Matrix{Float64}:
0.866025 0.5
0.5 0.866025

except using the broadcasting syntax instead of a comprehension. I thought that it’ll be something like

julia> getindex.(Ref(M), CartesianIndices(M)).(pi/3)
ERROR: MethodError: objects of type Matrix{Function} are not callable
Use square brackets [] for indexing an Array.

Oh I never realized map returns a Number if given a Number, good to know! Bear in mind this doesn’t work for scalars in general, map falls back to expecting an iterable:

julia> map(sin, pi/3)
0.8660254037844386
julia> struct A end
julia> f(::A) = 1
f (generic function with 1 method)
julia> map(f, A())
ERROR: MethodError: no method matching length(::A)