rewrite filter in terms of foldr