当前位置: 首页>>代码示例>>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;未经允许,请勿转载。