Some equivalent of a simple example like this?
last [a, b] would return ``b``
first (_, +,+, x) would return `` _ ``
I assume seq would most likely be involved in achieving this, but how ?
Thanks,
like this?
let arr = ["foo", "baa", "baz"]
assert arr[0] == "foo"
assert arr[^1] == "baz"
But note that Nim arrays don't have to start at index zero:
type
A = array[-3 .. 4, int]
var a: A
echo A.low, " ", A.high
echo a.low, " ", a.high
a = [1, 2, 3, 4, 5, 6, 7, 8]
echo a[a.low], " ", a[a.high]
echo a[0], " ", a[^1]
-3 4
-3 4
1 8
4 8
Nim sequences and openArray parameters have indeed always lowest index zero.