Beispiel #1
0
        public ScheminList ToList()
        {
            ScheminList list = new ScheminList();
            list.Quote();

            foreach (IScheminType type in List)
            {
                list.Append(type);
            }

            return list;
        }
Beispiel #2
0
        public Environment MakeEnvironment(ScheminList values, Evaluator eval)
        {
            if ((this.Arguments as ScheminList) != null)
            {
                ScheminList argslist = (ScheminList) this.Arguments;
                IScheminType first = argslist.Car();
                ScheminList rest = argslist.Cdr();
                IScheminType firstArg = values.Car();
                ScheminList restArgs = values.Cdr();

                Environment args = new Environment();
                args.parent = this.Closure;

                for (; ;)
                {
                    if (first.GetType() == typeof(ScheminList))
                    {
                        ScheminList tempFirst = (ScheminList) first;
                        if (tempFirst.Empty)
                        {
                            break;
                        }
                    }

                    ScheminAtom atom = (ScheminAtom) first;
                    if (atom.Name == ".")
                    {
                        restArgs.Cons(firstArg);
                        restArgs.Quote();
                        args.AddBinding((ScheminAtom) rest.Car(), restArgs);
                        break;
                    }

                    args.AddBinding((ScheminAtom) first, firstArg);

                    first = rest.Car();
                    firstArg = restArgs.Car();
                    rest = rest.Cdr();
                    restArgs = restArgs.Cdr();
                }

                return args;
            }
            else
            {
                Environment args = new Environment();
                args.parent = this.Closure;
                values.Quote();
                args.AddBinding((ScheminAtom) this.Arguments, values);
                return args;
            }
        }