I strongly advocate the use of a functional idiom such as Map
or Thread
as shown in the answers by Belisarius and image_doctor.
But it is worth noting that you can get something close to your original syntax using Infix notation (see this guide for more information. Aside from the issue with your termination condition, you were trying to use Or
as an infix operator (like + is for Plus
), instead of the correct infix form of ||
. You could if you really wanted to use Or
as the infix operator by nesting it in the ~
infix symbols. But watch out! Or
has higher precedence than equality/inequality, so you then have to wrap your conditions in parentheses. (See this guide on precedence.) The final expression would look like this:
f1[L_, n_] :=
For[i = 1, i <= Length[L], i++,
If[(L[[i]][[1]] > n) ~ Or ~ (L[[i]][[2]] > n),
Print["Bad"], Print["Good"]] ]
Please be aware that I do not advocate this particular syntax, but am only showing it for educational purposes.
Personally, I'd suggest
Max[#] > 5 & /@ {{0, 1}, {2, 3}, {4, 5}, {6, 7}}
Or use the explicit form of Map
(/@
) to get at the individual matrix elements at level 2 of the list, and then Apply
Or
to each row using the short-form notation @@@
.
Or @@@ Map[# > 5 &, {{0, 1}, {2, 3}, {4, 5}, {6, 7}}, {2}]