/// <summary>
        /// Repeat <paramref name="factory"/>()
        /// </summary>
        public static T[] Select <T>(this RepeatReader r, Func <ConsoleReader, int, T> factory)
        {
            var arr = new T[r.count];

            for (var i = 0; i < r.count; i++)
            {
                arr[i] = factory(r.cr, i);
            }
            return(arr);
        }
Exemple #2
0
        /// <summary>
        /// Repeat <paramref name="factory"/>() <paramref name="width"/> times per line
        /// </summary>
        public static T[][] Grid <T>(this RepeatReader r, int width, Func <ConsoleReader, int, int, T> factory)
        {
            var arr = new T[r.count][];

            for (var i = 0; i < r.count; i++)
            {
                arr[i] = new T[width];
                for (var j = 0; j < width; j++)
                {
                    arr[i][j] = factory(r.cr, i, j);
                }
            }
            return(arr);
        }
Exemple #3
0
 /// <summary>
 /// Repeat <paramref name="factory"/>()
 /// </summary>
 public static (T1[], T2[]) SelectArray <T1, T2>(this RepeatReader r,
                                                 Func <ConsoleReader, (T1, T2)> factory)