OxL Reference

method List.sum

The sum of the elements (0 for an empty list); panics on overflow like +.

Example:

oxl✓ checked in CI
fn main() io {
  let xs: List<isize> = [1, 2, 3, 4]
  print("{xs.sum()}")
}
Output
10
pub(api) fn sum() -> isize

Complexity. O(n).

Since. 1.0.0-beta

Returns

isize

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/numbers.oxl:4820

See also