Beispiel #1
0
        public static ElaList FromEnumerable(IEnumerable seq)
        {
            var list = ElaList.Empty;

            foreach (var e in seq)
            {
                list = new ElaList(list, ElaValue.FromObject(e));
            }

            return(list.Reverse());
        }
Beispiel #2
0
        public ElaList ToList()
        {
            var str = Value;
            var xs  = ElaList.Empty;

            for (var i = str.Length - 1; i > -1; i--)
            {
                xs = new ElaList(xs, new ElaValue(str[i]));
            }

            return(xs);
        }
Beispiel #3
0
        public virtual ElaList Reverse()
        {
            var newLst = ElaList.Empty;
            var lst    = this;

            while (lst != Empty)
            {
                newLst = new ElaList(newLst, lst.Value);
                lst    = lst.InternalNext;
            }

            return(newLst);
        }
Beispiel #4
0
        public IEnumerator <ElaValue> GetEnumerator()
        {
            ElaList xs = this;

            while (xs != Empty)
            {
                yield return(xs.InternalValue);

                var tl = xs.Tail().Ref;
                xs = tl as ElaList;

                if (xs == null)
                {
                    throw InvalidDefinition();
                }
            }
        }
Beispiel #5
0
        internal int GetLength()
        {
            ElaList xs    = this;
            var     count = 0;

            while (xs != Empty)
            {
                count++;

                var tl = xs.Tail().Ref;
                xs = tl as ElaList;

                if (xs == null)
                {
                    throw InvalidDefinition();
                }
            }

            return(count);
        }
Beispiel #6
0
 public ElaList(ElaList next, ElaValue value) : base(ElaTypeCode.List)
 {
     InternalNext  = next;
     InternalValue = value;
 }
Beispiel #7
0
 public ElaList(ElaList next, object value) : this(next, ElaValue.FromObject(value))
 {
 }