Dispatch on size of MVectors

you can’t do computation within type parameters, Julia does NOT have dependent types; here’s a hack:

julia> for M = 0:10
           @eval f(x::MVector{$M,T}) where {T} = "less than 10"
       end

julia> f(@MVector [1,2,3,4,5,6,7,8,9,10,11])
"This is the fallback generic function"

julia> f(@MVector [1,2,3,4,5,6,7,8,9])
"less than 10"
1 Like