Module coil-stdlib

collections::vec

These are free functions that take the vector first: map(xs, f). The methods on Vec itself (push, pop, len, …) are in the prelude.

Part of coil-stdlib. spool projects get it automatically; with plain coil, pass --root ~/.coil/stdlib/src.

Import what you use (use path::* is not allowed):

use collections::vec::{Partitioned, fold_int};

Types#

NameDescription
PartitionedTwo-bucket result of partition (matched = pred true, rest = pred false).

Functions#

NameDescription
fold_intThe same as fold; kept for older code.
containsReturns true when needle is in xs.
index_ofReturns the index of the first needle in xs, or -1.
binary_searchFinds needle in the ascending vector xs by halving, and returns an index holding it.
dedupReturns xs with runs of equal neighbours collapsed to one value.
mapReturns a new vector with mapper applied to each element, in order.
filterReturns the elements for which pred is true, in order.
firstReturns the first element, or None when xs is empty.
lastReturns the last element, or None when xs is empty.
concatReturns a new vector holding the elements of a followed by those of b.
chunksConsecutive non-overlapping slices of size (last slice may be short).
windowsOverlapping sliding windows of exact size.
partitionSplit xs into (matched, rest) by pred.
foldCombines the elements left to right: starts from init and replaces the accumulator with folder(acc)(x) for each x.
↑ ↓ navigate ↵ open