A pure function is pure, when the return value is only determined by its input values, without any observable side effects.
So your function is pure. Since the value of CONSTANT
is (as the name suggests) constant, the output is purely determined by the input.
From Wikipedia:
a function may be considered a pure function if both of the following statements about the function hold:
- The function always evaluates the same result value given the same argument value(s). The function result value cannot depend on any hidden information or state that may change while program execution proceeds or between different executions of the program, nor can it depend on any external input from I/O devices.
- Evaluation of the result does not cause any semantically observable side effect or output, such as mutation of mutable objects or output to I/O devices.