Category Archives: Functional Programming

When is a function pure?

Function_machine2.svgFunctional programming evolves around functions and a pure function is a very important aspect. But when exactly is function pure? I’ll try to show when a function is pure with some examples.

The following function is pure because no external state is touched and every time the function is called with the same parameters the result will be the same.

public function add(Integer x, Integer y) {
  return x + y;

Continue reading When is a function pure?