예제 #1
0
        public virtual Pair ToList()
        {
            Pair result = null;

            foreach (object o in this)
            {
                result = new Pair(o, result);
            }
            return((Pair)result.Reverse());
        }
예제 #2
0
파일: Compiler.cs 프로젝트: wisemoth/LSharp
        public static object CompileQuasiQuote(int level, object arg, Environment environment)
        {
            if (level == 0)
            {
                return(Compile1(arg, environment));
            }

            if (arg is ISequence)
            {
                ISequence c = (ISequence)arg;
                if (c.First() == UNQUOTE)
                {
                    return(new Pair(UNQUOTE, new Pair(CompileQuasiQuote(level - 1, Runtime.Car(Runtime.Cdr(arg)), environment))));
                }

                if ((level == 1) && (c.First() == UNQUOTE_SPLICING))
                {
                    return(new Pair(UNQUOTE_SPLICING, new Pair(CompileQuasiQuote(level - 1, Runtime.Car(Runtime.Cdr(arg)), environment))));
                }

                if (c.First() == QUASIQUOTE)
                {
                    return(new Pair(QUASIQUOTE, new Pair(CompileQuasiQuote(level + 1, Runtime.Car(Runtime.Cdr(arg)), environment))));
                }

                Pair r = null;
                foreach (object o in c)
                {
                    r = new Pair(CompileQuasiQuote(level, o, environment), r);
                }

                return(r.Reverse());
            }

            return(arg);
        }
예제 #3
0
        public virtual Pair ToList()
        {
            Pair result = null;

            foreach (object o in this)
            {
                result = new Pair(o, result);
            }
            return (Pair)result.Reverse();
        }
예제 #4
0
 public static ISequence Range(int start, int finish, int step)
 {
     Pair result = null;
     for (int i = start; i < finish; i += step)
     {
         result = new Pair(i, result);
     }
     return result.Reverse();
 }
예제 #5
0
        public static object CompileQuasiQuote(int level, object arg, Environment environment)
        {
            if (level == 0)
                return Compile1(arg, environment);

            if (arg is ISequence)
            {
                ISequence c = (ISequence)arg;
                if (c.First() == UNQUOTE)
                {
                     return new Pair(UNQUOTE,new Pair(CompileQuasiQuote(level - 1, Runtime.Car(Runtime.Cdr(arg)),environment)));
                }

                if ((level == 1) && (c.First() == UNQUOTE_SPLICING))
                {
                    return new Pair(UNQUOTE_SPLICING, new Pair(CompileQuasiQuote(level - 1, Runtime.Car(Runtime.Cdr(arg)), environment)));
                }

                if (c.First() == QUASIQUOTE)
                {
                    return new Pair(QUASIQUOTE, new Pair(CompileQuasiQuote(level + 1, Runtime.Car(Runtime.Cdr(arg)), environment)));
                }

                Pair r = null;
                foreach (object o in c)
                {
                    r = new Pair(CompileQuasiQuote(level, o,environment), r);
                }

                return r.Reverse();
            }

            return arg;
        }