Press "Enter" to skip to content

Higher-Order Functions In R

Holger von Jouanne-Diedrich explains the concept of higher-order functions using R as an example:

The part that causes the biggest difficulties (especially for beginners of R) is that you state the name of the function at the beginning and use the assignment operator – as if functions were like any other data type, like vectors, matrices or data frames…

Congratulations! You just encountered one of the big ideas of functional programming: functions are indeed like any other data type, they are not special – or in programming lingo, functions are first-class members.

This is one of the core tenets of functional programming: functions are things you can pass around to other functions; they aren’t special, inviolate pieces of code but are just another thing. Click through for a couple good examples of what you get in a language which supports higher-order functions.