Skip to main content

List.reduce

reducefunctionif_empty

Documentation

Combines all the elements of a non-empty list using a binary operation. If the list is empty, it returns if_empty.

Arguments

  • function: A binary operation that takes two items and combines them.
  • if_empty: Value returned if the list is empty.

Examples

Compute the sum of all the elements in a list.

      import Standard.Examples

example_fold = Examples.list.reduce (+)