Generalizing filtering by using a closure as a selector