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

Function mathGreatest

ext/math.go:643–668  ·  view source on GitHub ↗
(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr)

Source from the content-addressed store, hash-verified

641}
642
643func mathGreatest(mef cel.MacroExprFactory, target ast.Expr, args []ast.Expr) (ast.Expr, *cel.Error) {
644 if !macroTargetMatchesNamespace(mathNamespace, target) {
645 return nil, nil
646 }
647 switch len(args) {
648 case 0:
649 return nil, mef.NewError(target.ID(), "math.greatest() requires at least one argument")
650 case 1:
651 if isListLiteralWithNumericArgs(args[0]) || isNumericArgType(args[0]) {
652 return mef.NewCall(maxFunc, args[0]), nil
653 }
654 return nil, mef.NewError(args[0].ID(), "math.greatest() invalid single argument value")
655 case 2:
656 err := checkInvalidArgs(mef, "math.greatest()", args)
657 if err != nil {
658 return nil, err
659 }
660 return mef.NewCall(maxFunc, args...), nil
661 default:
662 err := checkInvalidArgs(mef, "math.greatest()", args)
663 if err != nil {
664 return nil, err
665 }
666 return mef.NewCall(maxFunc, mef.NewList(args...)), nil
667 }
668}
669
670func identity(val ref.Val) ref.Val {
671 return val

Callers

nothing calls this directly

Calls 8

isNumericArgTypeFunction · 0.85
checkInvalidArgsFunction · 0.85
NewErrorMethod · 0.65
IDMethod · 0.65
NewCallMethod · 0.65
NewListMethod · 0.65

Tested by

no test coverage detected