Ejemplo n.º 1
0
        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");
 }
Ejemplo n.º 3
0
 public NonEmptySList(T value, SList <T> next)
 {
     this.value = value;
     this.next  = next;
     length     = next.Length + 1;
 }
Ejemplo n.º 4
0
 public static Option <NonEmptySList <T> > unapply <T>(SList <T> list)
 {
     return(list.IsEmpty ? Option.None() : Option.Some((NonEmptySList <T>)list));
 }
Ejemplo n.º 5
0
 public void Reset()
 {
     current = null;
 }
Ejemplo n.º 6
0
 public SListEnumerator(SList <T> first)
 {
     this.first = first;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Prepends the other to this until the other SList is Nil
 /// </summary>
 /// <param name="other"></param>
 /// <returns>NonEmptySList&lt;T&gt;</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));
 }