Futhark arrays are written as values enclosed in square brackets.
def arr = [1,2,3]
The type of
i32 to be pedantic). The element type of an array can be another array:
def marr = [[1,2,3], [4,5,6]]
The type of
i32. Arrays must be regular, meaning that all elements must have the same shape. An array such as
[[1,2],  is illegal.
Arrays can be indexed from zero:
def first = arr
def tail = arr[1:]
We can even slice or index only some dimensions:
def innermost = marr[:,1:2]
[, ]. Slices are inclusive in the starting position and exclusive in the ending position as Dijkstra wills it.
Strides are also supported. Generally, The expression
a[i:j:s] returns a slice of the array
a from index
i (inclusive) to
j (exclusive) with a stride of
s. If the stride is positive, then
i <= j must hold, and if the stride is negative, then
j <= i must hold. For example, we can reverse an array like this:
def arr_reversed = arr[::-1]
Some syntactic sugar is provided for concisely specifying arrays of intervals of integers. The expression
x...y produces an array of the integers from
y, both inclusive. The upper bound can be made exclusive by writing
x..<y. For example:
def arr_range = 1...3
It is usually necessary to enclose a range expression in parentheses, because they bind very loosely. A stride can be provided by writing
x..y...z, with the interpretation “first
y, up to
z”. For example:
def strided = 1..3...7
[1, 3, 5, 7].
Reference manual: slicing.