conditionalIterate#
- swordfish.function.conditionalIterate()#
Supposing the iteration is based only on the previous result, for the k-th (k ∈ N+) record, the calculation logic is (where the column “factor” holds the results):
cond[k] == true: factor[k] = trueValue
cond[k] == false: factor[k] = falseIterFunc(factor)[k-1]
Note
If falseIterFunc is a window function, the iteration is based on multiple previous results.
- Parameters:
cond (Constant) – A conditional expression or a function with BOOLEAN return values. It must contain fields from the input table. Constants/constant expressions are not supported.
trueValue (Constant) – The calculation formula.
falseIterFunc (Constant) –
The function for iteration, whose only parameter is the column from the output table. Currently, only the following functions are supported (use partial application to specify functions with multiple parameters):
Moving functions: tmove, tmavg, tmmax, tmmin, tmsum, mavg, mmax, mmin, mcount, msum;
Cumulative window functions: cumlastNot, cumfirstNot;
Order-sensitive functions: ffill, move.
If cond returns true, the calculation of trueValue is triggered. If cond returns false, falseIterFunc is called for iteration.