Example #1
0
        static void Iterate(ConsoleInputContext context, Func <string, bool> action)
        {
            var res = IterateLowStack(context, action);

            while (res != null)
            {
                res = res.Run();
            }
        }
Example #2
0
        static LowStack IterateLowStack(ConsoleInputContext context, Func <string, bool> action)
        {
            var next = context.Next();
            var done = action(next.Value);

            if (!done)
            {
                return(new LowStack(() => IterateLowStack(next, action)));
            }

            return(null);
        }
Example #3
0
        static Func <ConsoleInputContext> NextConsoleInput()
        {
            ConsoleInputContext context = null;

            Func <ConsoleInputContext> next = () =>
            {
                if (context == null)
                {
                    var input = Console.ReadLine();
                    context = new ConsoleInputContext(input, NextConsoleInput());
                }
                return(context);
            };

            return(next);
        }