I'm learning OCaml, and one thing that I have not been able to discover how to do is taking a slice of an array. For example, if I want to extract the subarray of 3 elements starting from index 2, I have to do: [|array.(2); array.(3); array.(4)|]
. This gets tedious. Is there any function that can easily and quickly give an array slice? If not, how would I go about rolling my own function for such behaviour?
Really appreciate the help, thanks!
Array.sub is easier to use than blit :
Array.sub a
start len returns a fresh array of length len,containing the elements number start to start + len - 1 of array a.