示例#1
0
 private CCCons Index(CCIdentifier exp, CCCons env, int i)
 {
     if (env == null)
     {
         return null;
     }
     else
     {
         var j = Index2(exp, env.car as CCCons, 1);
         if (j == null)
         {
             return Index(exp, env.cdr as CCCons, i + 1);
         }
         else
         {
             return new CCCons(new CCInt() { value = i }, j);
         }
     }
 }
示例#2
0
 private CCObject Index2(CCIdentifier exp, CCCons env, int j)
 {
     if (env == null || env.car == null)
     {
         return null;
     }
     else
     {
         if(env.car.GetType() == typeof(CCCons)) // function or macro
         {
             if (env.caar.ToString() == exp.ToString())
             {
                 return new CCCons(new CCInt() { value = j }, env.cdar);
             }
             else
             {
                 return Index2(exp, env.cdr as CCCons, j + 1);
             }
         }
         else // atom
         {
             if (env.car.ToString() == exp.ToString())
             {
                 return new CCInt() { value = j };
             }
             else
             {
                 return Index2(exp, env.cdr as CCCons, j + 1);
             }
         }
     }
 }
示例#3
0
 private CCCons Index(CCIdentifier exp, CCCons env)
 {
     return Index(exp, env, 1);
 }