reduce

Reduce an array of elements to a single element, using a user-supplied reductor function.

If the array is empty, return the default value for the element type.

If the array contains only one element, return that element.

Otherwise, the reductor function will be called on every member of the array and on every resulting element until there is only one element, which is then returned.

  1. Elem reduce(Elem[] array, Reduce2E func)
    version(TangoDoc)
    reduce
  2. template reduce(Array, Func)

Parameters

array Elem[]

the array to reduce

func Reduce2E

the reductor function

Return Value

Type: Elem

the single element reduction

Meta