Performance tips on turning arrays into tuples

I think I formulated wrongly the question. indexes[i] is necessarily a vector there, which has to be preallocated, meaning, that is something like

vec = [1,2,3,4,5]
indices = [2,3]
vec[indices]
#or
vec[ [2,3] ]

Is there a syntax that allows that without allocating the intermediate indices vector?

1 Like