Skip to content

std/slice

import "std/slice" as slice;
FunctionResult
isEmpty(values) BoolWhether the slice has no elements
count(values) IntSlice length
first(values) TFirst element
last(values) TLast element
at(values, index) TElement after an explicit bounds check
setAt(values, index, value)Assignment after an explicit bounds check
indexOf(values, needle) IntFirst index, or -1
contains(values, needle) BoolWhether the value occurs
fun total(values: []Int) Int {
if slice.isEmpty(values) { return 0; }
return slice.first(values) + slice.last(values);
}

first, last, at, and setAt call panic when their preconditions are not met.