Purely functional
What is a computer program?
The following image shows the basic working of a computer program:
An input computed by a program returns an output. This is a very simple concept but it becomes highly relevant for functional programming.
A former colleague told me that's all there is to it: data and code that operates on data. If you want to take it further, the code itself is also data, so a computer program is really just data operating on data.
What about web programming?
The following image shows the basic working of a web server:
It's really the same thing. You have a web request that the server operates on and returns a web response.
How does this apply to functional programming?
The following image shows the basic working of functional programming:
A pure function is very much a computer program. It has an input and output, but the computation of the output adhere to certain conditions:
- The same output is always guaranteed for the same input
- The evaluation of the output...