public List < T > scanLeft ( BinaryOperator < T > accumulator ) { List < T > result = new ArrayList <> ( ) ; forEachOrdered ( t -> { if ( result . isEmpty ( ) ) result . add ( t ) ; else result . add ( accumulator . apply ( result . get ( result . size ( ) - 1 ) , t ) ) ; } ) ; return result ; }
Produces a list containing cumulative results of applying the accumulation function going left to right .