What is functional programming? Rúnar Óli defines it as:
programming with functions.
What’s a function?
f: A => B
relates every value of type ofA
to excatly one value of typeB
and nothing else.
To clarify the “nothing else” part, he introduces the notion of referential transparency as follows:
An expression
e
is referentially transparent if every occurrencee
can be replaced with its value without affecting the observable result of the program.
Using this notion, we can think of functional programming as building up referentially transparent expression tree. Memoization is one way of taking the advantage of referential transparency.