We explored "First-Class" functions in R, and how having functions be "just another object" makes the apply
family of functions possible (lapply
, sapply
, vapply
and regular old apply
).
Today, we're going to look at a few neat tricks that you need to have up your sleeve when doing functional-style programming in R.
- "Purely Functional" programming without R's "Syntactic Sugar"
- Higher-order functions: When imperative style just wont do
- Closures (a.k.a. functions, but with some data along for the ride)