Class StreamFold

All Implemented Interfaces:
ZeroLengthBehaviourI, ZeroLengthBehaviourI.DefaultZeroLengthBehaviourI, JepComponent, PostfixMathCommandI, Serializable

Fold a list using a lambda function to reduce the list down to a single argument.
 Sum = [x,y]=>x+y
 fold(Sum, [1,2,3,4,5])
 
If the stream has a single element, then that element is returned without applying the lambda function.

By default, if the stream is empty, an exception is thrown, but the behaviour can be configured using the methods of the ZeroLengthBehaviourI interface.

See Also:
  • Constructor Details

    • StreamFold

      public StreamFold()
      Default constructor with no zero length array handling, i.e. an exception is thrown when a zero length array is passed as an argument.
  • Method Details