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 &] != {}
$\endgroup$ – Dr. belisarius Oct 17 '12 at 16:13Catch[Scan[If[# > 1, Throw[True]] &, {1, 2, 6, 8}]]
$\endgroup$ – Dr. belisarius Oct 17 '12 at 16:19MemberQ[]
should be a pattern, not a test. What doesMatchQ[2, # > 1 &]
return? $\endgroup$ – J. M.'s ennui♦ Oct 17 '12 at 16:28MemberQ
you can doMemberQ[{2, 1}, _?(# > 1 &)]
to transform a test into a pattern. $\endgroup$ – b.gates.you.know.what Oct 17 '12 at 16:37! IntegerQ@Log2[1 + FromDigits[UnitStep[1 - {1, 2}]~Prepend~1, 2]]
$\endgroup$ – Rojo Oct 17 '12 at 18:44