示例#1
0
文件: SList.cs 项目: j3ffb/scalesque
        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");
 }
示例#3
0
文件: SList.cs 项目: j3ffb/scalesque
 public NonEmptySList(T value, SList <T> next)
 {
     this.value = value;
     this.next  = next;
     length     = next.Length + 1;
 }
示例#4
0
文件: SList.cs 项目: j3ffb/scalesque
 public static Option <NonEmptySList <T> > unapply <T>(SList <T> list)
 {
     return(list.IsEmpty ? Option.None() : Option.Some((NonEmptySList <T>)list));
 }
示例#5
0
文件: SList.cs 项目: j3ffb/scalesque
 public void Reset()
 {
     current = null;
 }
示例#6
0
文件: SList.cs 项目: j3ffb/scalesque
 public SListEnumerator(SList <T> first)
 {
     this.first = first;
 }
示例#7
0
文件: SList.cs 项目: j3ffb/scalesque
 /// <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));
 }