Skip to content

Commit

Permalink
Adding Erf math function
Browse files Browse the repository at this point in the history
  • Loading branch information
pratikmota committed May 26, 2024
1 parent e3928b7 commit c5c6f66
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions evaldo/builtins_math.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,20 @@ var Builtins_math = map[string]*env.Builtin{
}
},
},
"erf": {
Argsn: 1,
Doc: "Returns the error function of value.",
Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object {
switch val := arg0.(type) {
case env.Integer:
return *env.NewDecimal(math.Erf(float64(val.Value)))
case env.Decimal:
return *env.NewDecimal(math.Erf(val.Value))
default:
return MakeArgError(ps, 1, []env.Type{env.IntegerType, env.DecimalType}, "erf")
}
},
},
"pi": {
Argsn: 0,
Doc: "Return Pi constant.",
Expand Down

0 comments on commit c5c6f66

Please sign in to comment.