diff --git a/src/stdlib/functions/Max.cs b/src/stdlib/functions/Max.cs new file mode 100644 index 0000000..df3ba64 --- /dev/null +++ b/src/stdlib/functions/Max.cs @@ -0,0 +1,35 @@ +using csmic; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace stdlib.functions +{ + public class Max : FunctionBase, ICodedFunction + { + public override IEnumerable ExpectedArguments + { + get + { + yield return new FunctionArgument("first", FunctionValue.NUMBER); + yield return new FunctionArgument("second", FunctionValue.NUMBER); + } + } + + public FunctionValue Execute(params FunctionArgument[] args) + { + return base.Execute(args, (_args) => + { + var inputFirst = _args[0].Value; + var inputSecond = _args[1].Value; + decimal first = Convert.ToDecimal(inputFirst.Value); + decimal second = Convert.ToDecimal(inputSecond.Value); + + + return new FunctionValue(FunctionValueType.Numeric, Math.Min(first, second)); + }); + } + } +} diff --git a/src/stdlib/functions/Min.cs b/src/stdlib/functions/Min.cs new file mode 100644 index 0000000..18ca33e --- /dev/null +++ b/src/stdlib/functions/Min.cs @@ -0,0 +1,35 @@ +using csmic; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace stdlib.functions +{ + public class Min : FunctionBase, ICodedFunction + { + public override IEnumerable ExpectedArguments + { + get + { + yield return new FunctionArgument("first", FunctionValue.NUMBER); + yield return new FunctionArgument("second", FunctionValue.NUMBER); + } + } + + public FunctionValue Execute(params FunctionArgument[] args) + { + return base.Execute(args, (_args) => + { + var inputFirst = _args[0].Value; + var inputSecond = _args[1].Value; + decimal first = Convert.ToDecimal(inputFirst.Value); + decimal second = Convert.ToDecimal(inputSecond.Value); + + + return new FunctionValue(FunctionValueType.Numeric, Math.Min(first, second)); + }); + } + } +}