**func-tion:** a mathematical correspondence that assigns exactly one element of one set to each element of the same or another set

*Webster’s Dictionary*

The mathematical notion of function is that if *f*(*x*) = *a* “this time,” then *f*(*x*) = *a* “next time”; there is no other value equal to *f*(*x*). This allows the use of *equational reasoning* familiar from algebra: If *a* = *f* (*x*), then *g*(*f* (*x*), *f* (*x*)) is equivalent to *g*(*a*, *a*). *Pure functional* programming languages encourage a kind of programming in which equational reasoning works, as it does in mathematics.

*Imperative* programming languages have similar syntax: *a* ← *f* (*x*). But if we follow this by *b* ← *f* (*x*), there is no guarantee that *a* = *b*; the function *f* can have *side effects ...*

Start Free Trial

No credit card required