Example #1
0
        public static T TakeFirst <T>(this NonEmptyList <T> self)
        {
            var enumerator = self.GetEnumerator();

            enumerator.MoveNext();

            return(enumerator.Current);
        }
Example #2
0
        private static NonEmptyList <T> ConstructRecursively(IEnumerator <T> enumerator)
        {
            var current = enumerator.Current;

            if (enumerator.MoveNext())
            {
                return(NonEmptyList <T> .ConsNEL(current, ConstructRecursively(enumerator)));
            }
            else
            {
                return(NonEmptyList <T> .Singleton(current));
            }
        }
Example #3
0
 public static FuncyList <T> Take <T>(this NonEmptyList <T> self, int length)
 {
     return(NonEmptyListTCNT.ToFuncyList(self).Take(length));
 }
Example #4
0
 public static FuncyList <T> ToFuncyList <T>(this NonEmptyList <T> self)
 {
     return(FuncyList <T> .Construct(self.ToArray()));
 }
Example #5
0
 public override NonEmptyList <TReturn> FMap <TReturn>(Func <T, TReturn> f)
 {
     return(NonEmptyList <TReturn> .Singleton(f(this.value)));
 }
Example #6
0
 public override NonEmptyList <TReturn> FMap <TReturn>(Func <T, TReturn> f)
 {
     return(NonEmptyList <TReturn> .ConsNEL(f(this.head), this.tail.FMap(f)));
 }
Example #7
0
 public NonEmptyList <TReturn> ComputeWith <TReturn>(Func <T, NonEmptyList <TReturn> > f)
 {
     return(NonEmptyList <TReturn> .Construct(this.SelectMany(v => f(v))));
 }
Example #8
0
 public ConsNEL(T head, NonEmptyList <T> tail)
 {
     this.head = head;
     this.tail = tail;
 }
Example #9
0
 public NonEmptyList <T> Point(T value)
 {
     return(NonEmptyList <T> .Singleton(value));
 }
Example #10
0
 public NonEmptyList <TReturn> ApplyRight <TReturn>(NonEmptyList <TReturn> other)
 {
     return(other);
 }
Example #11
0
 public NonEmptyList <T> ApplyLeft <TReturn>(NonEmptyList <TReturn> other)
 {
     return(this);
 }
Example #12
0
 public NonEmptyList <TReturn> Apply <TReturn>(NonEmptyList <Func <T, TReturn> > f)
 {
     return(NonEmptyList <TReturn> .Construct(f.SelectMany(fElem => this.FMap(fElem))));
 }
Example #13
0
 public static NonEmptyList <T> ConsNEL(T head, NonEmptyList <T> tail)
 {
     return(new ConsNEL <T>(head, tail));
 }