예제 #1
0
        public DreamList CreateCopy(int start = 1, int end = 0)
        {
            if (start == 0)
            {
                ++start;             //start being 0 and start being 1 are equivalent
            }
            if (end > _values.Count + 1)
            {
                throw new Exception("list index out of bounds");
            }
            if (end == 0)
            {
                end = _values.Count + 1;
            }

            DreamList copy = Create(end);

            for (int i = start; i < end; i++)
            {
                DreamValue value = _values[i - 1];

                copy._values.Add(value);
                if (ContainsKey(value))
                {
                    copy.SetValue(value, _associativeValues[value]);
                }
            }

            return(copy);
        }
예제 #2
0
        public static DreamList Create(string[] collection)
        {
            var list = new DreamList(collection.Length);

            foreach (string value in collection)
            {
                list._values.Add(new DreamValue(value));
            }

            return(list);
        }
예제 #3
0
        public static DreamList Create(List <DreamObject> collection)
        {
            var list = new DreamList(collection.Count);

            foreach (DreamObject value in collection)
            {
                list._values.Add(new DreamValue(value));
            }

            return(list);
        }
예제 #4
0
        public DreamList Union(DreamList other)
        {
            DreamList newList = new DreamList();

            newList._values = _values.Union(other.GetValues()).ToList();
            foreach ((DreamValue key, DreamValue value) in other.GetAssociativeValues())
            {
                newList.SetValue(key, value);
            }

            return(newList);
        }