Element-wise test on List elements
To my knowledge, there aren't built-in versions for comparison operators that would be automatically threaded over lists. One reason for that is that Mathematica is a symbolic system, and every auto-simplification has a cost, because there may be cases when this isn't desirable.
It is relatively easy however to construct the behavior you want:
ClearAll[l];
l[f_] := Function[Null, f[##], Listable]
Now, you can call:
{{0.6, 1.2}, {5, 0.1}} ~ l[Greater] ~ 1
(* {{False, True}, {True, False}} *)
and similarly with other comparison operations.
Note that, since you didn't mention efficiency, I intentionally left this aspect out. If you have large numerical lists, there are vastly more efficient ways to perform the comparisons, making use of vectorization and packed arrays.
The BoolEval`
package does exactly this. For example:
BoolEval[{0.6, 1.2} > 1]
(* Out: {0, 1} *)
and
BoolEval[{{0.6, 1.2}, {5, 0.1}} > 1]
(* Out: {{0, 1}, {1, 0}} *)
In order to return True
and False
instead of 0
and 1
, you can append /. {0 -> False, 1 -> True}
.
Depth 1
MapAt[Greater[#, 1] &, {0.6, 1.2}, {All}]
{False, True}
OR
Thread[Greater[#, 1]] & @ RandomReal[2, 10]
{True, False, False, True, True, True, False, False, False, True}
Depth 2
MapAt[Greater[#, 1] &, {{0.6, 1.2}, {5, 0.1}}, {All, All}]
{{False, True}, {True, False}}
OR
Thread[Greater[#, 1]] & /@ RandomReal[2, {3, 5}]
{{True, True, False, True, True}, {True, False, False, False, False}, {False, False, False, False, True}}
Depth n
f=MapAt[Greater[#, 1] &, #, Table[All, (Depth[#] - 1)]] &
f[{{{1.6, 0.2}, {3, 0.1}}, {{0.6, 1.2}, {5, 0.1}}}]
{{{True, False}, {True, False}}, {{False, True}, {True, False}}}
f@RandomReal[2, Range[6]]
OR
RandomReal[2, Range[4]] /. (w_Real -> w > 1)