MCPcopy Index your code
hub / github.com/google/mangle / evalLet

Function evalLet

engine/transformer.go:43–60  ·  view source on GitHub ↗

evalLet evaluates a let transform. This consists of a number of let statements, each acting on a single row.

(
	head ast.Atom,
	transform ast.Transform,
	rows []ast.ConstSubstList,
	emit func(atom ast.Atom) bool)

Source from the content-addressed store, hash-verified

41// evalLet evaluates a let transform. This consists of a number of let statements,
42// each acting on a single row.
43func evalLet(
44 head ast.Atom,
45 transform ast.Transform,
46 rows []ast.ConstSubstList,
47 emit func(atom ast.Atom) bool) error {
48 for _, init := range rows {
49 subst := init
50 for _, stmt := range transform.Statements {
51 con, err := functional.EvalApplyFn(stmt.Fn, subst)
52 if err != nil {
53 return err
54 }
55 subst = subst.Extend(*stmt.Var, con)
56 }
57 emit(head.ApplySubst(subst).(ast.Atom))
58 }
59 return nil
60}
61
62type grouped struct {
63 key []ast.Constant

Callers 1

EvalTransformFunction · 0.85

Calls 3

EvalApplyFnFunction · 0.92
ApplySubstMethod · 0.65
ExtendMethod · 0.45

Tested by

no test coverage detected