| Type Params | Return Type | Name and description |
|---|---|---|
<T, P> |
public static Predicate<T> |
curryWith(BiPredicate<? super T, ? super P> bp, P p)Right-partials a BiPredicate with the supplied parameter, returning a Predicate that fixes the second argument. |
<T, P, R> |
public static Function<T, R> |
curryWith(BiFunction<? super T, ? super P, ? extends R> bf, P p)Right-partials a BiFunction with the supplied parameter, returning a Function that fixes the second argument. |
<T, P> |
public static Consumer<T> |
curryWith(BiConsumer<? super T, ? super P> bc, P p)Right-partials a BiConsumer with the supplied parameter, returning a Consumer that fixes the second argument. |
Right-partials a BiPredicate with the supplied parameter, returning a Predicate that fixes the second argument.
BiPredicate<Integer,Integer> divisibleBy = (n, d) -> n % d == 0
assert [1, 2, 3, 4, 5].stream().filter(curryWith(divisibleBy, 2)).toList() == [2, 4]
Right-partials a BiFunction with the supplied parameter, returning a Function that fixes the second argument.
BiFunction<String,Integer,String> repeat = (s, n) -> s * n
assert ['a', 'b', 'c'].stream().map(curryWith(repeat, 3)).toList() == ['aaa', 'bbb', 'ccc']
Right-partials a BiConsumer with the supplied parameter, returning a Consumer that fixes the second argument.
def sink = []
BiConsumer<String,List> addTo = (s, list) -> list << s
['a', 'b', 'c'].stream().forEach(curryWith(addTo, sink))
assert sink == ['a', 'b', 'c']