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#
| Name | Description |
|---|---|
Partitioned | Two-bucket result of partition (matched = pred true, rest = pred false). |
Functions#
| Name | Description |
|---|---|
fold_int | The same as fold; kept for older code. |
contains | Returns true when needle is in xs. |
index_of | Returns the index of the first needle in xs, or -1. |
binary_search | Finds needle in the ascending vector xs by halving, and returns an index holding it. |
dedup | Returns xs with runs of equal neighbours collapsed to one value. |
map | Returns a new vector with mapper applied to each element, in order. |
filter | Returns the elements for which pred is true, in order. |
first | Returns the first element, or None when xs is empty. |
last | Returns the last element, or None when xs is empty. |
concat | Returns a new vector holding the elements of a followed by those of b. |
chunks | Consecutive non-overlapping slices of size (last slice may be short). |
windows | Overlapping sliding windows of exact size. |
partition | Split xs into (matched, rest) by pred. |
fold | Combines the elements left to right: starts from init and replaces the accumulator with folder(acc)(x) for each x. |