/** * * @param seed * @return Product of Seed and value */ static P2<Long, Long> nextLong(long seed) { long newSeed = (seed * 0x5DEECE66DL + 0xBL) & 0xFFFFFFFFFFFFL; long n = newSeed >>> 16; return P.p(newSeed, n); }
/** * Returns an empty stream. * * @return An empty stream. */ public static <A> P1<Stream<A>> nil_() { return P.lazy(Nil::new); }
Later(F0<A> producer) { this.memo = P.hardMemo(producer); }
/** * Modifies the value for the given key, if present, by applying the given function to it. * * @param k The key for the value to modify. * @param f A function with which to modify the value. * @return A new tree map with the value for the given key transformed by the given function, * paired with True if the map was modified, otherwise False. */ public P2<Boolean, TreeMap<K, V>> update(final K k, final F<V, V> f) { final P2<Boolean, Set<P2<K, Option<V>>>> up = tree.update(p(k, Option.none()), compose(P2.tuple(P.p2()), P2.map2_(Option.<V, V>map().f(f)))); return p(up._1(), new TreeMap<>(up._2())); }
/** * Zips this list with the given list to produce a list of pairs. If this list and the given list * have different lengths, then the longer list is normalised so this function never fails. * * @param bs The list to zip this list with. * @return A new list with a length the same as the shortest of this list and the given list. */ public final <B> List<P2<A, B>> zip(final List<B> bs) { final F<A, F<B, P2<A, B>>> __2 = p2(); return zipWith(bs, __2); }
/** * Transforms a product of a promise to a promise of a product. * * @param s The strategy with which to traverse the promise. * @param p A product of a promise to traverse. * @return A promised product. */ public static <A> Promise<P1<A>> sequence(final Strategy<Unit> s, final P1<Promise<A>> p) { return join(promise(s, p)).fmap(P.p1()); }
/** * Zips this vector with the given vector to produce a vector of pairs. * * @param bs The vector to zip this vector with. * @return A new vector with a length the same as the shortest of this vector and the given * vector. */ public <B> V4<P2<A, B>> zip(final V4<B> bs) { final F<A, F<B, P2<A, B>>> __2 = p2(); return zipWith(__2, bs); }
/** modify polymorphically the target of a {@link PPrism} with an Applicative function */ public final F<S, P1<T>> modifyP1F(final F<A, P1<B>> f) { return s -> getOrModify(s).either( P.p1(), t -> f.f(t).map(this::reverseGet) ); }
/** * Returns the product-4 representation of this zipper. * * @return the product-4 representation of this zipper. */ public P4<Tree<A>, Stream<Tree<A>>, Stream<Tree<A>>, Stream<P3<Stream<Tree<A>>, A, Stream<Tree<A>>>>> p() { return P.p(tree, lefts, rights, parents); }
/** * Swaps the elements around in this product. * * @return A new product-2 with the elements swapped. */ public final P2<B, A> swap() { return P.lazy(P2.this::_2, P2.this::_1); }
/** * Zips this vector with the given vector to produce a vector of pairs. * * @param bs The vector to zip this vector with. * @return A new vector with a length the same as the shortest of this vector and the given * vector. */ public <B> V8<P2<A, B>> zip(final V8<B> bs) { final F<A, F<B, P2<A, B>>> __2 = p2(); return zipWith(__2, bs); }
@Override public F<S, P1<T>> modifyP1F(final F<A, P1<B>> f) { return s -> getOrModify.f(s).either( P.p1(), t -> f.f(t).map(b -> set.f(b).f(s)) ); }
/** * A function that puts an element in a product-7. * * @return A function that puts an element in a product-7. */ public static <A, B, C, D, E, F$, G> F<A, F<B, F<C, F<D, F<E, F<F$, F<G, P7<A, B, C, D, E, F$, G>>>>>>>> p7() { return a -> b -> c -> d -> e -> f -> g -> p(a, b, c, d, e, f, g); }
/** * Return the first element of this vector as a product-1. * * @return the first element of this vector as a product-1. */ public P1<A> head() { return P.lazy(V2.this::_1); }
/** * Zips this vector with the given vector to produce a vector of pairs. * * @param bs The vector to zip this vector with. * @return A new vector with a length the same as the shortest of this vector and the given * vector. */ public <B> V6<P2<A, B>> zip(final V6<B> bs) { final F<A, F<B, P2<A, B>>> __2 = p2(); return zipWith(__2, bs); }
/** * Append the given element to this stream to product a new stream. * * @param a The element to append. * @return A new stream with the given element at the end. */ public final Stream<A> snoc(final A a) { return snoc(p(a)); }
/** * Provides a thunk that throws an error using the given message when evaluated. * * @param s The message to fail with. * @return A thunk that throws an error using the given message when evaluated. */ public static <A> P1<A> error_(final String s) { return P.lazy(() -> { throw new Error(s); }); }
/** * Zips this vector with the given vector to produce a vector of pairs. * * @param bs The vector to zip this vector with. * @return A new vector with a length the same as the shortest of this vector and the given * vector. */ public <B> V7<P2<A, B>> zip(final V7<B> bs) { final F<A, F<B, P2<A, B>>> __2 = p2(); return zipWith(__2, bs); }