This macro is deprecated - it may be removed in a future version of Harlowe.

(subarray: Array, Number, Number) → Array

When given an array, this returns a new array containing only the elements whose positions are between the two number, inclusively.

Example usage:

(subarray: $a, 3, 4) is the same as $a's (a:3,4)


You can obtain subarrays of arrays without this macro, by using the 's or of syntax along with an array of positions. For instance, $a's (range:4,12) obtains a subarray of $a containing its 4th through 12th values. But, for compatibility with previous Harlowe versions which did not feature this syntax, this macro also exists.


If you provide negative numbers, they will be treated as being offset from the end of the array - -2 will specify the 2ndlast item, just as 2 will specify the 2nd item.

If the last number given is larger than the first (for instance, in (subarray: (a:1,2,3,4), 4, 2)) then the macro will still work - in that case returning (a:2,3,4) as if the numbers were in the correct order.

See also:

(substring:), (rotated:)