This is a recurring theme in FP: start with small, easy-to-understand building blocks, combine them into more complex structures, and apply them with confidence. These pieces are twined together in the conclusion which shows how to build a suite of tools for numerical integration, starting from very simple primitives. Then you’ll learn about the three building blocks of functional programming: anonymous functions, closures (functions written by functions), and lists of functions. The chapter starts by showing a motivating example, removing redundancy and duplication in code used to clean and summarise data. You can do anything with functions that you can do with vectors: you can assign them to variables, store them in lists, pass them as arguments to other functions, create them inside functions, and even return them as the result of a function. In particular, R has what’s known as first class functions. This means that it provides many tools for the creation and manipulation of functions. R, at its heart, is a functional programming (FP) language. You’re reading the first edition of Advanced R for the latest on this topic, see the Functional programming section in the second edition.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |