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) )); }
public DiffList <Pair <A, B> > Product <B>(DiffList <B> o) { return(ProductWith <B, Pair <A, B> >(o, Pair <A, B> .pairF())); }
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)))); }
public static DiffList <A> DiffListValue <A>(this A a) { return(DiffList <A> .diffList(l => a + l)); }
public static DiffList <A> Flatten <A>(this DiffList <DiffList <A> > o) { return(o.SelectMany(z => z)); }
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)))); }
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))); }
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)); }
public DiffList <Pair <A, B> > Product <B>(DiffList <B> o) => ProductWith(o, Pair <A, B> .pairF());
public static DiffList <A> DiffListValue <A>(this A a) => DiffList <A> .diffList(l => a + l);
public static DiffList <A> Flatten <A>(this DiffList <DiffList <A> > o) => o.SelectMany(z => z);
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);