What is a pure function in functional programming?
a) A function that depends on external variables
b) A function that always produces the same output for the same input and has no side effects
c) A function that modifies the global state
d) A function that does not return a value
Answer:
b) A function that always produces the same output for the same input and has no side effects
Explanation:
A pure function is one that always returns the same output given the same input and does not produce any side effects, such as modifying global variables or performing I/O operations.