當前位置: 首頁>>代碼示例>>C#>>正文


C# Node.getCdr方法代碼示例

本文整理匯總了C#中Tree.Node.getCdr方法的典型用法代碼示例。如果您正苦於以下問題:C# Node.getCdr方法的具體用法?C# Node.getCdr怎麽用?C# Node.getCdr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Tree.Node的用法示例。


在下文中一共展示了Node.getCdr方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: print

        public override void print(Node t, int n, bool p)
        {
            for (int i = Console.CursorLeft; i < n; i++)
                Console.Write(" ");

            if (!p)
                Console.Write("(");
            //Print "lambda"
            t.getCar().print(n);
            Console.Write(" ");

            Node second = t.getCdr().getCar();
            if (second.isPair())
            {
                second.print(n, false);
            }
            Console.WriteLine();
            Node term = t.getCdr().getCdr();
            while(!term.isNull())
            {
                term.getCar().print(n + 4);
                term = term.getCdr();
                Console.WriteLine();
            }
            Nil.getNil().print(n,true);
        }
開發者ID:matthewjwolff,項目名稱:SchemePrettyPrinter,代碼行數:26,代碼來源:Lambda.cs

示例2: print

        public override void print(Node t, int n, bool p)
        {
            // TODO: Implement this function.
            //  Console.Write("".PadLeft(n));
            if (!p)
            {
                Console.Write("".PadLeft(n) + '(');
            }
            t.getCar().print(0, !p);
            //  if(!t.getCdr().isNull())
            //  {
            //      Console.Write(" ");
            //  }
            if(t.getCdr().isNull())
            {
                t.getCdr().print(0, true);
                //  Console.WriteLine();
            }
            else {
                Console.Write(" ");
                t.getCdr().print(n, true);
            }

            //  if(t.getCdr().isNull())
            //  {
            //      Console.WriteLine();
            //  }
        }
開發者ID:CSC4101Projects,項目名稱:Project1,代碼行數:28,代碼來源:Regular.cs

示例3: print

        public override void print(Node t, int n, bool p)
        {
            Console.Write("".PadLeft(n));
               Console.Write("(lambda");

               Node Num2Node = t.getCdr().getCar();
               if (Num2Node.isPair())
               {
             Num2Node.print(0,false);
               }
               else
               {
              Console.Error.Write("Syntax Error with Lambda (Num2Node)");
               }

               Console.Write("".PadLeft(n));

               Node Num3Node = t.getCdr().getCdr().getCar();

               if( Num3Node.isPair())
               {
               Num3Node.print(n+4, false);
               }
               else
               {
               Console.Error.Write("Syntax Error with Lambda (Num3Node)");
               }
               Console.Write("".PadLeft(n));
        }
開發者ID:CSC4101Projects,項目名稱:Project1,代碼行數:29,代碼來源:Lambda.cs

示例4: print

        public override void print(Node t, int n, bool p)
        {
            Console.Write("".PadLeft(n));
               if ( p != true)
               {
               Console.Write("(");
               }
               if(t.getCar().isPair())
               {
               t.getCar().print(0);
               }
               else
               {
               t.getCar().print(0, true);
               }
               Console.Write(" ");

            if(t.getCdr() is Nil)
            {
                Console.WriteLine(")");
            }
            else
            {
                t.getCdr().print(0, true);
            }
            //  Console.WriteLine();
        }
開發者ID:CSC4101Projects,項目名稱:Project1,代碼行數:27,代碼來源:Set.cs

示例5: print

        public override void print(Node t, int n, bool p)
        {
            // TODO: Implement this function.
            Console.Write("".PadLeft(n));
            Console.WriteLine("(let");
            Node bindings = t.getCdr().getCar();

            if (bindings.isPair())
            {
                bindings.print(0,false);
            }
            else
            {
                Console.Error.WriteLine("Syntax error for LET-BINDINGS");
            }

            Console.Write("".PadLeft(n));
            Node body = t.getCdr().getCdr();

            if (body.isPair())
            {
                body.print(n+4, true);
            }
            else
            {
                Console.Error.WriteLine("Syntax error for LET-BODY");
            }
            Console.Write("".PadLeft(n)+ ")");
        }
開發者ID:CSC4101Projects,項目名稱:Project1,代碼行數:29,代碼來源:Let.cs

