MCPcopy Create free account
hub / github.com/cel-expr/cel-go / foldIterable

Method foldIterable

interpreter/interpretable.go:1555–1575  ·  view source on GitHub ↗
(iterable traits.Iterable)

Source from the content-addressed store, hash-verified

1553}
1554
1555func (f *folder) foldIterable(iterable traits.Iterable) ref.Val {
1556 it := iterable.Iterator()
1557 for it.HasNext() == types.True {
1558 f.iterVar1Val = it.Next()
1559
1560 cond := f.cond.Exec(f.frame)
1561 condBool, ok := cond.(types.Bool)
1562 if f.interrupted || (!f.exhaustive && ok && condBool != types.True) {
1563 return f.evalResult()
1564 }
1565
1566 // Update the accumulation value and check for eval interuption.
1567 f.accuVal = f.step.Exec(f.frame)
1568 f.initialized = true
1569 if f.interruptable && f.frame.CheckInterrupt() {
1570 f.interrupted = true
1571 return f.evalResult()
1572 }
1573 }
1574 return f.evalResult()
1575}
1576
1577// FoldEntry will either fold comprehension v1 style macros if iterVar2 is unset, or comprehension v2 style
1578// macros if both the iterVar and iterVar2 are set to non-empty strings.

Callers 1

ExecMethod · 0.80

Calls 6

evalResultMethod · 0.95
CheckInterruptMethod · 0.80
IteratorMethod · 0.65
HasNextMethod · 0.65
NextMethod · 0.65
ExecMethod · 0.65

Tested by

no test coverage detected