June 2018
Intermediate to advanced
280 pages
7h 46m
English
Currying is a process used to transform an n-ary function into a series or unary functions, and it was named after Haskell Curry, an American mathematician. The form g:: x -> y -> z is the curried form of f :: (x, y) -> z. For the square radius presented formula earlier, f(x,y) = x2 + y2, a curried version, without the use of BiFunction, would use apply multiple times. A single application of a function would just replace the parameter with a value, as we saw earlier. The following code shows how to curry a two-parameter function, for n parameters there will be n calls to the Function<X,Y> class's apply function:
jshell> Function<Integer, Function<Integer, Integer>> square_radius = x -> y -> x*x + y*y;square_radius ==> $Lambda$46/1050349584@6c3708b3 ...
Read now
Unlock full access