Beispiel #1
0
        internal static IDynamic Min(IEnvironment environment, IArgs args)
        {
            if (args.IsEmpty)
            {
                return(environment.CreateNumber(double.PositiveInfinity));
            }
            if (args.Count == 1)
            {
                return(args[0].ConvertToNumber());
            }

            var numbers = new INumber[args.Count];

            for (int i = 0; i < numbers.Length; i++)
            {
                var number = args[i].ConvertToNumber();
                if (double.IsNaN(number.BaseValue))
                {
                    return(environment.CreateNumber(double.NaN));
                }
                numbers[i] = number;
            }

            INumber r = null;

            foreach (var n in numbers)
            {
                if (r == null || r.Op_Greaterthan(n).ConvertToBoolean().BaseValue)
                {
                    r = n;
                }
            }
            return(r);
        }