namespace
List
Operations over []T slices — length, ends access, push/pop, swap, search, and in-place reverse. A slice is a shared growable buffer, so these mutate it in place and every holder sees the change. Arguments are positional.
List.len(s) -> intThe number of elements in a slice.List.push(s, v) -> voidAppend an element to the end of a slice.List.clear(s) -> voidRemove all elements, keeping capacity.List.first(s) -> TThe first element of a slice.List.last(s) -> TThe last element of a slice.List.pop(s) -> TRemove and return the last element.List.swap(s, i, j) -> voidExchange the elements at two indices.List.contains(s, v) -> boolWhether a value appears in a slice.List.index_of(s, v) -> intThe index of a value in a slice, or -1 if absent.List.reverse(s) -> voidReverse the order of a slice in place.List.insert(s, i, v) -> voidInsert an element at an index, shifting the rest up.List.remove_at(s, i) -> voidRemove the element at an index, shifting the rest down.List.remove(s, v) -> voidRemove the first element equal to a value.List.sort(s) -> voidSort a slice in ascending order, in place.List.sort_by(s, key) -> voidSort a slice ascending by a key each element maps to.List.sort_desc_by(s, key) -> voidSort a slice descending by a key each element maps to.List.sort_with(s, cmp) -> voidSort a slice with a full two-argument comparator.List.sample(pool, count) -> []intRandom picks from an int slice, distinct while it can.