示例6: eval

 public override Node eval(Node t, Environment e)
 {
     if(t.getCdr() is Closure)
         return e.lookup(t.getCar()).apply(t.getCdr());
     else
     {
         Node args = t.getCdr();
         Node param;
         if (args.getCar().isSymbol())
             param = new Cons(e.lookup((Node)args.GetCar()), Nil.getInstance());
         else
             param = new Cons((Node)args.GetCar(), Nil.getInstance());
         Node currentNode = param;
         args = args.getCdr();
         while (args != Nil.getInstance())
         {
             if (args.getCar().isSymbol())
                 currentNode.setCdr(new Cons(e.lookup(args.getCar()), Nil.getInstance()));
             else
                 currentNode.setCdr(new Cons(args.getCar(), Nil.getInstance()));
             currentNode = currentNode.getCdr();
             args = args.getCdr();
         }
         return e.lookup(t.getCar()).apply(param);
     }
 }
開發者ID:Lumenze,項目名稱:4101_prog2,代碼行數:26,代碼來源:Regular.cs

示例7: print

        public override void print(Node t, int n, bool p)
        {
            // TODO: Implement this function.
            Console.Write("".PadLeft(n));
            Console.Write("(define ");

            Node name = t.getCdr().getCar();
            name.print(n);

            Console.Write(" ");

            Node definition = t.getCdr().getCdr().getCar();
            if (definition.isNull())
            {
                Console.Error.Write("Syntax error with DEFINE-definition");
            }
            else if (definition.isPair())
            {
                Console.WriteLine();
                //  Console.Write("".PadLeft(n+4));
                definition.print(n+4);
            }
            else
            {
                definition.print(n);
            }
            // made n to 0
            //  Console.WriteLine();
            Console.WriteLine("".PadLeft(n) + ")");
        }
開發者ID:CSC4101Projects,項目名稱:Project1,代碼行數:30,代碼來源:Define.cs

示例8: print

 public override void print(Node t, int n, bool p)
 {
     for (int i = Console.CursorLeft; i < n; i++)
         Console.Write(" ");
     if (!p)
     {
         Console.Write("(");
     }
     //print "let"
     t.getCar().print(n);
     Console.WriteLine();
     Node rest = t.getCdr();
     if (rest.isPair())
     {
         rest.getCar().print(n + 4, false);
         Console.WriteLine();
         while ((rest = rest.getCdr()) != Nil.getNil())
         {
             rest.getCar().print(n + 4, false);
             Console.WriteLine();
         }
         Console.Write(")");
     }
     else t.getCdr().print(n, true);
 }
開發者ID:matthewjwolff,項目名稱:SchemePrettyPrinter,代碼行數:25,代碼來源:Let.cs

示例9: eval

 // REMEMBER: If not explictly false, then true.
 public Node eval(Node t, Environment e)
 {
     Node cond = t.getCdr().getCar(); // condition -> cadr(exp)
     if (cond == null)
     {
         Console.Error.WriteLine("Error: Null in Condition");
     }
     Node ifTrue = t.getCdr().getCdr().getCar(); // true -> caddr(exp)
     if (ifTrue == null)
     {
         Console.Error.WriteLine("Error: Null in True/If");
     }
     Node ifFalse = t.getCdr().getCdr().getCdr().getCar(); // false -> cadddr(exp)
     if (ifFalse == null)
     {
         Console.Error.WriteLine("Error: Null in False/Else");
     }
     bool checkTrueResult = checkTrue(t, e);
     if (checkTrueResult == true)
     {
         return ifTrue.eval(ifTrue, e);
     }
     else
     {
         return ifFalse.eval(ifFalse, e);
     }
 }
開發者ID:sbaldw2,項目名稱:CSC4101,代碼行數:28,代碼來源:If.cs

示例10: eval

        public override Node eval(Node exp, Environment env)
        {
            int length = Util.expLength(exp);
            if (length < 3)
            {
                Console.Error.WriteLine("Error: invalid expression");
                return Nil.getInstance();
            }
            Node second = exp.getCdr().getCar();
            Node name, value;
            if (length == 3 && second.isSymbol())
            {
                name = second;
                value = exp.getCdr().getCdr().getCar().eval(env);
                env.define(name, value);
                return null;
            }
            if (!second.isPair())
            {
                Console.Error.WriteLine("Error: invalid expression");
                return Nil.getInstance();
            }
            name = second.getCar();
            Node lambda = exp.getCdr();
            lambda.setCar(second.getCdr());
            lambda = new Cons(new Ident("lambda"), lambda);
            value = lambda.eval(env);
            env.define(name, value);

            return null;
        }
開發者ID:jktucn,項目名稱:SchemeInterpreter,代碼行數:31,代碼來源:Define.cs

