Skip to main content

Pair.fold

foldinitfunction

Documentation

Combines all the elements of the pair, by iteratively applying the passed function with next elements of the pair.

Arguments

  • init: The initial value for the fold.
  • function: A function taking two elements and combining them.

Examples

Compute the sum of all of the elements in a pair.

      Pair.new 10 20 . fold 0 (+)