At the R in Finance conference Paul Teetor gave a fantastic talk about Fast(er) R Code. Paul mentioned the common higher-order function Reduce, which I hadn't used before.
Reduce allows me to apply a function successively over a vector.
What does that mean? Well, if I would like to add up the figures 1 to 5, I could say: add <- function(x,y) x+y
or
add(add(add(add(1,2),3),4),5)Reduce(add, 1:5)