Пример #1
0
        //last arg must be seq
        internal Object apply(params Object[] args)
        {
            Object      f     = Primitives.arg(0, args);
            IEnumerator tail  = (IEnumerator)get_enum_gf.Invoke(args[args.Length - 1]);
            ArrayList   fargs = new ArrayList();

            for (int i = 1; i < args.Length - 1; i++)
            {
                fargs.Add(args[i]);
            }
            while (tail.MoveNext())
            {
                fargs.Add(tail.Current);
            }
            return(Util.InvokeObject(f, fargs.ToArray()));
        }
Пример #2
0
        internal Object map_to_list(params Object[] args)
        {
            Object f = Primitives.arg(0, args);

            IEnumerator[] enums = new IEnumerator[args.Length - 1];
            for (int i = 0; i < enums.Length; i++)
            {
                enums[i] = (IEnumerator)get_enum_gf.Invoke(Primitives.arg(i + 1, args));
            }
            //n.b. setting up arg array which will be reused
            //mean functions cannot assume ownership of args w/o copying them
            Object[] fargs = new Object[enums.Length];
            Cons     ret   = null;
            Cons     tail  = null;

            while (true)
            {
                for (int i = 0; i < enums.Length; i++)
                {
                    if (enums[i].MoveNext())
                    {
                        fargs[i] = enums[i].Current;
                    }
                    else             //bail on shortest
                    {
                        return(ret);
                    }
                }

                Object x    = Util.InvokeObject(f, fargs);
                Cons   node = new Cons(x, null);
                if (ret == null)
                {
                    ret = tail = node;
                }
                else
                {
                    tail = tail.rest = node;
                }
            }
        }
Пример #3
0
        internal Object internf(params Object[] args)
        {
            String sym = (String)Primitives.arg(0, args);

            return(symbolTable.intern(sym));
        }
Пример #4
0
        internal Object loadf(params Object[] args)
        {
            String path = (String)Primitives.arg(0, args);

            return(LoadFile(path));
        }
Пример #5
0
        internal Object evalf(params Object[] args)
        {
            Object x = Primitives.arg(0, args);

            return(eval(x, globalenv));
        }