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

Method Fold

cel/macro.go:469–487  ·  view source on GitHub ↗

Fold creates a fold comprehension instruction. - iterVar is the iteration variable name. - iterRange represents the expression that resolves to a list or map where the elements or keys (respectively) will be iterated over. - accuVar is the accumulation variable name, typically parser.AccumulatorNam

(iterVar string,
	iterRange *exprpb.Expr,
	accuVar string,
	accuInit *exprpb.Expr,
	condition *exprpb.Expr,
	step *exprpb.Expr,
	result *exprpb.Expr)

Source from the content-addressed store, hash-verified

467// environment in the step and condition expressions. Presently, the name __result__ is commonly
468// used by built-in macros but this may change in the future.
469func (ah *adaptingHelper) Fold(iterVar string,
470 iterRange *exprpb.Expr,
471 accuVar string,
472 accuInit *exprpb.Expr,
473 condition *exprpb.Expr,
474 step *exprpb.Expr,
475 result *exprpb.Expr) *exprpb.Expr {
476 return mustAdaptToProto(
477 ah.modernHelper.NewComprehension(
478 mustAdaptToExpr(iterRange),
479 iterVar,
480 accuVar,
481 mustAdaptToExpr(accuInit),
482 mustAdaptToExpr(condition),
483 mustAdaptToExpr(step),
484 mustAdaptToExpr(result),
485 ),
486 )
487}
488
489// Ident creates an identifier Expr value.
490func (ah *adaptingHelper) Ident(name string) *exprpb.Expr {

Callers

nothing calls this directly

Calls 3

mustAdaptToProtoFunction · 0.85
mustAdaptToExprFunction · 0.85
NewComprehensionMethod · 0.65

Tested by

no test coverage detected