2021-09-22
|~1 min read
|179 words
Brian Lonsdorf’s definition of a function from Hardcore Functional Programming in Javascript, v2 is three legged:
Total Functions1 contrast with Partial Functions. The former terminates in a value for all possible inputs whereas the former does not.
That is, for the entire domain, the range is defined. The domain being the set of inputs and the range the set of outputs.
Another word for deterministic is reliable. A deterministic function is one that reliably returns the same output.
In this context, a side-effect is something that changes the state of the world or application that can be readily observed.
Of course, this can be taken “too far”. For example, my understanding is pure functions can still result in outputs that are written to STDOUT.
Hi there and thanks for reading! My name's Stephen. I live in Chicago with my wife, Kate, and dog, Finn. Want more? See about and get in touch!