# Specifying form in MemberQ

This seems like a very simple question, the answer to which should be obvious to me. So I won't be offended if this question is closed. But I'm having trouble figuring out the answer.

I would like to write a function that returns True if a list contains one or more numbers greater than 1. Why does MemberQ[{2, 1}, # > 1 &] return False? Thanks.

• Select[{2, 1}, # > 1 &] != {} – Dr. belisarius Oct 17 '12 at 16:13
• Catch[Scan[If[# > 1, Throw[True]] &, {1, 2, 6, 8}]] – Dr. belisarius Oct 17 '12 at 16:19
• Simply put, the second argument of MemberQ[] should be a pattern, not a test. What does MatchQ[2, # > 1 &] return? – J. M.'s torpor Oct 17 '12 at 16:28
• The comment by @J.M. answers your question; if you insist on using MemberQ you can do MemberQ[{2, 1}, _?(# > 1 &)] to transform a test into a pattern. – b.gates.you.know.what Oct 17 '12 at 16:37
• The simplest way is clearly ! IntegerQ@Log2[1 + FromDigits[UnitStep[1 - {1, 2}]~Prepend~1, 2]] – Rojo Oct 17 '12 at 18:44

MemberQ[{2, 1}, _?(# > 1 &)]