示例11: eval

 public override Node eval(Node t, Environment e)
 {
     while (t.getCdr() != Nil.getInstance())
     {
         t = t.getCdr();
         if (t.getCar().GetType() != typeof(Cons))
         {
             Console.Error.WriteLine("Error: invalid argument");
             throw new InvalidOperationException();
         }
         if (t.getCar().getCar().eval(e) == BoolLit.getInstance(true))
         {
             t = t.getCar();
             while(t.getCdr() != Nil.getInstance())
             {
                 t = t.getCdr();
                 if (t.getCdr() == Nil.getInstance()) break;
                 t.getCar().eval(e);
             }
             return (Node)t.getCar().eval(e);
         }
         else if (t.getCar().getCar().eval(e) != BoolLit.getInstance(false))
         {
             Console.Error.WriteLine("Error: invalid argument");
             throw new InvalidOperationException();
         }
     }
     return Nil.getInstance();
 }
開發者ID:Lumenze,項目名稱:4101_prog2,代碼行數:29,代碼來源:Cond.cs

示例12: eval

 public override Node eval(Node exp, Environment env)
 {
     int length = Util.expLength(exp);
     if (length < 3)
     {
         Console.Error.WriteLine("Error: invalid expression");
         return Nil.getInstance();
     }
     Node second = exp.getCdr().getCar();
     while (second.isPair())
     {
         if (Util.expLength(second.getCar()) != 2)
         {
             Console.Error.WriteLine("Error: invalid expression");
             return Nil.getInstance();
         }
         second = second.getCdr();
     }
     second = exp.getCdr().getCar();
     Environment env1 = new Environment(env);
     while (second.isPair())
     {
         Node id = second.getCar().getCar();
         Node val = second.getCar().getCdr().getCar();
         env1.define(id, val);
         second = second.getCdr();
     }
     Node exp1 = exp.getCdr().getCdr();
     return Begin.evalBody(exp1, env1);
 }
開發者ID:jktucn,項目名稱:SchemeInterpreter,代碼行數:30,代碼來源:Let.cs

示例13: eval

 public override Node eval(Node t, Environment env)
 {
     //arg1: set!
     //arg2: variable
     //arg3: value
     env.assign(t.getCdr().getCar(), t.getCdr().getCdr().getCar().eval(env));
     return new StringLit("set done");
 }
開發者ID:matthewjwolff,項目名稱:Scheme4101,代碼行數:8,代碼來源:Set.cs

示例14: eval

 public override Node eval(Node t, Environment env)
 {
     Node bodystart = t.getCdr().getCar();
     Node expression = t.getCdr().getCdr().getCar();
     Environment e = new Environment(env);
     bodystart = evalLetBody(bodystart, e); //Should we be returning bodystart?
     return expression.eval(e); //Why return e?
 }
開發者ID:hcross2,項目名稱:4330-Project-2,代碼行數:8,代碼來源:Let.cs

示例15: print

        public override void print(Node t, int n, bool p)
        {
            // print leading spaces and '('
            if (n < 0)
            {
                n = -(n + 1);
            }
            Console.Write(new string(' ', n) + "(");
            // record the current indent
            // common out due to CursorLeft is not supported in mono
            //int indent = Console.CursorLeft - 1;
            pcount++;
            // first element is parinted with no leading space, no change line
            t.getCar().print(-1);
            // if 'if' is the only element (if) or (if . x)
            if(!t.getCdr().isPair())
            {
                pcount--;
                if (t.getCdr().isNull())
                {
                    t.getCdr().print(0, true);
                }
                else
                {
                    Console.Write(" . ");
                    t.getCdr().print(0);
                }
                return;
            }
            // second element is printed with 1 leading space, change line
            else
            {
                t = t.getCdr();
                t.getCar().print(1);
            }
            // following element is printed with further indent, change line
            while (t.getCdr().isPair())
            {
                t = t.getCdr();
                t.getCar().print(pcount * 4);
            }
            // print last element and ')'
            pcount--;
            if (t.getCdr().isNull())
            {
                // ')' is printed with indent, change line
                t.getCdr().print(pcount * 4, true);
            }
            else
            {
                Console.Write(new string(' ', pcount * 4) + ". ");
                t.getCdr().print(0);
                Console.WriteLine(new string(' ', pcount * 4) + ")");
            }


        }
開發者ID:jktucn,項目名稱:SchemePrettyPrinter,代碼行數:57,代碼來源:If.cs


注:本文中的Tree.Node.getCdr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。