In this chapter, we explore the programming paradigm called functional programming and how it relates to R. There are many definitions of what it means for a language to be a functional programming language, and there have been many language wars over whether any given feature is “pure” or not. I won’t go into such discussions, but some features, I think everyone would agree, are needed. You should be able to define higher-order functions, you should be able to create closures, and you probably want anonymous functions as well.
Let’s tackle anonymous functions right away, as these ...