apply arbitrary functions to vectors