/** * Returns a function that moves a value along the enumerator a given number of times. * * @param l The number of times to move along the enumerator. * @return A function that moves a value along the enumerator a given number of times. */ public F<A, Option<A>> plus(final long l) { return flip(plus).f(l); }
/** * Performs a right-fold reduction across this list. This function uses O(length) stack space. */ public final A foldRight1(final F<A, F<A, A>> f) { return reverse().foldLeft1(flip(f)); }
/** * Performs a right-fold reduction across this list. This function uses O(length) stack space. * * @param f The function to apply on each element of the list. * @param b The beginning value to start the application from. * @return The final result after the right-fold reduction. */ public final <B> B foldRight(final F2<A, B, B> f, final B b) { return reverse().foldLeft(flip(f), b); }
/** * Performs a right-fold reduction across this list. This function uses O(length) stack space. */ public final A foldRight1(final F2<A, A, A> f) { return reverse().foldLeft1(flip(f)); }
@Override public <B> B foldRight(final F<A, F<B, B>> aff, final B z) { return prefix.foldRight(aff, middle.foldRight(flip(Node.foldRight_(aff)), suffix.foldRight(aff, z))); }
@Override public A reduceRight(final F<A, F<A, A>> aff) { return prefix.foldRight(aff, middle.foldRight(flip(Node.foldRight_(aff)), suffix.reduceRight(aff))); }
/** * Zips the nodes in this zipper with a boolean that indicates whether that node has focus. * All of the booleans will be false, except for the focused node. * * @return A new zipper of pairs, with each node of this zipper paired with a boolean that is true if that * node has focus, and false otherwise. */ public TreeZipper<P2<A, Boolean>> zipWithFocus() { final F<A, P2<A, Boolean>> f = flip(P.<A, Boolean>p2()).f(false); return map(f).modifyLabel(P2.map2_(Booleans.not)); }
private static <A> Stream<Tree<A>> combChildren(final Stream<Tree<A>> ls, final Tree<A> t, final Stream<Tree<A>> rs) { return ls.foldLeft(compose(flip(Stream.cons()), P.p1()), Stream.cons(t, P.p(rs))); }
/** * Sort this stream according to the given ordering. * * @param o An ordering for the elements of this stream. * @return A new stream with the elements of this stream sorted according to the given ordering. */ public final Stream<A> sort(final Ord<A> o) { return mergesort(o, map(flip(Stream.<A>cons()).f(p(Stream.nil())))); }
/** * Performs a right-fold reduction across this zipper. * * @param f The function to apply on each element of this zipper. * @param z The beginning value to start the application from. * @return the final result after the right-fold reduction. */ public <B> B foldRight(final F<A, F<B, B>> f, final B z) { return left.foldLeft(flip(f), right.cons(focus).foldRight(compose( Function.<P1<B>, B, B>andThen().f(P1.__1()), f), z)); }
public PkginfoFile f( PkginfoFile pkginfoFile ) { return pkginfoFile. pstamp( map2.get( "PSTAMP" ) ). desc( map2.get( "DESC" ) ). email( map2.get( "EMAIL" ) ). classes( map2.get( "CLASSES" ).map( flip( StringF.split ).f( "," ) ).orSome( List.<String>nil() ) ); } } );
/** * Maps the given function across the values of this TreeMap. * * @param f A function to apply to the values of this TreeMap. * @return A new TreeMap with the values transformed by the given function. */ @SuppressWarnings("unchecked") public <W> TreeMap<K, W> map(final F<V, W> f) { final F<P2<K, Option<V>>, P2<K, Option<W>>> g = compose(p2 -> p(p2._1(), p2._2()), P2.map2_(F1Functions.mapOption(f))); final F<K, P2<K, Option<V>>> coord = flip(P.<K, Option<V>>p2()).f(Option.none()); final Ord<K> o = tree.ord().contramap(coord); return new TreeMap<>(tree.map(TreeMap.ord(o), g)); }
public Pkginfo f( Pkginfo pkginfo ) { return pkginfo. pstamp( map2.get( "PSTAMP" ) ). desc( map2.get( "DESC" ) ). email( map2.get( "EMAIL" ) ). size( map2.get( "SIZE" ) ). classes( map2.get( "CLASSES" ).map( flip( StringF.split ).f( "," ) ).orSome( List.<String>nil() ) ); } } );