Junior — Middle
Can you explain what is meant by a pure function in programming?
sobes.tech AI
Answer from AI
A pure function is a function that always returns the same result given the same inputs and has no side effects. This means it does not modify external state, does not access external variables, and does not depend on them.
Example of a pure function in Python:
def add(a, b):
return a + b
Such a function will always return the same result for the same arguments and will not change anything outside itself.