当前位置: 首页>>代码示例>>C#>>正文


C# Node.isNull方法代码示例

本文整理汇总了C#中Tree.Node.isNull方法的典型用法代码示例。如果您正苦于以下问题:C# Node.isNull方法的具体用法?C# Node.isNull怎么用?C# Node.isNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree.Node的用法示例。


在下文中一共展示了Node.isNull方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: pairup

 //Function for pairing up arguments with corresponding symbols
 private static void pairup(Node parms, Node args, Environment env)
 {
     //if null return nothing
     if (parms.isNull() && args.isNull())
     {
         return;
     }
     //check the symbol type
     if (parms.isSymbol())
     {
         env.define(parms, args);
     }
     //depending on the parameter, check the # of required valid arguments
     else if (parms.isNull() || args.isNull())
     {
         Console.get_Error().WriteLine("Error: wrong number of arguments");
     }
     //look for values in different env w/ closure pointer? idk how to explain this
     else if (parms.isPair() && args.isPair())
     {
         env.define(parms.getCar(), args.getCar());
         Closure.pairup(parms.getCdr(), args.getCdr(), env);
     }
     else
     {
         Console.get_Error().WriteLine("Error: invalid expression");
     }
 }
开发者ID:Profitlol,项目名称:prog2-baum,代码行数:29,代码来源:Closure.cs

示例2: print

 public override void print(Node t, int n, bool p)
 {
     var spaces = "";
     if(n >= 0) spaces = new string(' ', n);
     if(!p) { Console.Write(spaces+"("); p = true; }
     n = 0;
     do
     {
         t.getCar().print(n, false);
         t = t.getCdr();
         if(!t.isNull())
             Console.Write(' ');
     } while (t.getCdr() != null);
     if (t.isPair() || t.isNull())
         t.print(n, p);
     else
     {
         Console.Write(". ");
         t.print(n, p);
         Console.Write(")");
     }
 }
开发者ID:tlecom3,项目名称:4101_prog1,代码行数:22,代码来源:Regular.cs

示例3: expLength

        //obtain experession length of a statement
        public static int expLength(Node exp)
        {
            if (exp.isNull())
                return 0;

            if (!exp.isPair())
                return -1;

            int num = Util.expLength(exp.getCdr());
            if (num == -1)
                return -1;

            return num + 1;
        }
开发者ID:Profitlol,项目名称:prog2-baum,代码行数:15,代码来源:Util.cs

示例4: printVar

 private static void printVar(Node t, int n, bool p)
 {
     string spaces = new string(' ', n);
     if (!p) { Console.Write(spaces + "("); p = true; }
     n = 0;
     do
     {
         t.getCar().print(n, false);
         t = t.getCdr();
         if (!t.isNull())
             Console.Write(' ');
     } while (t.getCdr() != null);
     t.print(n, p);
 }
开发者ID:Lumenze,项目名称:4101_prog1,代码行数:14,代码来源:Define.cs

示例5: define

 //added from here and down, possible errors
 private static int define(Node bind, Environment env, Environment lenv)
 {
     if (bind.isNull())
     {
         return 0;
     }
     Node car = bind.getCar();
     if (Util.expLength(car) != 2)
     {
         return -1;
     }
     Node car2 = car.getCar(); // (car x)
     Node value = car.getCdr().getCar().eval(env); //(eval (cadr x) env)
     lenv.define(car2, value); // (list (car x) (eval (cadr x) env)))
     return Let.define(bind.getCdr(), env, lenv);
 }
开发者ID:Profitlol,项目名称:prog2-baum,代码行数:17,代码来源:Let.cs

示例6: mapEval

 //mapping element for evaluation, i think it's similar when you are trying to map some exp to a certain lambda
 //Ex) (map (lambda (x) (* -1 x)) '(1 2 3 4))
 //reference http://courses.cs.washington.edu/courses/cse341/02sp/scheme/apply-eval.html
 public static Node mapEval(Node exp, Environment env)
 {
     if (exp.isNull())
         return Nil.getInstance();
     return new Cons(exp.getCar().eval(env), Util.mapEval(exp.getCdr(), env));
 }
