core.list-fold-inner
- description
- Fold the items of xs from start (inclusive) to end (exclusive) in order. Splits the range in halves: a function variable cannot be passed on as it is (function_not_called), so each recursive call wraps reducer in a new lambda, and with the halves an item goes through O(log n) wrappers (one item at a time, the k-th item went through k wrappers, O(n^2) calls in all)
- type
Fn( T: Type, A: Type, reducer: Fn(acc: Param("A"), item: Param("T")) -> Param("A"), xs: List<Param("T")>, start: Number, end: Number, acc: Param("A") ) -> Param("A")- expression
fn(T$0, A$1, reducer$2, xs$3, start$4, end$5, acc$6) => let length$7 = @core.minus(left: $5, right: $4); match @core.less-than(left: $7, right: 2) { true => match @core.equal(left: $7, right: 1) { true => match @core.list-get(list: $3, index: $4) { #some(item$8) => $2(acc: $6, item: $8), #none(_) => $6 }, false => $6 }, false => let middle$9 = @core.plus(left: $4, right: @core.divide(left: $7, right: 2)); @core.list-fold-inner( T: $0, A: $1, reducer: fn(acc$10, item$11) => $2(acc: $10, item: $11), xs: $3, start: $9, end: $5, acc: @core.list-fold-inner( T: $0, A: $1, reducer: fn(acc$12, item$13) => $2(acc: $12, item: $13), xs: $3, start: $4, end: $9, acc: $6 ) ) }
- visibility
- public
core.list-fold-inner (project definy, branch main, snapshot CfIAXM725tR74SWd4aoTUz4-JJQfqnllblZbQ2Sv204) id: jeFsyn-vx17pcEmwW5Oz9ISYARSglyvLck81UBv_lgI content hash: _7zMwbbaj1rEqUHTAPY8arU3mbDeyC-G1pHeyB1xZ-o