4 ms·
Very big difference between pure and total functions. Pure functions are memoryless and deterministic. Total functions are defined for all elements in its dom
by nyrikki 3y ago
Very big difference between pure and total functions.
Pure functions are memoryless and deterministic.
Total functions are defined for all elements in its domain.
Square (x²) is a total function. Reciprocal (1/x) is not, since 0 is a real number, but has no reciprocal.
“Total” and “pure” are orthogonal concepts.
A pure functions that raises an error with the input 0/0 is not total, and you can have total functions that aren't pure.
- mrkeen 3y ago> Total functions are defined for all elements in its domain. Do you include "same-output-for-the-same-input" as part of defined?
- nyrikki 3y agoIn context of This paper, where they are talking about Total forms of pure functions, yes But in general no. I could say have a total function with an internal counter that adds 1 each time it was run. That would still be a total function, but not pure.