Example #1
0
 public NonEmptyList <A> Append(NonEmptyList <A> x) =>
 IsEmpty ? x : new NonEmptyList <A>(UnsafeHead, UnsafeTail).Append(x);
Example #2
0
 public NonEmptyList <Pair <A, B> > Product <B>(NonEmptyList <B> o) =>
 ZipWith <B, Pair <A, B> >(o, Pair <A, B> .pairF());
Example #3
0
 public NonEmptyList <A> Append(NonEmptyList <A> x) => Append(x.List);
Example #4
0
 public static Pair <NonEmptyList <A>, NonEmptyList <B> > Unzip <A, B>(this NonEmptyList <Pair <A, B> > p) =>
 p.Tail.Get.Unzip().BinarySelect(ta => p.Head.Get._1.Get & ta, tb => p.Head.Get._2.Get & tb);
Example #5
0
 public NonEmptyList <C> ProductWith <B, C>(NonEmptyList <B> o, Func <A, Func <B, C> > f) =>
 SelectMany <C>(a => o.Select <C>(b => f(a)(b)));
Example #6
0
 public static NonEmptyList <B> ApplyZip <A, B>(this NonEmptyList <Func <A, B> > f, NonEmptyList <A> o) =>
 f.ZipWith <A, B>(o, a => b => a(b));
Example #7
0
 public static NonEmptyList <A> Flatten <A>(this NonEmptyList <NonEmptyList <A> > o) =>
 o.SelectMany(z => z);
Example #8
0
 public static NonEmptyList <C> SelectMany <A, B, C>(this NonEmptyList <A> ps, Func <A, NonEmptyList <B> > p, Func <A, B, C> f) =>
 SelectMany(ps, a => Select(p(a), b => f(a, b)));
Example #9
0
 public static NonEmptyList <B> Apply <A, B>(this NonEmptyList <Func <A, B> > f, NonEmptyList <A> o) =>
 f.ProductWith <A, B>(o, a => b => a(b));
Example #10
0
 public static NonEmptyList <B> Select <A, B>(this NonEmptyList <A> ps, Func <A, B> f) =>
 new NonEmptyList <B>(f(ps.Head.Get), ps.Tail.Get.Select(f));
Example #11
0
 public static NonEmptyList <B> SelectMany <A, B>(this NonEmptyList <A> ps, Func <A, NonEmptyList <B> > f) =>
 f(ps.Head.Get).Append(ps.Tail.Get.SelectMany(a => f(a).List));
Example #12
0
 public NonEmptyList <Pair <A, B> > Zip <B>(NonEmptyList <B> bs) => ZipWith <B, Pair <A, B> >(bs, a => b => a.And(b));
Example #13
0
 public NonEmptyList <C> ZipWith <B, C>(NonEmptyList <B> bs, Func <A, Func <B, C> > f) =>
 new NonEmptyList <C>(f(head)(bs.head), tail.ZipWith(bs.tail, f));
Example #14
0
 public NonEmptyList <A> Append(NonEmptyList <A> x)
 {
     return(IsEmpty ? x : new NonEmptyList <A>(UnsafeHead, UnsafeTail).Append(x));
 }
Example #15
0
 public NonEmptyList <A> Append(NonEmptyList <A> x)
 {
     return(Append(x.List));
 }
Example #16
0
 public static NonEmptyList <A> Flatten <A>(this NonEmptyList <NonEmptyList <A> > o)
 {
     return(o.SelectMany(z => z));
 }