Functional programming means (at least) 2 things:
- Expressions do not have side effects (i.e., don't create or change any variables without you explicitly asking for them to)
- Functions are "first-class"
- Can be manipulated like any other R object
- Can be passed as arguments to other functions
- Can be returned as a result of a function
Don't be scared though: You've been doing functional programming all along without knowing it, because at it's core, R is a functional programming language!
We're going to focus on the second tenant today, as "first class" functions are the underpinning of the *apply
family of functions in R.