package math import ( "context" "github.com/MontFerret/ferret/pkg/runtime/core" "github.com/MontFerret/ferret/pkg/runtime/values" "math" ) /* * Returns the square root of a given number. * @param value (Int|Float) - A number. * @returns (Float) - The square root. */ func Sqrt(_ context.Context, args ...core.Value) (core.Value, error) { err := core.ValidateArgs(args, 1, 1) if err != nil { return values.None, err } err = core.ValidateType(args[0], core.IntType, core.FloatType) if err != nil { return values.None, err } return values.NewFloat(math.Sqrt(toFloat(args[0]))), nil }