# List

{/* Generated from types/std.Rtypes by `just docs-std`. Do not edit this file. */}

Functions over `List<T>`, ry's ordered sequence of values of one type. `[1, 2, 3]` builds a
list, and `List.from_r` converts an R vector or list. A function whose result items come from a
callback, such as `List.map`, requires them to be ry values (the
[`item` constraint](/reference/type-system.md#constraints)), so `List.map([1, 2], \(x) list(x))` is
a type error.

```
@type List<T>
```

| Function | Summary |
| --- | --- |
| [`List.from_r`](#listfrom_r) | Converts an R vector or list into a `List`, checking every item: it refuses `NA`, a classed object and a ragged list, and drops names. |
| [`List.to_r`](#listto_r) | Converts a `List` into the R vector it shares a representation with. |
| [`List.len`](#listlen) | The number of elements. |
| [`List.is_empty`](#listis_empty) | Whether the list has no elements. |
| [`List.get`](#listget) | The element at a 1-based position, or `:Err(:OutOfBounds)`. |
| [`List.set`](#listset) | Replaces the element at a position; a position out of range leaves the list unchanged. |
| [`List.update`](#listupdate) | Replaces the element at a position with `f` of it. |
| [`List.append`](#listappend) | Adds an element at the end. |
| [`List.prepend`](#listprepend) | Adds an element at the start. |
| [`List.concat`](#listconcat) | The elements of `first` followed by those of `second`. |
| [`List.single`](#listsingle) | A list of one element. |
| [`List.repeat`](#listrepeat) | A list of `count` copies of `value`. |
| [`List.range`](#listrange) | The integers from `start` up to and including `end`, or an empty list when `end` is smaller. |
| [`List.reverse`](#listreverse) | The elements in reverse order. |
| [`List.join`](#listjoin) | Concatenates a list of lists. |
| [`List.map`](#listmap) | Applies `f` to every element. |
| [`List.map_with_index`](#listmap_with_index) | Applies `f` to every element and its 1-based position. |
| [`List.map2`](#listmap2) | Applies `f` to the elements of two lists pairwise, stopping at the shorter one. |
| [`List.map3`](#listmap3) | Applies `f` to the elements at each position of three lists, up to the shortest one. |
| [`List.map4`](#listmap4) | Applies `f` to the elements at each position of four lists, up to the shortest one. |
| [`List.join_map`](#listjoin_map) | Applies `f`, which returns a list, to every element and concatenates the results. |
| [`List.keep_if`](#listkeep_if) | The elements for which `predicate` is `TRUE`. |
| [`List.keep_if_try`](#listkeep_if_try) | The elements for which `predicate` returns `:Ok(TRUE)`, or the first `:Err` it returns. |
| [`List.drop_if`](#listdrop_if) | The elements for which `predicate` is `FALSE`. |
| [`List.keep_oks`](#listkeep_oks) | Applies `f` to every element and keeps the `:Ok` values. |
| [`List.keep_errs`](#listkeep_errs) | Applies `f` to every element and keeps the `:Err` values. |
| [`List.map_try`](#listmap_try) | Applies `f` to every element and stops at the first `:Err`. |
| [`List.walk`](#listwalk) | Folds from the first element: `f` gets the state and an element and returns the next state. |
| [`List.walk_backwards`](#listwalk_backwards) | Folds from the last element. |
| [`List.walk_until`](#listwalk_until) | Folds until `f` returns `:Break(state)`; `:Continue(state)` goes on. |
| [`List.walk_backwards_until`](#listwalk_backwards_until) | Folds the list from the last element until `f` returns `:Break(state)`. |
| [`List.walk_with_index`](#listwalk_with_index) | Folds the list, passing `f` each element's 1-based position too. |
| [`List.walk_with_index_until`](#listwalk_with_index_until) | Folds the list with positions until `f` returns `:Break(state)`. |
| [`List.walk_from`](#listwalk_from) | Folds the list from a 1-based position onwards. |
| [`List.walk_from_until`](#listwalk_from_until) | Folds the list from a position until `f` returns `:Break(state)`. |
| [`List.walk_try`](#listwalk_try) | Folds the list while `f` returns `:Ok(state)`, stopping at the first `:Err`. |
| [`List.for_each`](#listfor_each) | Calls `f` on each element for its effect, and returns `NULL` invisibly. |
| [`List.for_each_try`](#listfor_each_try) | Calls `f` on each element, stopping at the first `:Err`. |
| [`List.any`](#listany) | Whether `predicate` is `TRUE` for some element. |
| [`List.all`](#listall) | Whether `predicate` is `TRUE` for every element; `TRUE` for an empty list. |
| [`List.contains`](#listcontains) | Whether some element is `identical()` to `value`. |
| [`List.count_if`](#listcount_if) | The number of elements for which `predicate` is `TRUE`. |
| [`List.find_first`](#listfind_first) | The first element for which `predicate` is `TRUE`, or `:Err(:NotFound)`. |
| [`List.find_last`](#listfind_last) | The last element for which `predicate` is `TRUE`, or `:Err(:NotFound)`. |
| [`List.find_first_index`](#listfind_first_index) | The position of the first match, or `:Err(:NotFound)`. |
| [`List.find_last_index`](#listfind_last_index) | The position of the last match, or `:Err(:NotFound)`. |
| [`List.first`](#listfirst) | The first element, or `:Err(:ListWasEmpty)`. |
| [`List.last`](#listlast) | The last element, or `:Err(:ListWasEmpty)`. |
| [`List.take_first`](#listtake_first) | The first `count` elements, or all of them if there are fewer. |
| [`List.take_last`](#listtake_last) | The last `count` elements. |
| [`List.drop_first`](#listdrop_first) | Everything but the first `count` elements. |
| [`List.drop_last`](#listdrop_last) | Everything but the last `count` elements. |
| [`List.drop_at`](#listdrop_at) | Removes the element at a position. |
| [`List.sublist`](#listsublist) | `count` elements starting at position `start`. |
| [`List.split_at`](#listsplit_at) | The first `count` elements as `before` and the rest as `others`. |
| [`List.split_first`](#listsplit_first) | Splits the list around the first element identical to `delimiter`. |
| [`List.split_last`](#listsplit_last) | Splits the list around the last element identical to `delimiter`. |
| [`List.split_on`](#listsplit_on) | The runs of elements between elements identical to `delimiter`. |
| [`List.split_on_list`](#listsplit_on_list) | The runs of elements between occurrences of the sublist `delimiter`. |
| [`List.chunks_of`](#listchunks_of) | Groups of `size` elements; the last group may be shorter. |
| [`List.intersperse`](#listintersperse) | Puts `separator` between every two elements. |
| [`List.sort_with`](#listsort_with) | A stable sort by `compare`, which returns `:LT`, `:EQ` or `:GT`. |
| [`List.sort_asc`](#listsort_asc) | Sorts numbers from smallest to largest. |
| [`List.sort_desc`](#listsort_desc) | Sorts numbers from largest to smallest. |
| [`List.swap`](#listswap) | Exchanges the elements at two positions; an out-of-range position leaves the list unchanged. |
| [`List.replace`](#listreplace) | Replaces the element at a position, returning the new list and the element it replaced. |
| [`List.append_if_ok`](#listappend_if_ok) | Adds an `:Ok` value at the end; an `:Err` leaves the list unchanged. |
| [`List.prepend_if_ok`](#listprepend_if_ok) | Adds an `:Ok` value at the start; an `:Err` leaves the list unchanged. |
| [`List.concat_utf8`](#listconcat_utf8) | Appends the UTF-8 bytes of a string to a list of bytes. |
| [`List.with_capacity`](#listwith_capacity) | An empty list with room for `capacity` elements, so appending that many never copies. |
| [`List.reserve`](#listreserve) | The list with room for `spare` more elements. |
| [`List.release_excess_capacity`](#listrelease_excess_capacity) | The list with no room beyond its elements, which gives back what `List.reserve` or `List.with_capacity` set aside. |
| [`List.sum`](#listsum) | The sum of the elements; `0L` for an empty list. |
| [`List.product`](#listproduct) | The product of the elements; `1L` for an empty list. |
| [`List.min`](#listmin) | The smallest element, or `:Err(:ListWasEmpty)`. |
| [`List.max`](#listmax) | The largest element, or `:Err(:ListWasEmpty)`. |
| [`List.starts_with`](#liststarts_with) | Whether the list begins with the elements of `prefix`. |
| [`List.ends_with`](#listends_with) | Whether the list ends with the elements of `suffix`. |

## `List.from_r`

### Inline

```r
List.from_r <- function(vector: logical[]) -> List<Bool>
List.from_r <- function(vector: integer[]) -> List<I64>
List.from_r <- function(vector: double[]) -> List<F64>
List.from_r <- function(vector: character[]) -> List<Str>
List.from_r <- function(vector: raw[]) -> List<I64>
List.from_r <- function<T: item>(vector: list[T]) -> List<T>
```

### Comments

```r
#: fn(vector: logical[]) -> List<Bool>
List.from_r <- function(vector)

#: fn(vector: integer[]) -> List<I64>
List.from_r <- function(vector)

#: fn(vector: double[]) -> List<F64>
List.from_r <- function(vector)

#: fn(vector: character[]) -> List<Str>
List.from_r <- function(vector)

#: fn(vector: raw[]) -> List<I64>
List.from_r <- function(vector)

#: <T: item> fn(vector: list[T]) -> List<T>
List.from_r <- function(vector)
```

Converts an R vector or list into a `List`, checking every item: it refuses `NA`, a classed
object and a ragged list, and drops names. A `double` vector becomes a `List<F64>`, an
`integer` or `raw` vector a `List<I64>`, a `logical` vector a `List<Bool>` and a `character`
vector a `List<Str>`.

```r
List.from_r(c(3, 1, 2))
#> [3, 1, 2]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L117)

## `List.to_r`

### Inline

```r
List.to_r <- function(list: List<F64>) -> double[]
List.to_r <- function(list: List<Bool>) -> logical[]
List.to_r <- function(list: List<Str>) -> character[]
List.to_r <- function(list: List<I64>) -> integer[] | double[]
List.to_r <- function<T: item>(list: List<T>) -> list[T]
```

### Comments

```r
#: fn(list: List<F64>) -> double[]
List.to_r <- function(list)

#: fn(list: List<Bool>) -> logical[]
List.to_r <- function(list)

#: fn(list: List<Str>) -> character[]
List.to_r <- function(list)

#: fn(list: List<I64>) -> integer[] | double[]
List.to_r <- function(list)

#: <T: item> fn(list: List<T>) -> list[T]
List.to_r <- function(list)
```

Converts a `List` into the R vector it shares a representation with. A `List<I64>`
becomes an `integer` vector when every item fits in 32 bits and a `double` vector otherwise. A
`List<F64>`, `List<Bool>` or `List<Str>` already passes to R code as a vector without this call.

```r
List.to_r([3i64, 1i64])
#> c(3L, 1L)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L132)

## `List.len`

### Inline

```r
List.len <- function<T>(list: List<T>) -> I64
```

### Comments

```r
#: <T> fn(list: List<T>) -> I64
List.len <- function(list)
```

The number of elements.

```r
List.len(["a", "b"])
#> 2i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L144)

## `List.is_empty`

### Inline

```r
List.is_empty <- function<T>(list: List<T>) -> Bool
```

### Comments

```r
#: <T> fn(list: List<T>) -> Bool
List.is_empty <- function(list)
```

Whether the list has no elements.

```r
List.is_empty([])
#> TRUE
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L152)

## `List.get`

### Inline

```r
List.get <- function<T>(list: List<T>, index: I64) -> Result<T, :OutOfBounds>
```

### Comments

```r
#: <T> fn(list: List<T>, index: I64) -> Result<T, :OutOfBounds>
List.get <- function(list, index)
```

The element at a 1-based position, or `:Err(:OutOfBounds)`.

```r
List.get(["a", "b"], 3)
#> :Err(:OutOfBounds)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L160)

## `List.set`

### Inline

```r
List.set <- function<T>(list: List<T>, index: I64, value: T) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, index: I64, value: T) -> List<T>
List.set <- function(list, index, value)
```

Replaces the element at a position; a position out of range leaves the list unchanged.

```r
List.set(["a", "b"], 2, "z")
#> ["a", "z"]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L168)

## `List.update`

### Inline

```r
List.update <- function<T>(list: List<T>, index: I64, f: fn(T) -> T) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, index: I64, f: fn(T) -> T) -> List<T>
List.update <- function(list, index, f)
```

Replaces the element at a position with `f` of it.

```r
List.update([1, 2], 1, function(x) x + 10)
#> [11i64, 2i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L176)

## `List.append`

### Inline

```r
List.append <- function<T>(list: List<T>, value: T) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, value: T) -> List<T>
List.append <- function(list, value)
```

Adds an element at the end.

```r
List.append([1, 2], 3)
#> [1i64, 2i64, 3i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L184)

## `List.prepend`

### Inline

```r
List.prepend <- function<T>(list: List<T>, value: T) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, value: T) -> List<T>
List.prepend <- function(list, value)
```

Adds an element at the start.

```r
List.prepend([1, 2], 0)
#> [0i64, 1i64, 2i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L192)

## `List.concat`

### Inline

```r
List.concat <- function<T>(first: List<T>, second: List<T>) -> List<T>
```

### Comments

```r
#: <T> fn(first: List<T>, second: List<T>) -> List<T>
List.concat <- function(first, second)
```

The elements of `first` followed by those of `second`.

```r
List.concat([1], [2, 3])
#> [1i64, 2i64, 3i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L200)

## `List.single`

### Inline

```r
List.single <- function<T>(value: T) -> List<T>
```

### Comments

```r
#: <T> fn(value: T) -> List<T>
List.single <- function(value)
```

A list of one element.

```r
List.single("only")
#> ["only"]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L208)

## `List.repeat`

### Inline

```r
List.repeat <- function<T>(value: T, count: I64) -> List<T>
```

### Comments

```r
#: <T> fn(value: T, count: I64) -> List<T>
List.repeat <- function(value, count)
```

A list of `count` copies of `value`.

```r
List.repeat("x", 3)
#> ["x", "x", "x"]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L216)

## `List.range`

### Inline

```r
List.range <- function(start: I64, end: I64) -> List<I64>
```

### Comments

```r
#: fn(start: I64, end: I64) -> List<I64>
List.range <- function(start, end)
```

The integers from `start` up to and including `end`, or an empty list when `end` is smaller.
Unlike R's `:`, it never counts down.

Both `List.range` and `List.repeat` stop with an error when the list would hold more than
2,147,483,647 elements, the longest vector an R integer index reaches.

```r
List.range(2, 5)
#> [2i64, 3i64, 4i64, 5i64]
List.range(3, 1)
#> []
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L230)

## `List.reverse`

### Inline

```r
List.reverse <- function<T>(list: List<T>) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>) -> List<T>
List.reverse <- function(list)
```

The elements in reverse order.

```r
List.reverse([1, 2, 3])
#> [3i64, 2i64, 1i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L238)

## `List.join`

### Inline

```r
List.join <- function<T>(lists: List<List<T>>) -> List<T>
```

### Comments

```r
#: <T> fn(lists: List<List<T>>) -> List<T>
List.join <- function(lists)
```

Concatenates a list of lists.

```r
List.join([[1], [], [2, 3]])
#> [1i64, 2i64, 3i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L246)

## `List.map`

### Inline

```r
List.map <- function<A, B: item>(list: List<A>, f: fn(A) -> B) -> List<B>
```

### Comments

```r
#: <A, B: item> fn(list: List<A>, f: fn(A) -> B) -> List<B>
List.map <- function(list, f)
```

Applies `f` to every element.

```r
List.map([1, 2, 3], function(x) x * 2)
#> [2i64, 4i64, 6i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L254)

## `List.map_with_index`

### Inline

```r
List.map_with_index <- function<A, B: item>(list: List<A>, f: fn(A, I64) -> B) -> List<B>
```

### Comments

```r
#: <A, B: item> fn(list: List<A>, f: fn(A, I64) -> B) -> List<B>
List.map_with_index <- function(list, f)
```

Applies `f` to every element and its 1-based position.

```r
List.map_with_index(["a", "b"], function(x, i) Str.concat(x, Num.to_str(i)))
#> ["a1", "b2"]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L262)

## `List.map2`

### Inline

```r
List.map2 <- function<A, B, C: item>(first: List<A>, second: List<B>, f: fn(A, B) -> C) -> List<C>
```

### Comments

```r
#: <A, B, C: item> fn(first: List<A>, second: List<B>, f: fn(A, B) -> C) -> List<C>
List.map2 <- function(first, second, f)
```

Applies `f` to the elements of two lists pairwise, stopping at the shorter one.

```r
List.map2([1, 2, 3], [10, 20], function(a, b) a + b)
#> [11i64, 22i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L270)

## `List.map3`

### Inline

```r
List.map3 <- function<A, B, C, D: item>(first: List<A>, second: List<B>, third: List<C>, f: fn(A, B, C) -> D) -> List<D>
```

### Comments

```r
#: <A, B, C, D: item> fn(first: List<A>, second: List<B>, third: List<C>, f: fn(A, B, C) -> D) -> List<D>
List.map3 <- function(first, second, third, f)
```

Applies `f` to the elements at each position of three lists, up to the shortest one.

```r
List.map3([1, 2], [10, 20], [100, 200], function(a, b, c) a + b + c)
#> [111i64, 222i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L278)

## `List.map4`

### Inline

```r
List.map4 <- function<A, B, C, D, E: item>(first: List<A>, second: List<B>, third: List<C>, fourth: List<D>, f: fn(A, B, C, D) -> E) -> List<E>
```

### Comments

```r
#: <A, B, C, D, E: item> fn(first: List<A>, second: List<B>, third: List<C>, fourth: List<D>, f: fn(A, B, C, D) -> E) -> List<E>
List.map4 <- function(first, second, third, fourth, f)
```

Applies `f` to the elements at each position of four lists, up to the shortest one.

```r
List.map4([1], [2], [3], [4], function(a, b, c, d) a * b * c * d)
#> [24i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L286)

## `List.join_map`

### Inline

```r
List.join_map <- function<A, B>(list: List<A>, f: fn(A) -> List<B>) -> List<B>
```

### Comments

```r
#: <A, B> fn(list: List<A>, f: fn(A) -> List<B>) -> List<B>
List.join_map <- function(list, f)
```

Applies `f`, which returns a list, to every element and concatenates the results.

```r
List.join_map([1, 2], function(x) [x, x])
#> [1i64, 1i64, 2i64, 2i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L294)

## `List.keep_if`

### Inline

```r
List.keep_if <- function<T>(list: List<T>, predicate: fn(T) -> Bool) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, predicate: fn(T) -> Bool) -> List<T>
List.keep_if <- function(list, predicate)
```

The elements for which `predicate` is `TRUE`.

```r
List.keep_if([1, 5, 2], function(x) x > 1)
#> [5i64, 2i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L302)

## `List.keep_if_try`

### Inline

```r
List.keep_if_try <- function<T, E>(list: List<T>, predicate: fn(T) -> Result<Bool, E>) -> Result<List<T>, E>
```

### Comments

```r
#: <T, E> fn(list: List<T>, predicate: fn(T) -> Result<Bool, E>) -> Result<List<T>, E>
List.keep_if_try <- function(list, predicate)
```

The elements for which `predicate` returns `:Ok(TRUE)`, or the first `:Err` it returns.

```r
List.keep_if_try(["1", "20", "3"], function(s) Result.map(Str.to_i64(s), function(n) n > 2))
#> :Ok(["20", "3"])
List.keep_if_try(["1", "x"], function(s) Result.map(Str.to_i64(s), function(n) n > 2))
#> :Err(:InvalidNumStr)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L312)

## `List.drop_if`

### Inline

```r
List.drop_if <- function<T>(list: List<T>, predicate: fn(T) -> Bool) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, predicate: fn(T) -> Bool) -> List<T>
List.drop_if <- function(list, predicate)
```

The elements for which `predicate` is `FALSE`.

```r
List.drop_if([1, 5, 2], function(x) x > 1)
#> [1i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L320)

## `List.keep_oks`

### Inline

```r
List.keep_oks <- function<A, B: item, E>(list: List<A>, f: fn(A) -> Result<B, E>) -> List<B>
```

### Comments

```r
#: <A, B: item, E> fn(list: List<A>, f: fn(A) -> Result<B, E>) -> List<B>
List.keep_oks <- function(list, f)
```

Applies `f` to every element and keeps the `:Ok` values.

```r
List.keep_oks(["1", "x", "3"], Str.to_i64)
#> [1i64, 3i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L328)

## `List.keep_errs`

### Inline

```r
List.keep_errs <- function<A, B, E: item>(list: List<A>, f: fn(A) -> Result<B, E>) -> List<E>
```

### Comments

```r
#: <A, B, E: item> fn(list: List<A>, f: fn(A) -> Result<B, E>) -> List<E>
List.keep_errs <- function(list, f)
```

Applies `f` to every element and keeps the `:Err` values.

```r
List.keep_errs(["1", "x"], Str.to_i64)
#> [:InvalidNumStr]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L336)

## `List.map_try`

### Inline

```r
List.map_try <- function<A, B: item, E>(list: List<A>, f: fn(A) -> Result<B, E>) -> Result<List<B>, E>
```

### Comments

```r
#: <A, B: item, E> fn(list: List<A>, f: fn(A) -> Result<B, E>) -> Result<List<B>, E>
List.map_try <- function(list, f)
```

Applies `f` to every element and stops at the first `:Err`.

```r
List.map_try(["1", "2"], Str.to_i64)
#> :Ok([1i64, 2i64])
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L344)

## `List.walk`

### Inline

```r
List.walk <- function<T, S>(list: List<T>, state: S, f: fn(S, T) -> S) -> S
```

### Comments

```r
#: <T, S> fn(list: List<T>, state: S, f: fn(S, T) -> S) -> S
List.walk <- function(list, state, f)
```

Folds from the first element: `f` gets the state and an element and returns the next state.

```r
List.walk([1, 2, 3], 0, function(total, x) total + x)
#> 6i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L352)

## `List.walk_backwards`

### Inline

```r
List.walk_backwards <- function<T, S>(list: List<T>, state: S, f: fn(S, T) -> S) -> S
```

### Comments

```r
#: <T, S> fn(list: List<T>, state: S, f: fn(S, T) -> S) -> S
List.walk_backwards <- function(list, state, f)
```

Folds from the last element.

```r
List.walk_backwards(["a", "b", "c"], "", function(text, x) Str.concat(text, x))
#> "cba"
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L360)

## `List.walk_until`

### Inline

```r
List.walk_until <- function<T, S>(list: List<T>, state: S, f: fn(S, T) -> :Continue(S) | :Break(S)) -> S
```

### Comments

```r
#: <T, S> fn(list: List<T>, state: S, f: fn(S, T) -> :Continue(S) | :Break(S)) -> S
List.walk_until <- function(list, state, f)
```

Folds until `f` returns `:Break(state)`; `:Continue(state)` goes on.

```r
List.walk_until([1, 2, 3, 4], 0, function(total, x) if (total >= 3) :Break(total) else :Continue(total + x))
#> 3i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L368)

## `List.walk_backwards_until`

### Inline

```r
List.walk_backwards_until <- function<T, S>(list: List<T>, state: S, f: fn(S, T) -> :Continue(S) | :Break(S)) -> S
```

### Comments

```r
#: <T, S> fn(list: List<T>, state: S, f: fn(S, T) -> :Continue(S) | :Break(S)) -> S
List.walk_backwards_until <- function(list, state, f)
```

Folds the list from the last element until `f` returns `:Break(state)`.

```r
List.walk_backwards_until([1, 5, 2, 3], 0, function(total, x) if (x > 4) :Break(total) else :Continue(total + x))
#> 5i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L376)

## `List.walk_with_index`

### Inline

```r
List.walk_with_index <- function<T, S>(list: List<T>, state: S, f: fn(S, T, I64) -> S) -> S
```

### Comments

```r
#: <T, S> fn(list: List<T>, state: S, f: fn(S, T, I64) -> S) -> S
List.walk_with_index <- function(list, state, f)
```

Folds the list, passing `f` each element's 1-based position too.

```r
List.walk_with_index([10, 20, 30], 0, function(total, x, i) total + x * i)
#> 140i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L384)

## `List.walk_with_index_until`

### Inline

```r
List.walk_with_index_until <- function<T, S>(list: List<T>, state: S, f: fn(S, T, I64) -> :Continue(S) | :Break(S)) -> S
```

### Comments

```r
#: <T, S> fn(list: List<T>, state: S, f: fn(S, T, I64) -> :Continue(S) | :Break(S)) -> S
List.walk_with_index_until <- function(list, state, f)
```

Folds the list with positions until `f` returns `:Break(state)`.

```r
List.walk_with_index_until(["a", "b", "c"], "", function(seen, x, i) if (i > 2) :Break(seen) else :Continue(Str.concat(seen, x)))
#> "ab"
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L392)

## `List.walk_from`

### Inline

```r
List.walk_from <- function<T, S>(list: List<T>, index: I64, state: S, f: fn(S, T) -> S) -> S
```

### Comments

```r
#: <T, S> fn(list: List<T>, index: I64, state: S, f: fn(S, T) -> S) -> S
List.walk_from <- function(list, index, state, f)
```

Folds the list from a 1-based position onwards.

```r
List.walk_from([1, 2, 3, 4], 3, 0, function(total, x) total + x)
#> 7i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L400)

## `List.walk_from_until`

### Inline

```r
List.walk_from_until <- function<T, S>(list: List<T>, index: I64, state: S, f: fn(S, T) -> :Continue(S) | :Break(S)) -> S
```

### Comments

```r
#: <T, S> fn(list: List<T>, index: I64, state: S, f: fn(S, T) -> :Continue(S) | :Break(S)) -> S
List.walk_from_until <- function(list, index, state, f)
```

Folds the list from a position until `f` returns `:Break(state)`.

```r
List.walk_from_until([1, 2, 3, 4], 2, 0, function(total, x) if (total >= 5) :Break(total) else :Continue(total + x))
#> 5i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L408)

## `List.walk_try`

### Inline

```r
List.walk_try <- function<T, S, E>(list: List<T>, state: S, f: fn(S, T) -> Result<S, E>) -> Result<S, E>
```

### Comments

```r
#: <T, S, E> fn(list: List<T>, state: S, f: fn(S, T) -> Result<S, E>) -> Result<S, E>
List.walk_try <- function(list, state, f)
```

Folds the list while `f` returns `:Ok(state)`, stopping at the first `:Err`.

```r
List.walk_try(["1", "2", "x"], 0, function(total, s) Result.map(Str.to_i64(s), function(n) total + n))
#> :Err(:InvalidNumStr)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L416)

## `List.for_each`

### Inline

```r
List.for_each <- function<T>(list: List<T>, f: fn(T) -> Any) -> NULL
```

### Comments

```r
#: <T> fn(list: List<T>, f: fn(T) -> Any) -> NULL
List.for_each <- function(list, f)
```

Calls `f` on each element for its effect, and returns `NULL` invisibly.

```r
List.for_each(["a", "b"], function(x) cat(x, "\n"))
#> a
#> b
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L425)

## `List.for_each_try`

### Inline

```r
List.for_each_try <- function<T, E>(list: List<T>, f: fn(T) -> Result<Any, E>) -> Result<NULL, E>
```

### Comments

```r
#: <T, E> fn(list: List<T>, f: fn(T) -> Result<Any, E>) -> Result<NULL, E>
List.for_each_try <- function(list, f)
```

Calls `f` on each element, stopping at the first `:Err`.

```r
List.for_each_try([1, -2, 3], function(x) if (x < 0) :Err(:Negative(x)) else :Ok(NULL))
#> :Err(:Negative(-2i64))
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L433)

## `List.any`

### Inline

```r
List.any <- function<T>(list: List<T>, predicate: fn(T) -> Bool) -> Bool
```

### Comments

```r
#: <T> fn(list: List<T>, predicate: fn(T) -> Bool) -> Bool
List.any <- function(list, predicate)
```

Whether `predicate` is `TRUE` for some element.

```r
List.any([1, 5], function(x) x > 4)
#> TRUE
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L441)

## `List.all`

### Inline

```r
List.all <- function<T>(list: List<T>, predicate: fn(T) -> Bool) -> Bool
```

### Comments

```r
#: <T> fn(list: List<T>, predicate: fn(T) -> Bool) -> Bool
List.all <- function(list, predicate)
```

Whether `predicate` is `TRUE` for every element; `TRUE` for an empty list.

```r
List.all([1, 5], function(x) x > 4)
#> FALSE
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L449)

## `List.contains`

### Inline

```r
List.contains <- function<T: eq>(list: List<T>, value: T) -> Bool
```

### Comments

```r
#: <T: eq> fn(list: List<T>, value: T) -> Bool
List.contains <- function(list, value)
```

Whether some element is `identical()` to `value`.

```r
List.contains(["a", "b"], "b")
#> TRUE
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L457)

## `List.count_if`

### Inline

```r
List.count_if <- function<T>(list: List<T>, predicate: fn(T) -> Bool) -> I64
```

### Comments

```r
#: <T> fn(list: List<T>, predicate: fn(T) -> Bool) -> I64
List.count_if <- function(list, predicate)
```

The number of elements for which `predicate` is `TRUE`.

```r
List.count_if([1, 5, 7], function(x) x > 4)
#> 2i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L465)

## `List.find_first`

### Inline

```r
List.find_first <- function<T>(list: List<T>, predicate: fn(T) -> Bool) -> Result<T, :NotFound>
```

### Comments

```r
#: <T> fn(list: List<T>, predicate: fn(T) -> Bool) -> Result<T, :NotFound>
List.find_first <- function(list, predicate)
```

The first element for which `predicate` is `TRUE`, or `:Err(:NotFound)`.

```r
List.find_first([1, 5, 7], function(x) x > 4)
#> :Ok(5i64)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L473)

## `List.find_last`

### Inline

```r
List.find_last <- function<T>(list: List<T>, predicate: fn(T) -> Bool) -> Result<T, :NotFound>
```

### Comments

```r
#: <T> fn(list: List<T>, predicate: fn(T) -> Bool) -> Result<T, :NotFound>
List.find_last <- function(list, predicate)
```

The last element for which `predicate` is `TRUE`, or `:Err(:NotFound)`.

```r
List.find_last([1, 5, 7], function(x) x > 4)
#> :Ok(7i64)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L481)

## `List.find_first_index`

### Inline

```r
List.find_first_index <- function<T>(list: List<T>, predicate: fn(T) -> Bool) -> Result<I64, :NotFound>
```

### Comments

```r
#: <T> fn(list: List<T>, predicate: fn(T) -> Bool) -> Result<I64, :NotFound>
List.find_first_index <- function(list, predicate)
```

The position of the first match, or `:Err(:NotFound)`.

```r
List.find_first_index([1, 5, 7], function(x) x > 4)
#> :Ok(2i64)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L489)

## `List.find_last_index`

### Inline

```r
List.find_last_index <- function<T>(list: List<T>, predicate: fn(T) -> Bool) -> Result<I64, :NotFound>
```

### Comments

```r
#: <T> fn(list: List<T>, predicate: fn(T) -> Bool) -> Result<I64, :NotFound>
List.find_last_index <- function(list, predicate)
```

The position of the last match, or `:Err(:NotFound)`.

```r
List.find_last_index([1, 5, 7], function(x) x > 9)
#> :Err(:NotFound)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L497)

## `List.first`

### Inline

```r
List.first <- function<T>(list: List<T>) -> Result<T, :ListWasEmpty>
```

### Comments

```r
#: <T> fn(list: List<T>) -> Result<T, :ListWasEmpty>
List.first <- function(list)
```

The first element, or `:Err(:ListWasEmpty)`.

```r
List.first(["a", "b"])
#> :Ok("a")
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L505)

## `List.last`

### Inline

```r
List.last <- function<T>(list: List<T>) -> Result<T, :ListWasEmpty>
```

### Comments

```r
#: <T> fn(list: List<T>) -> Result<T, :ListWasEmpty>
List.last <- function(list)
```

The last element, or `:Err(:ListWasEmpty)`.

```r
List.last([])
#> :Err(:ListWasEmpty)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L513)

## `List.take_first`

### Inline

```r
List.take_first <- function<T>(list: List<T>, count: I64) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, count: I64) -> List<T>
List.take_first <- function(list, count)
```

The first `count` elements, or all of them if there are fewer.

```r
List.take_first([1, 2, 3], 2)
#> [1i64, 2i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L521)

## `List.take_last`

### Inline

```r
List.take_last <- function<T>(list: List<T>, count: I64) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, count: I64) -> List<T>
List.take_last <- function(list, count)
```

The last `count` elements.

```r
List.take_last([1, 2, 3], 2)
#> [2i64, 3i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L529)

## `List.drop_first`

### Inline

```r
List.drop_first <- function<T>(list: List<T>, count: I64) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, count: I64) -> List<T>
List.drop_first <- function(list, count)
```

Everything but the first `count` elements.

```r
List.drop_first([1, 2, 3], 2)
#> [3i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L537)

## `List.drop_last`

### Inline

```r
List.drop_last <- function<T>(list: List<T>, count: I64) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, count: I64) -> List<T>
List.drop_last <- function(list, count)
```

Everything but the last `count` elements.

```r
List.drop_last([1, 2, 3], 2)
#> [1i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L545)

## `List.drop_at`

### Inline

```r
List.drop_at <- function<T>(list: List<T>, index: I64) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, index: I64) -> List<T>
List.drop_at <- function(list, index)
```

Removes the element at a position.

```r
List.drop_at(["a", "b", "c"], 2)
#> ["a", "c"]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L553)

## `List.sublist`

### Inline

```r
List.sublist <- function<T>(list: List<T>, start: I64, count: I64) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, start: I64, count: I64) -> List<T>
List.sublist <- function(list, start, count)
```

`count` elements starting at position `start`.

```r
List.sublist([1, 2, 3, 4], 2, 2)
#> [2i64, 3i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L561)

## `List.split_at`

### Inline

```r
List.split_at <- function<T>(list: List<T>, count: I64) -> Record{before: List<T>, others: List<T>}
```

### Comments

```r
#: <T> fn(list: List<T>, count: I64) -> Record{before: List<T>, others: List<T>}
List.split_at <- function(list, count)
```

The first `count` elements as `before` and the rest as `others`.

```r
List.split_at([1, 2, 3], 1)
#> (before = [1i64], others = [2i64, 3i64])
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L569)

## `List.split_first`

### Inline

```r
List.split_first <- function<T>(list: List<T>, delimiter: T) -> Result<Record{before: List<T>, after: List<T>}, :NotFound>
```

### Comments

```r
#: <T> fn(list: List<T>, delimiter: T) -> Result<Record{before: List<T>, after: List<T>}, :NotFound>
List.split_first <- function(list, delimiter)
```

Splits the list around the first element identical to `delimiter`.

```r
List.split_first(["a", "-", "b", "-", "c"], "-")
#> :Ok((after = ["b", "-", "c"], before = ["a"]))
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L577)

## `List.split_last`

### Inline

```r
List.split_last <- function<T>(list: List<T>, delimiter: T) -> Result<Record{before: List<T>, after: List<T>}, :NotFound>
```

### Comments

```r
#: <T> fn(list: List<T>, delimiter: T) -> Result<Record{before: List<T>, after: List<T>}, :NotFound>
List.split_last <- function(list, delimiter)
```

Splits the list around the last element identical to `delimiter`.

```r
List.split_last(["a", "-", "b", "-", "c"], "-")
#> :Ok((after = ["c"], before = ["a", "-", "b"]))
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L585)

## `List.split_on`

### Inline

```r
List.split_on <- function<T>(list: List<T>, delimiter: T) -> List<List<T>>
```

### Comments

```r
#: <T> fn(list: List<T>, delimiter: T) -> List<List<T>>
List.split_on <- function(list, delimiter)
```

The runs of elements between elements identical to `delimiter`.

```r
List.split_on([1, 0, 2, 3, 0, 4], 0)
#> [[1i64], [2i64, 3i64], [4i64]]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L593)

## `List.split_on_list`

### Inline

```r
List.split_on_list <- function<T>(list: List<T>, delimiter: List<T>) -> List<List<T>>
```

### Comments

```r
#: <T> fn(list: List<T>, delimiter: List<T>) -> List<List<T>>
List.split_on_list <- function(list, delimiter)
```

The runs of elements between occurrences of the sublist `delimiter`.

```r
List.split_on_list([1, 0, 0, 2, 0, 3], [0, 0])
#> [[1i64], [2i64, 0i64, 3i64]]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L601)

## `List.chunks_of`

### Inline

```r
List.chunks_of <- function<T>(list: List<T>, size: I64) -> List<List<T>>
```

### Comments

```r
#: <T> fn(list: List<T>, size: I64) -> List<List<T>>
List.chunks_of <- function(list, size)
```

Groups of `size` elements; the last group may be shorter.

```r
List.chunks_of([1, 2, 3], 2)
#> [[1i64, 2i64], [3i64]]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L609)

## `List.intersperse`

### Inline

```r
List.intersperse <- function<T>(list: List<T>, separator: T) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, separator: T) -> List<T>
List.intersperse <- function(list, separator)
```

Puts `separator` between every two elements.

```r
List.intersperse(["a", "b", "c"], "-")
#> ["a", "-", "b", "-", "c"]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L617)

## `List.sort_with`

### Inline

```r
List.sort_with <- function<T>(list: List<T>, compare: fn(T, T) -> :LT | :EQ | :GT) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, compare: fn(T, T) -> :LT | :EQ | :GT) -> List<T>
List.sort_with <- function(list, compare)
```

A stable sort by `compare`, which returns `:LT`, `:EQ` or `:GT`.

```r
List.sort_with([3, 1, 2], Num.compare)
#> [1i64, 2i64, 3i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L625)

## `List.sort_asc`

### Inline

```r
List.sort_asc <- function<T: number>(list: List<T>) -> List<T>
```

### Comments

```r
#: <T: number> fn(list: List<T>) -> List<T>
List.sort_asc <- function(list)
```

Sorts numbers from smallest to largest.

```r
List.sort_asc([3, 1, 2])
#> [1i64, 2i64, 3i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L633)

## `List.sort_desc`

### Inline

```r
List.sort_desc <- function<T: number>(list: List<T>) -> List<T>
```

### Comments

```r
#: <T: number> fn(list: List<T>) -> List<T>
List.sort_desc <- function(list)
```

Sorts numbers from largest to smallest.

```r
List.sort_desc([1.5, 3, 2])
#> [3, 2, 1.5]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L641)

## `List.swap`

### Inline

```r
List.swap <- function<T>(list: List<T>, first: I64, second: I64) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, first: I64, second: I64) -> List<T>
List.swap <- function(list, first, second)
```

Exchanges the elements at two positions; an out-of-range position leaves the list unchanged.

```r
List.swap(["a", "b", "c"], 1, 3)
#> ["c", "b", "a"]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L649)

## `List.replace`

### Inline

```r
List.replace <- function<T>(list: List<T>, index: I64, value: T) -> Record{list: List<T>, value: T}
```

### Comments

```r
#: <T> fn(list: List<T>, index: I64, value: T) -> Record{list: List<T>, value: T}
List.replace <- function(list, index, value)
```

Replaces the element at a position, returning the new list and the element it replaced.

```r
List.replace(["a", "b"], 2, "z")
#> (list = ["a", "z"], value = "b")
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L657)

## `List.append_if_ok`

### Inline

```r
List.append_if_ok <- function<T, E>(list: List<T>, result: Result<T, E>) -> List<T>
```

### Comments

```r
#: <T, E> fn(list: List<T>, result: Result<T, E>) -> List<T>
List.append_if_ok <- function(list, result)
```

Adds an `:Ok` value at the end; an `:Err` leaves the list unchanged.

```r
List.append_if_ok([1], Str.to_i64("2"))
#> [1i64, 2i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L665)

## `List.prepend_if_ok`

### Inline

```r
List.prepend_if_ok <- function<T, E>(list: List<T>, result: Result<T, E>) -> List<T>
```

### Comments

```r
#: <T, E> fn(list: List<T>, result: Result<T, E>) -> List<T>
List.prepend_if_ok <- function(list, result)
```

Adds an `:Ok` value at the start; an `:Err` leaves the list unchanged.

```r
List.prepend_if_ok([1], Str.to_i64("x"))
#> [1i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L673)

## `List.concat_utf8`

### Inline

```r
List.concat_utf8 <- function(list: List<I64>, string: Str) -> List<I64>
```

### Comments

```r
#: fn(list: List<I64>, string: Str) -> List<I64>
List.concat_utf8 <- function(list, string)
```

Appends the UTF-8 bytes of a string to a list of bytes.

```r
List.concat_utf8([104], "i")
#> [104i64, 105i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L681)

## `List.with_capacity`

### Inline

```r
List.with_capacity <- function<T>(capacity: I64) -> List<T>
```

### Comments

```r
#: <T> fn(capacity: I64) -> List<T>
List.with_capacity <- function(capacity)
```

An empty list with room for `capacity` elements, so appending that many never copies.

```r
List.len(List.with_capacity(1000))
#> 0i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L689)

## `List.reserve`

### Inline

```r
List.reserve <- function<T>(list: List<T>, spare: I64) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>, spare: I64) -> List<T>
List.reserve <- function(list, spare)
```

The list with room for `spare` more elements.

```r
List.reserve([1, 2], 100)
#> [1i64, 2i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L697)

## `List.release_excess_capacity`

### Inline

```r
List.release_excess_capacity <- function<T>(list: List<T>) -> List<T>
```

### Comments

```r
#: <T> fn(list: List<T>) -> List<T>
List.release_excess_capacity <- function(list)
```

The list with no room beyond its elements, which gives back what `List.reserve` or
`List.with_capacity` set aside.

```r
List.release_excess_capacity(List.reserve([1, 2], 100))
#> [1i64, 2i64]
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L706)

## `List.sum`

### Inline

```r
List.sum <- function<T: number>(list: List<T>) -> T
```

### Comments

```r
#: <T: number> fn(list: List<T>) -> T
List.sum <- function(list)
```

The sum of the elements; `0L` for an empty list. An `integer` sum that overflows is an error, so
sum doubles, or fold with `Num.add_checked` to get `:Err(:Overflow)` instead. A `double` sum
adds the elements from first to last in double precision, as a loop with `+` does. R's `sum()`
accumulates with more precision, so the two can differ in the last digits.

```r
List.sum([1, 2, 3])
#> 6i64
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L717)

## `List.product`

### Inline

```r
List.product <- function<T: number>(list: List<T>) -> T
```

### Comments

```r
#: <T: number> fn(list: List<T>) -> T
List.product <- function(list)
```

The product of the elements; `1L` for an empty list. An `integer` product that overflows is an
error, as for `List.sum`.

```r
List.product([2, 2.5])
#> 5
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L726)

## `List.min`

### Inline

```r
List.min <- function<T: number>(list: List<T>) -> Result<T, :ListWasEmpty>
```

### Comments

```r
#: <T: number> fn(list: List<T>) -> Result<T, :ListWasEmpty>
List.min <- function(list)
```

The smallest element, or `:Err(:ListWasEmpty)`.

```r
List.min([3, 1, 2])
#> :Ok(1i64)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L734)

## `List.max`

### Inline

```r
List.max <- function<T: number>(list: List<T>) -> Result<T, :ListWasEmpty>
```

### Comments

```r
#: <T: number> fn(list: List<T>) -> Result<T, :ListWasEmpty>
List.max <- function(list)
```

The largest element, or `:Err(:ListWasEmpty)`.

```r
List.max([])
#> :Err(:ListWasEmpty)
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L742)

## `List.starts_with`

### Inline

```r
List.starts_with <- function<T>(list: List<T>, prefix: List<T>) -> Bool
```

### Comments

```r
#: <T> fn(list: List<T>, prefix: List<T>) -> Bool
List.starts_with <- function(list, prefix)
```

Whether the list begins with the elements of `prefix`.

```r
List.starts_with([1, 2, 3], [1, 2])
#> TRUE
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L750)

## `List.ends_with`

### Inline

```r
List.ends_with <- function<T>(list: List<T>, suffix: List<T>) -> Bool
```

### Comments

```r
#: <T> fn(list: List<T>, suffix: List<T>) -> Bool
List.ends_with <- function(list, suffix)
```

Whether the list ends with the elements of `suffix`.

```r
List.ends_with([1, 2, 3], [2])
#> FALSE
```

[Source](https://github.com/felix-andreas/ry/blob/main/types/std.Rtypes#L758)
