示例#1
0
        //////////////////////////////////////////////////////////////////////////////

        public static Obj CreateSeq(bool[] vals, int len)
        {
            if (len == 0)
            {
                return(EmptySeqObj.singleton);
            }

            Obj[] objs = new Obj[len];
            for (int i = 0; i < len; i++)
            {
                objs[i] = SymbObj.Get(vals[i]);
            }
            return(ArrayObjs.Create(objs));
        }
示例#2
0
        public static Obj CreateSeq(Obj[] objs)
        {
            int len = objs.Length;

            if (len == 0)
            {
                return(EmptySeqObj.singleton);
            }

            if (objs[0].IsInt())
            {
                for (int i = 1; i < len; i++)
                {
                    if (!objs[i].IsInt())
                    {
                        return(ArrayObjs.Create(objs));
                    }
                }

                long[] longs = new long[len];
                for (int i = 0; i < len; i++)
                {
                    longs[i] = objs[i].GetLong();
                }
                return(IntArrayObjs.Create(longs));
            }

            if (objs[0].IsFloat())
            {
                for (int i = 1; i < len; i++)
                {
                    if (!objs[i].IsFloat())
                    {
                        return(ArrayObjs.Create(objs));
                    }
                }

                double[] doubles = new double[len];
                for (int i = 0; i < len; i++)
                {
                    doubles[i] = objs[i].GetDouble();
                }
                return(FloatArrayObjs.Create(doubles));
            }

            return(ArrayObjs.Create(objs));
        }
示例#3
0
        public static Obj CreateSeq(Obj[] objs, int len)
        {
            if (len == 0)
            {
                return(EmptySeqObj.singleton);
            }

            for (int i = 0; i < len; i++)
            {
                if (!objs[i].IsInt())
                {
                    return(ArrayObjs.Create(objs, len));
                }
            }

            long[] longs = new long[len];
            for (int i = 0; i < len; i++)
            {
                longs[i] = objs[i].GetLong();
            }
            return(IntArrayObjs.Create(longs));
        }