/** * Creates a {@link P8} by adding the given element to the current {@link P4} * * @param el the element to append * @return A {@link P8} containing the original {@link P4} with the extra element added at the end */ public final <E, F, G, H> P8<A, B, C, D, E, F, G, H> append(P4<E, F, G, H> el) { return P.p(_1(), _2(), _3(), _4(), el._1(), el._2(), el._3(), el._4()); }
/** * Promotes this function to zip two TreeZippers, applying the function lock-step over both zippers in all directions. * The structure of the resulting TreeZipper is the structural intersection of the two TreeZippers. * * @return A function that zips two TreeZippers with this function. */ public static <A, B, C> F2<TreeZipper<A>, TreeZipper<B>, TreeZipper<C>> zipTreeZipperM(final F2<A, B, C> f) { return (ta, tb) -> { final F2<Stream<Tree<A>>, Stream<Tree<B>>, Stream<Tree<C>>> sf = zipStreamM(treeM(f)); final F2<Stream<P3<Stream<Tree<A>>, A, Stream<Tree<A>>>>, Stream<P3<Stream<Tree<B>>, B, Stream<Tree<B>>>>, Stream<P3<Stream<Tree<C>>, C, Stream<Tree<C>>>>> pf = zipStreamM((pa, pb) -> p(zipStreamM(treeM(f)).f(pa._1(), pb._1()), f.f(pa._2(), pb._2()), zipStreamM(treeM(f)).f(pa._3(), pb._3()))); return treeZipper(treeM(f).f(ta.p()._1(), tb.p()._1()), sf.f(ta.lefts(), tb.lefts()), sf.f(ta.rights(), tb.rights()), pf.f(ta.p()._4(), tb.p()._4())); }; }
public D _4() { return P4.this._4(); } };
public C _3() { return P4.this._3(); }
public A _1() { return p._2(); }
public A _1() { return P4.this._1(); }
/** * Returns the 1-product projection over the fourth element. * * @return the 1-product projection over the fourth element. */ public final P1<D> _4_() { return F1Functions.lazy(P4.<A, B, C, D>__4()).f(this); }
/** * Returns the 1-product projection over the second element. * * @return the 1-product projection over the second element. */ public final P1<B> _2_() { return F1Functions.lazy(P4.<A, B, C, D>__2()).f(this); }
/** * Returns the 1-product projection over the first element. * * @return the 1-product projection over the first element. */ public final P1<A> _1_() { return F1Functions.lazy(P4.<A, B, C, D>__1()).f(this); }
/** * Returns the 1-product projection over the third element. * * @return the 1-product projection over the third element. */ public final P1<C> _3_() { return F1Functions.lazy(P4.<A, B, C, D>__3()).f(this); }
/** * Maps a function across a TreeZipper in parallel. * * @param za A TreeZipper to map across in parallel. * @param f A function to map across the given TreeZipper. * @return A promise of a new TreeZipper with the given function applied to each element of the tree. */ public <A, B> Promise<TreeZipper<B>> parMap(final TreeZipper<A> za, final F<A, B> f) { final F<Tree<A>, Tree<B>> tf = Tree.<A, B>fmap_().f(f); final P4<Tree<A>, Stream<Tree<A>>, Stream<Tree<A>>, Stream<P3<Stream<Tree<A>>, A, Stream<Tree<A>>>>> p = za.p(); return mapM(p._4(), p3 -> parMap(p3._3(), tf).apply(promise(f).f(p3._2()).apply( parMap(p3._1(), tf).fmap(P.p3())))).apply(parMap(za.rights(), tf).apply( parMap(za.lefts(), tf).apply(parMap(p._1(), f).fmap(TreeZipper.treeZipper())))); }
public D _4() { return P4.this._4(); } };
public C _3() { return P4.this._3(); }
public B _2() { return P4.this._2(); }
public A _1() { return P4.this._1(); }
/** * Creates a {@link P5} by adding the given element to the current {@link P4} * * @param el the element to append * @return A {@link P5} containing the original {@link P4} with the extra element added at the end */ public final <E> P5<A, B, C, D, E> append(E el) { return P.p(_1(), _2(), _3(), _4(), el); }
public A _3() { return p._4(); } }));
public A _2() { return p._3(); }
public B _2() { return P4.this._2(); }
public A _1() { return P4.this._1(); }