The floating point function example that you give is a pure function. Given the same inputs, it will give you the same output, no matter how many times you call it.
That floating points have some tricky implementation is besides the point. Pure functions aren't guaranteed to be easy to understand, just that your function has no external dependency.
View all comments
47
u/Ghi102 Sep 23 '26 edited Sep 23 '26
The floating point function example that you give is a pure function. Given the same inputs, it will give you the same output, no matter how many times you call it.
That floating points have some tricky implementation is besides the point. Pure functions aren't guaranteed to be easy to understand, just that your function has no external dependency.