We all learned about mathematical functions when we studied algebra: y = f(x), where f(x) = ax2+…. In the abstract world of mathematics, functions are pure and reproducible and have no side effects.
In imperative programming languages such as C, functions (in the sense of subroutines that return a value) are often anything but pure, since they rely on internal and external state, and they may change their behavior from one invocation to another. While it's often useful and expedient to have functions with side effects, they can be complicated to debug and may present a nightmare for a maintainer.
A branch of mathematics called lambda calculus (λ-calculus), which originated with the work of Alonzo Church in the 1930s, underlies the idea of functional programming. Among the formal aspects of λ-calculus that apply to functional programming are anonymous functions, also called lambda functions; currying, which transforms a multivariate function into a chain of univariate functions, thus allowing them to conform to the λ-calculus rule that functions may only have a single input; and functions as first-class values, meaning that functions can be the inputs and outputs of other functions.
In the following article, I give you an overview of functional programming and walk you through examples in F# to help you make the switch.
To continue reading this article register now