Beispiel #1
0
        public static IO <Unit> Run(IReadOnlyList <GcdStart> states)
        {
            states.ContractedNotNull("states");

            return((
                       from test in Gcd_S4.GetTests(false)
                       let elapsed = Readers.Timer()
                                     let isThird = Readers.MatchCounter(i => i == 3, 1)
                                                   let results = from start in states
                                                                 select new {
                Start = start,
                Result = from validated in ValidateState(start.ToMaybe()).State
                         select test.Transform(validated).Value
            }

                       select(from _   in ConsoleWriteLine("{0}", test.Title)
                              from __  in (from item in results
                                           select ConsoleWriteLine(
                                               @"    GCD = {0,14} for {1}: Elapsed = {2:ss\.fff} secs; {3}",
                                               (from r in item.Result
                                                select String.Format(_culture, "{0,14:N0}", r.Gcd)
                                               ) | "incalculable",
                                               item.Start,
                                               elapsed(),
                                               isThird() ? "I'm third!" : ""
                                               )
                                           ).Last()
                              from ___ in ConsoleWriteLine(@"Elapsed Time: {0:ss\.ff} secs", elapsed())
                              select ConsoleWriteLine()
                              ).Invoke()
                       ).LastOrDefault());
        }
Beispiel #2
0
        static void Main()
        {
            BasicTest();

            WesDyerTest();

            MikeHadlowTest();

            ExternalStateTest();

            GcdTest1(new List <int>()
            {
                24, 60, 42, 48, 9
            }.AsReadOnly());

            var start = new GcdStart(40, 1024);

  #if true
            Gcd_S4.Best.Run(start).ToMaybe().SelectMany(result => {
                var value = result.Value;
                var title = Gcd_S4.GetTitle(Gcd_S4.Best.Run);
                Console.WriteLine("    GCD = {0} for {1} - {2}", value.Gcd, start, title);
                Console.WriteLine();
                return(Maybe.Unit);
            });
  #else
            var result8 = Gcd_S4.Best.Run(start);
            if (result8 != null)
            {
                var value = result8.Value;
                var title = Gcd_S4.GetTitle(Gcd_S4.Best.Run);
                Console.WriteLine("    GCD = {0} for {1} - {2}", value.Gcd, start, title);
                Console.WriteLine();
            }
  #endif

            Console.ReadLine();
        }