Add `apply` function like IPython's apply