The filter function in terms of reduce