Beispiel #1
0
 public NonEmptyList <A> Append(NonEmptyList <A> x) =>
 IsEmpty ? x : new NonEmptyList <A>(UnsafeHead, UnsafeTail).Append(x);
 public NonEmptyList <Pair <A, B> > Product <B>(NonEmptyList <B> o) =>
 ZipWith <B, Pair <A, B> >(o, Pair <A, B> .pairF());
 public NonEmptyList <A> Append(NonEmptyList <A> x) => Append(x.List);
 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);
 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)));
 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));
 public static NonEmptyList <A> Flatten <A>(this NonEmptyList <NonEmptyList <A> > o) =>
 o.SelectMany(z => z);
 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)));
 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));
Beispiel #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));
Beispiel #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));
Beispiel #12
0
 public NonEmptyList <Pair <A, B> > Zip <B>(NonEmptyList <B> bs) => ZipWith <B, Pair <A, B> >(bs, a => b => a.And(b));
Beispiel #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));
Beispiel #14
0
 public NonEmptyList <A> Append(NonEmptyList <A> x)
 {
     return(IsEmpty ? x : new NonEmptyList <A>(UnsafeHead, UnsafeTail).Append(x));
 }
Beispiel #15
0
 public NonEmptyList <A> Append(NonEmptyList <A> x)
 {
     return(Append(x.List));
 }
Beispiel #16
0
 public static NonEmptyList <A> Flatten <A>(this NonEmptyList <NonEmptyList <A> > o)
 {
     return(o.SelectMany(z => z));
 }