To convert a Boolean test function such as `PrimeQ` or `IntegerQ` into a pattern one typically uses either `Condition` or `PatternTest`. There are specific strengths and purposes for each which are described in: http://mathematica.stackexchange.com/q/1835/121. Here is a simple and brief example of each: Cases[Range@10, _?PrimeQ] > {2, 3, 5, 7} Cases[Range@10, x_ /; PrimeQ[x]] > {2, 3, 5, 7} Be aware that the `PatternTest` operator `?` has [unusually high binding power][1]: Precedence[PatternTest] > 680. [1]: http://mathematica.stackexchange.com/q/1699/121