public bool MoveNext() { if (current == null) { current = first; } else { current = current.Tail; } return(!current.IsEmpty); }
public override void Because() { list = Nil <string> .Instance + "blah" + "Jubbins" + "Your more general gubbins"; list2 = SList.apply("Your more general gubbins", "Jubbins", "blah"); }
public NonEmptySList(T value, SList <T> next) { this.value = value; this.next = next; length = next.Length + 1; }
public static Option <NonEmptySList <T> > unapply <T>(SList <T> list) { return(list.IsEmpty ? Option.None() : Option.Some((NonEmptySList <T>)list)); }
public void Reset() { current = null; }
public SListEnumerator(SList <T> first) { this.first = first; }
/// <summary> /// Prepends the other to this until the other SList is Nil /// </summary> /// <param name="other"></param> /// <returns>NonEmptySList<T></returns> private NonEmptySList <T> prependWith(SList <T> other) { //i think this construct will allow tail call optimisation in .net 4.0 //http://stackoverflow.com/questions/491376/why-doesnt-net-c-optimize-for-tail-call-recursion return(other.Length == 0 ? this : Prepend(other.Head).prependWith(other.Tail)); }