public abstract class Fold extends Object implements ValueExpression
ValueExpression implementations of the Fold
operation.
Fold has three operands: values (a ValueExpression),
reducer (a Reducer) and initial (a
ValueExpression). First initial is evaluated. If it
does not return a single value, the final result is an empty list. Next,
values is evaluated and its result is passed to the abstract
prepareValues(ImmutableList) method. The returned list is prefixed
by the value returned by evaluating initial. On this list, the
reducer is applied to the first two values until a single
value remains, which is then returned.
| Modifier and Type | Field and Description |
|---|---|
ValueExpression |
initial |
Reducer |
reducer |
ValueExpression |
values |
| Constructor and Description |
|---|
Fold(ValueExpression values,
Reducer reducer,
ValueExpression initial) |
| Modifier and Type | Method and Description |
|---|---|
ImmutableList<OptionalValue> |
eval(Environment environment,
Encoding encoding) |
protected abstract ImmutableList<OptionalValue> |
prepareValues(ImmutableList<OptionalValue> values) |
protected abstract ValueExpression |
reduce(Reducer reducer,
Value head,
Value tail) |
public final ValueExpression values
public final Reducer reducer
public final ValueExpression initial
public Fold(ValueExpression values, Reducer reducer, ValueExpression initial)
public ImmutableList<OptionalValue> eval(Environment environment, Encoding encoding)
eval in interface ValueExpressionprotected abstract ImmutableList<OptionalValue> prepareValues(ImmutableList<OptionalValue> values)
protected abstract ValueExpression reduce(Reducer reducer, Value head, Value tail)
Copyright © 2017. All rights reserved.