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 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 #3
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);