コード例 #1
0
        static Answer3 TakAnswer3(int x, int y, int z)
        {
            if (!(y < x))
            {
                return(new Answer3(null, z));
            }
            Answer3 a1 = TakAnswer3(x - 1, y, z);

            while (a1.Next != null)
            {
                a1 = a1.Next();
            }
            ;
            if (a1.Unload != null)
            {
                throw new NotImplementedException();
            }
            Answer3 a2 = TakAnswer3(y - 1, z, x);

            while (a2.Next != null)
            {
                a2 = a2.Next();
            }
            ;
            if (a2.Unload != null)
            {
                throw new NotImplementedException();
            }
            Answer3 a3 = TakAnswer3(z - 1, x, y);

            while (a3.Next != null)
            {
                a3 = a3.Next();
            }
            ;
            if (a3.Unload != null)
            {
                throw new NotImplementedException();
            }
            return(new Answer3(
                       new Step3(delegate() { return TakAnswer3((int)a1.FinalAnswer, (int)a2.FinalAnswer, (int)a3.FinalAnswer); }),
                       null));
        }
コード例 #2
0
        static void Main(string [] args)
        {
            Identify(Console.Out, "# ");
            Console.WriteLine("set terminal windows");
            Console.WriteLine("set logscale x");
            Console.WriteLine("set grid");
            Console.Write("plot \"-\" using 4:3 with lines");
            for (int i = 0; i < 3; i++)
            {
                Console.Write(", \"-\" using 4:3 with lines");
            }
            Console.WriteLine("");

            int nruns = 21;

            //DumpHistogram ("c:\\jrm-code-project\\TakTest\\takval2.txt", runThunk (1000, 10, delegate () {
            //    TakVal2 (18, 12, 6);
            //}), .000063609);
            DumpHistogram(Console.Out, runThunk(nruns, 10, delegate() { Tak(18, 12, 6); }), .000063609);
            Console.WriteLine("e");
            //DumpHistogram (Console.Out, runThunk (nruns, 10, delegate () { Tak1a (0, 18, 12, 6); }), .000063609);
            //Console.WriteLine ("e");
            //DumpHistogram (Console.Out, runThunk (1000, 10, delegate () { Tak1b (0, 18, 12, 6); }), .000063609);
            //Console.WriteLine ("e");
            //DumpHistogram (Console.Out, runThunk (1000, 10, delegate () { Tak2 (0, 1, 18, 12, 6); }), .000063609);
            //Console.WriteLine ("e");
            //DumpHistogram (Console.Out, runThunk (1000, 10, delegate () { Tak3 (0, 1, 2, 18, 12, 6); }), .000063609);
            //Console.WriteLine ("e");
            DumpHistogram(Console.Out, runThunk(nruns, 10, delegate() { int answer; TakOut(out answer, 18, 12, 6); }), .000063609);
            Console.WriteLine("e");
            DumpHistogram(Console.Out, runThunk(nruns, 10, delegate()
            {
                int answer;
                TakOut3d again;
                for (bool a = TakOut3a(out again, out answer, 18, 12, 6);
                     a;
                     a = again(out again, out answer))
                {
                }
                ;
            }), .000063609);
            Console.WriteLine("e");

            //DumpHistogram (Console.Out, runThunk (1000, 10, delegate () { int answer = 0; TakRef (ref answer, 18, 12, 6); }), .000063609);
            //Console.WriteLine ("e");
            //DumpHistogram (Console.Out, runThunk (nruns, 10, delegate () { TakBox (18, 12, 6); }), .000063609);
            //Console.WriteLine ("e");
            //DumpHistogram (Console.Out, runThunk (nruns, 10, delegate () { TakValb (18, 12, 6); }), .000063609);
            //Console.WriteLine ("e");
            //DumpHistogram (Console.Out, runThunk (nruns, 10, delegate () { TakGlob (18, 12, 6); }), .000063609);
            //Console.WriteLine ("e");
            //DumpHistogram (Console.Out, runThunk (nruns, 10, delegate () { Answer2 a = TakAnswer2 (18,12,6); while (a.Next != null) {a = a.Next();}; }), .000063609);
            //Console.WriteLine ("e");
            DumpHistogram(Console.Out, runThunk(nruns, 10, delegate() { Answer2 a = TakAnswer2a(18, 12, 6); while (a.Next != null)
                                                                        {
                                                                            a = a.Next();
                                                                        }
                                                                        ; }), .000063609);
            Console.WriteLine("e");
            DumpHistogram(Console.Out, runThunk(nruns, 10, delegate() { Answer3 a = TakAnswer3(18, 12, 6); while (a.Next != null)
                                                                        {
                                                                            a = a.Next();
                                                                        }
                                                                        ; }), .000063609);
            Console.WriteLine("e");
            TakTrampInit();
            DumpHistogram(Console.Out, runThunk(nruns, 1, delegate() { TakInterpNew(); }), .000063609);
            Console.WriteLine("e");


            //DumpHistogram (Console.Out, runThunk (nruns, 10, delegate () { TakTramp (); }), .000063609);
            //Console.WriteLine ("e");

            //DumpHistogram (Console.Out, runThunk (1000, 10, delegate () { Tak4 (0, 1, 2, 3, 18, 12, 6); }), .000063609);

            Console.WriteLine();
            Console.WriteLine("# {0} exits", appName);
        }