Expanding Standard Library
Some checks failed
Build / build (push) Successful in 37s
Tests / tests (push) Failing after 31s

Expanding functions in the standard library.
This commit is contained in:
Jordan Wages 2026-06-27 19:41:26 -05:00
commit 5556010c91
12 changed files with 366 additions and 3 deletions

View 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));
});
}
}
}