Tom Ritchford
Aug 27, 2017 · 1 min read

Sorry to be carping, but this is only part of the definition. Pure functions have no side effects and they don’t depend on any external variables or conditions — so they return exactly the same results on the same inputs every time.

For example, the time function which returns the system time is not a pure function, because the result depends on an external variable — the time!

And a function which returns the value of a mutable global variable isn’t a pure function, because you could change that global variable elsewhere in the program and change the value of the function.

The key property of pure functions is “the same inputs give the same outputs every time”. It is this property that makes pure functions so desirable and useful.

)
    Tom Ritchford

    Written by

    uk->at->ca->us->nl