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<f32> = [1.5, 2.5, 4.0]
  print("{xs.sum()}")
}
Output
8.0
pub(api) fn sum() -> f32

Complexity. O(n).

Since. 1.0.0-beta

Returns

f32

Effects

none declared (pure unless the body says otherwise)

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

See also