square <- function(x) x^2
add1 <- function(x) x + 1
f <- fcompose(sqrt, square, add1) # => sqrt(square(x + 1))
f(4) # => sqrt((4 + 1)^2) = sqrt(25) = 5
# More compact
fcompose(log, exp)(2) # log(exp(2)) = 2
Run the code above in your browser using DataLab