Constructing functions
History /
Edit /
PDF /
EPUB /
BIB /
Created: August 18, 2016 / Updated: November 2, 2024 / Status: in progress / 2 min read (~323 words)
Created: August 18, 2016 / Updated: November 2, 2024 / Status: in progress / 2 min read (~323 words)
Let's assume that all that is available to us to write a new function is a list of existing functions.
First we want look at parameterless functions.
A parameterless function can do three of the following things:
- Return data (an intrinsic value or some structure/object)
- Call other parameterless functions
- Call other functions with parameters by instantiating the required arguments internally through a call to other parameterless functions
- It can return consumable data
- It can instantiate static data
Overall, the "functions" of such a function are:
- Encapsulating functions (f()=g())
- Encapsulating sequence of functions (f()=g(),h(),i())
- Function composition/Chaining functions calls (f=g∘h∘i=g(h(i())))
- Recursive function calls (f=fn, f=∘nf ,f=f∘f∘⋯∘f⏟n)
Here we observe that calling functions with parameters only amounts to calling the appropriate instantiator and passing the result to the function expecting an argument.
We can consider the following program
to be convertible into