A Pure Function is a function (a block of code) that always returns the same result if the same arguments are passed.
It does not depend on any state or data change during a program's execution. Rather, it only depends on its input arguments.5
xxxxxxxxxx
public class MathUtility {
private static int count = 1;
public static int sum(int num1, int num2) {
count++;
multiply(num1,num2);
return num1 + bnum2;
}
}
https://blog.knoldus.com/functional-java-understanding-pure-functions-with-java/
xxxxxxxxxx
function addNumbers(num1,num2) {
return num1 + num2
}
Calling addNumbers(2,3) will ALWAYS equal 5.
A pure function is a function that always returns
the same result if the same arguments are passed
xxxxxxxxxx
const array = [1,2,3]
function addElementToArray(a,element){
return [a, element]
}
//invoce function
addElementToArray(array,4)
//[1,2,3,4]