(args []super.Value)
| 175 | } |
| 176 | |
| 177 | func (s *Sqrt) Call(args []super.Value) super.Value { |
| 178 | val := args[0].Under() |
| 179 | if val.IsNull() { |
| 180 | return super.Null |
| 181 | } |
| 182 | if !super.IsNumber(val.Type().ID()) { |
| 183 | return s.sctx.WrapError("sqrt: number argument required", val) |
| 184 | } |
| 185 | x, ok := coerce.ToFloat(val, super.TypeFloat64) |
| 186 | if !ok { |
| 187 | return s.sctx.WrapError("sqrt: not a number", val) |
| 188 | } |
| 189 | return super.NewFloat64(math.Sqrt(x)) |
| 190 | } |