Functional Programming - Reduce - Reduction Operation (fold)
Table of Contents
About
A (reduction|reduce) operation (also called a fold) is a functional programming function.
Reduction operations are terminal operations.
They takes a sequence of input elements and returns:
- a single summary result
- a collection
- or a map
Example:
- finding the sum or maximum of a set of numbers,
- finding the average of values
- grouping elements into categories
- accumulating elements into a list (collections) - group by, partitioningBy
- summarizing elements according to various criteria
- etc..
Articles Related
Property
Batch
A reduction operates on the stream as a whole rather than on individual elements. See Data Processing - Batch
Parallel
A properly constructed reduce operation is inherently parallelizable. See Parallel Programming - (Function|Operation)