Is there an elegant and short way to write the functions that are written below in one go, in a single definition? So that the function operates on an array with flexible number of dimensions, adding the :s as needed? Ideally, so that it also with N dimensions.
ind = 1:5
view_something(A::AbstractArray{T,1}, ind) where {T} = view(A, ind)
view_something(A::AbstractArray{T,2}, ind) where {T} = view(A, :, ind)
view_something(A::AbstractArray{T,3}, ind) where {T} = view(A, :, :, ind)
view_something(rand(10,10,10), ind)
view_something(rand(10,10), ind)
view_something(rand(10), ind)
I noticed that one can call the Colon operator and assemble func args in a vector like that [Colon(),Colon(),...], is this the way to go or are there other ways that are preferred?