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

Method foldIterable

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

Source from the content-addressed store, hash-verified

1982}
1983
1984func (f *folder) foldIterable(iterable traits.Iterable) ref.Val {
1985 it := iterable.Iterator()
1986 for it.HasNext() == types.True {
1987 f.iterVar1Val = it.Next()
1988
1989 cond := f.cond.Exec(f.frame)
1990 if f.interrupted {
1991 return f.evalResult()
1992 }
1993 if !f.exhaustive && cond != types.True {
1994 if isError(cond) {
1995 f.interrupted = true
1996 }
1997 return f.evalResult()
1998 }
1999
2000 // Update the accumulation value and check for eval interruption.
2001 f.accuVal = f.step.Exec(f.frame)
2002 f.initialized = true
2003 if f.interruptable && f.frame.CheckInterrupt() {
2004 f.interrupted = true
2005 return f.evalResult()
2006 }
2007 }
2008 return f.evalResult()
2009}
2010
2011// FoldKeyOnly reports whether the folder only consumes the entry key (e.g. 1-variable map
2012// comprehensions where iterVar2 is empty and listV1Fold is false).

Callers 1

ExecMethod · 0.80

Calls 7

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

Tested by

no test coverage detected