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()); }
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); }
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); }
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(); } } }
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); }
public ElaList(ElaList next, ElaValue value) : base(ElaTypeCode.List) { InternalNext = next; InternalValue = value; }
public ElaList(ElaList next, object value) : this(next, ElaValue.FromObject(value)) { }