DEV Community

Discussion on: The beauty of Functional Programming

Sloan, the sloth mascot
Comment deleted
ekoutanov profile image
Emil Koutanov • Edited on

Sorry Fanny, but it would be classed as a pure function in spite of writing to a local variable. As long as the write has no side effects that are externally observable, it would satisfy the definition of a pure function.

Even a recursive function with no visible variable assignment may introduce any number of intermediate variables as part of compiler optimisation; this wouldn't make it any less pure provided these changes did not escape outside function scope.