Functions revisited
Unlike object-oriented programs, those written in a functional way don't hold any mutable state. Instead, code is made up with functions that take arguments and return values. Because there is no internal state nor side-effects involved that can alter the execution, all functions are deterministic. This is a really good feature because it implies that different executions of the same function, with the same parameters, would produce the same outcome.
The following snippet illustrates a function that does not mutate any internal state:
public Integer add(Integer a, Integer b) { return a + b; }
The following is the same function written using Java's functional API:
public final BinaryOperator<Integer> add = new BinaryOperator<Integer>() { @Override public Integer apply(Integer a, Integer b) { return a + b; } };
The first example should be completely familiar to any Java developer; it follows the common syntax of a function that takes two...