Example #1
0
        /// <summary>
        /// Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
        /// </summary>
        /// <param name="callbackfn">A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.</param>
        /// <param name="initialValue">If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.</param>
        /// <returns></returns>
        public object ReduceRight(ReduceRightCallback callbackfn, object initialValue)
        {
            object result = initialValue;

            for (int index = 0; index < this.Length; index++)
            {
                result = callbackfn(result, this[this.Length - index - 1], index, this);
            }

            return(result);
        }
Example #2
0
 /// <summary>
 /// Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
 /// </summary>
 /// <param name="callbackfn">A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.</param>
 /// <returns></returns>
 public object ReduceRight(ReduceRightCallback callbackfn) => ReduceRight(callbackfn, null);