/** * Maps the given function over the given array in parallel using this strategy. * * @param f A function to map over the given array in parallel. * @param bs An array over which to map the given function in parallel. * @return A product-1 that returns the array with all of its elements transformed by the given function. */ public <B> P1<Array<A>> parMap(final F<B, A> f, final Array<B> bs) { return P1.sequence(bs.map(concurry(f))); }
/** * Evaluates a list of product-1s in parallel. * * @param ps A list to evaluate in parallel. * @return A list of the values of the product-1s in the argument. */ public P1<List<A>> parList(final List<P1<A>> ps) { return P1.sequence(ps.map(f())); }
/** * Maps the given function over the given list in parallel using this strategy. * * @param f A function to map over the given list in parallel. * @param bs A list over which to map the given function in parallel. * @return A product-1 that returns the list with all of its elements transformed by the given function. */ public <B> P1<List<A>> parMap(final F<B, A> f, final List<B> bs) { return P1.sequence(bs.map(concurry(f))); }
/** * Zips together two lists in parallel using a given function, with this strategy. * Calls the given function once for each corresponding pair in the lists, position-wise, * passing elements from the first list to the first argument of the function, and elements from the second list * to the second argument of the function, yielding a list of the results. * If the lists are not of the same length, the remaining elements of the longer list are ignored. * * @param f The function of arity-2 with which to zip. * @param bs A list to zip with the given function. * @param cs A list to zip with the given function. * @return The list of the results of calling the given function on corresponding elements of the given lists. */ public <B, C> P1<List<A>> parZipWith(final F2<B, C, A> f, final List<B> bs, final List<C> cs) { return P1.sequence(bs.zipWith(cs, concurry(f))); }
/** * Zips together two arrays in parallel using a given function, with this strategy. * Calls the given function once for each corresponding pair in the arrays, position-wise, * passing elements from the first array to the first argument of the function, and elements from the second array * to the second argument of the function, yielding a array of the results. * If the arrays are not of the same length, the remaining elements of the longer array are ignored. * * @param f The function of arity-2 with which to zip. * @param bs A array to zip with the given function. * @param cs A array to zip with the given function. * @return The array of the results of calling the given function on corresponding elements of the given arrays. */ public <B, C> P1<Array<A>> parZipWith(final F2<B, C, A> f, final Array<B> bs, final Array<C> cs) { return P1.sequence(bs.zipWith(cs, concurry(f))); }