generic apply/filter/reduce

fixes github issue #11