How can I write a function that accepts arrays of arbitrary size, provided they are of rank 1?
This is exactly what the intrinsic function shape can do, so I don't think my request is too demanding.
Actually, the function shape does more. It can (obviously) accept array of any shape, that is arbitrary rank and arbitrary length along each dimension.
This question is aimed to write a function sub2ind which corresponds to the MATLAB function of the same name.