9.1 Introduction

Functionals are functions that take function as input and return a vector as output. Functionals that you probably have used before are: apply(), lapply() or tapply().

  • alternatives to loops

  • a functional is better than a for loop is better than while is better than repeat

Benefits

  • encourages function logic to be separated from iteration logic

  • can collapse into vectors/data frames easily