开发者ID:Profitlol,项目名称:prog2-baum,代码行数:9,代码来源:Util.cs

示例7: apply1

 //if arg's length = 1
 private Node apply1(Node arg1)
 {
     string name = this.symbol.getName();
     bool flag = name.Equals("car");
     Node result;
     if (flag)
     {
         result = arg1.getCar();
     }//end if
     else
     {
         bool flag2 = name.Equals("cdr");
         if (flag2)
         {
             result = arg1.getCdr();
         }//end if
         else
         {
             bool flag3 = name.Equals("number?");
             if (flag3)
             {
                 result = BoolLit.getInstance(arg1.isNumber());
             }//end if
             else
             {
                 bool flag4 = name.Equals("symbol?");
                 if (flag4)
                 {
                     result = BoolLit.getInstance(arg1.isSymbol());
                 }//end if
                 else
                 {
                     bool flag5 = name.Equals("null?");
                     if (flag5)
                     {
                         result = BoolLit.getInstance(arg1.isNull());
                     }//end if
                     else
                     {
                         bool flag6 = name.Equals("pair?");
                         if (flag6)
                         {
                             result = BoolLit.getInstance(arg1.isPair());
                         }//end if
                         else
                         {
                             bool flag7 = name.Equals("procedure?");
                             if (flag7)
                             {
                                 result = BoolLit.getInstance(arg1.isProcedure());
                             }//end if
                             else
                             {
                                 bool flag8 = name.Equals("write");// i am not sure if im handling this correctly
                                 if (flag8)
                                 {
                                     arg1.print(-1);
                                     result = Unspecific.getInstance();
                                 }//end if
                                 else
                                 {
                                     bool flag9 = name.Equals("display"); // i am not sure if im handling this correctly
                                     if (flag9)
                                     {
                                         StringLit.printDoubleQuotes = false;
                                         arg1.print(-1);
                                         StringLit.printDoubleQuotes = true;
                                         result = Unspecific.getInstance();
                                     }//end if
                                     else
                                     {
                                         bool flag10 = name.Equals("load");
                                         if (flag10)
                                         {
                                             bool flag11 = !arg1.isString();
                                             if (flag11)
                                             {
                                                 Console.Error.WriteLine("Error: wrong type of argument");
                                                 result = Nil.getInstance();
                                             }
                                             else
                                             {
                                                 string stringVal = arg1.getStringVal();
                                                 try
                                                 {
                                                     //not sure why it has to be Parse.Scanner to call this
                                                     Parse.Scanner s = new Parse.Scanner(File.OpenText(stringVal));
                                                     TreeBuilder b = new TreeBuilder();
                                                     Parse.Parser parser = new Parse.Parser(s, b);
                                                     for (Node node = (Node)parser.parseExp(); node != null; node = (Node)parser.parseExp())
                                                     {
                                                         node.eval(Scheme4101.env);
                                                     }
                                                 }
                                                 catch (SystemException)
                                                 {
                                                     Console.Error.WriteLine("Could not find file " + stringVal);
                                                 }
                                                 result = Unspecific.getInstance();
//.........这里部分代码省略.........
开发者ID:Profitlol,项目名称:prog2-baum,代码行数:101,代码来源:BuiltIn.cs

示例8: checkSymbols

 //check if valid statement
 private bool checkSymbols(Node parms)
 {
     return parms.isNull() || parms.isSymbol() || (parms.isPair() && parms.getCar().isSymbol() && this.checkSymbols(parms.getCdr()));
 }
开发者ID:Profitlol,项目名称:prog2-baum,代码行数:5,代码来源:Define.cs


注:本文中的Tree.Node.isNull方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。