In the book Functional Programming in Java the author builds a compose function using only the Function<T, U>
interface (the interface however is not one shipped with Java 8 but very similar though) the snippet of which is show below
public interface Function<T, U> {
U apply(T arg);
}
though I could understand the method version of compose below, which takes in 2 functions and return a composed function
public static final Function<Integer, Integer> compose (final Function<Integer, Integer> f1,
final Function<Integer, Integer> f2) {
arg -> f1.apply(f2.apply(arg));
}
I just couldn't get my head around the below compose implementation with Function<> and lambdas
static Function<Function<Integer, Integer>,
Function<Function<Integer, Integer>,
Function<Integer, Integer>>> compose =
x -> y -> z -> x.apply(y.apply(z));
PS: couldn't get my mind out of this and move forward with remaining sections :(