Example #1
0
 public static Pair <DiffList <A>, DiffList <B> > Unzip <A, B>(this DiffList <Pair <A, B> > p)
 {
     return(p.FoldRight <Pair <DiffList <A>, DiffList <B> > >(
                (x, y) => (x._1.Get + y._1.Get).And(x._2.Get + y._2.Get)
                , DiffList <A> .Empty.And(DiffList <B> .Empty)
                ));
 }
Example #2
0
 public DiffList <Pair <A, B> > Product <B>(DiffList <B> o)
 {
     return(ProductWith <B, Pair <A, B> >(o, Pair <A, B> .pairF()));
 }
Example #3
0
 public DiffList <C> ProductWith <B, C>(DiffList <B> o, Func <A, Func <B, C> > f)
 {
     return(this.SelectMany(a => o.Select(b => f(a)(b))));
 }
Example #4
0
 public static DiffList <A> DiffListValue <A>(this A a)
 {
     return(DiffList <A> .diffList(l => a + l));
 }
Example #5
0
 public static DiffList <A> Flatten <A>(this DiffList <DiffList <A> > o)
 {
     return(o.SelectMany(z => z));
 }
Example #6
0
 public static DiffList <C> SelectMany <A, B, C>(this DiffList <A> ps, Func <A, DiffList <B> > p, Func <A, B, C> f)
 {
     return(SelectMany(ps, a => Select(p(a), b => f(a, b))));
 }
Example #7
0
 public static DiffList <B> Apply <A, B>(this DiffList <Func <A, B> > f, DiffList <A> o)
 {
     return(f.ProductWith <A, B>(o, a => b => a(b)));
 }
Example #8
0
 public static DiffList <B> SelectMany <A, B>(this DiffList <A> ps, Func <A, DiffList <B> > f)
 {
     return(ps.FoldRight((a, b) => f(a) * b, DiffList <B> .Empty));
 }
Example #9
0
 public DiffList <Pair <A, B> > Product <B>(DiffList <B> o) =>
 ProductWith(o, Pair <A, B> .pairF());
Example #10
0
 public static DiffList <A> DiffListValue <A>(this A a) =>
 DiffList <A> .diffList(l => a + l);
Example #11
0
 public static DiffList <A> Flatten <A>(this DiffList <DiffList <A> > o) =>
 o.SelectMany(z => z);
Example #12
0
 public static DiffList <B> Select <A, B>(this DiffList <A> ps, Func <A, B> f) =>
 ps.FoldRight((a, b) => f(a) + b, DiffList <B> .Empty);