Class FoldLeftFunction
java.lang.Object
com.github.basking2.sdsai.itrex.functions.AbstractFunction2<FunctionInterface<Object>,Object,Object>
com.github.basking2.sdsai.itrex.functions.functional.FoldLeftFunction
- All Implemented Interfaces:
FunctionInterface<Object>
,BiFunction<Iterator<?>,
EvaluationContext, Object>
Fold a given value over all elements.
[* Assume the add function exists. *]
[foldLeft [curry add] 0 [1,2,3,4]]
This is much like the foldLeft function common in Scala or ML languages.
There is no foldRight
as iterators make it expensive to materialize to a list and then foldRight.
If such an algorithm is necessary, operate on the list in a reversed projection.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Object
applyImpl
(FunctionInterface<Object> objectFunctionInterface, Object o, Iterator<?> rest, EvaluationContext context) Overriders of this class should implement this.Methods inherited from class com.github.basking2.sdsai.itrex.functions.AbstractFunction2
apply
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.function.BiFunction
andThen
-
Constructor Details
-
FoldLeftFunction
public FoldLeftFunction()
-
-
Method Details
-
applyImpl
protected Object applyImpl(FunctionInterface<Object> objectFunctionInterface, Object o, Iterator<?> rest, EvaluationContext context) Description copied from class:AbstractFunction2
Overriders of this class should implement this.- Specified by:
applyImpl
in classAbstractFunction2<FunctionInterface<Object>,
Object, Object> - Parameters:
objectFunctionInterface
- The desired parameter.o
- The desired parameter.rest
- Any unused arguments.context
- The evaluation context.- Returns:
- The produced object.
-