DEV Community

Discussion on: Functional programming basics part 1: Pure function

Collapse
 
tux0r profile image
tux0r

Its return value should be determined solely by its input parameters.

Wouldn't that make any function in strongly typed languages "pure"?

Thread Thread
 
pizmovc profile image
Luka

No.

For example:

int a = 5;

int sumOfNumbers(int x, int y) {
  a = 1;
  return x + y;
}

int sum = sumOfNumbers(12, 33);

This function is not pure as it modifies a.