Update docs for "apply" and add an example

Try to solve #1076. @vchekan, any suggestion?

/cc @headinthebox, @samuelgruetter