Ejemplo n.º 1
0
        public virtual Pair ToList()
        {
            Pair result = null;

            foreach (object o in this)
            {
                result = new Pair(o, result);
            }
            return((Pair)result.Reverse());
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public virtual Pair ToList()
        {
            Pair result = null;

            foreach (object o in this)
            {
                result = new Pair(o, result);
            }
            return (Pair)result.Reverse();
        }
Ejemplo n.º 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();
 }
Ejemplo n.º 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;
        }