cs-mic/src/stdlib/functions/Max.cs
2025-08-20 05:28:05 -05:00

35 lines
1 KiB
C#

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