purefunctions

noun
UK /ˌpjʊə ˈfʌŋkʃənz/
US /ˌpjʊr ˈfʌŋkʃənz/

Pure functions are special helpers in computer programs that always give the same answer for the same input and never change anything outside themselves.

In our coding class, we learned that pure functions make programs easier to test because they always behave the same way.


OTHER MEANINGS

2. In mathematics, functions whose output depends only on their inputs and which have no hidden state or side effects.

Mathematicians often treat formulas like f(x) = x + 1 as pure functions.

3. In software design, a coding style that favors small, predictable functions over ones that modify shared data.

The team refactored the codebase to use pure functions, which reduced bugs caused by shared state.

4. In testing, functions that can be called repeatedly with the same arguments and always return identical results.

Because they are pure functions, we can run the unit tests in any order without interference.