Expanding Standard Library
Expanding functions in the standard library.
This commit is contained in:
parent
9dba1a2dfd
commit
5556010c91
12 changed files with 366 additions and 3 deletions
36
src/StandardLibrary/Functions/SquareRoot.cs
Normal file
36
src/StandardLibrary/Functions/SquareRoot.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace CSMic.StandardLibrary.Functions
|
||||
{
|
||||
public class SquareRoot: FunctionBase, ICodedFunction
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "sqrt";
|
||||
}
|
||||
}
|
||||
|
||||
public override IEnumerable<FunctionArgument> ExpectedArguments
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new FunctionArgument("value", FunctionValue.NUMBER);
|
||||
}
|
||||
}
|
||||
|
||||
public FunctionValue Execute(params FunctionArgument[] args)
|
||||
{
|
||||
return base.Execute(args, (_args) =>
|
||||
{
|
||||
var input = _args[0].Value;
|
||||
double number = Convert.ToDouble(input.Value);
|
||||
|
||||
return new FunctionValue(FunctionValueType.Numeric, Math.Sqrt(number));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue