I'm used to MATLAB so this might be a stupid question but Mathematica is freaking me out.
I have a big matrix with the following format:
M = {{A,B,C},{1,{1,3,6,7},0},{1,{3,7,9},1}}
As you can see, each element in the second column is a separate list again. These separate lists contain integers, so it's no problem to get back to them. For example if I use MemberQ[M[[2,2]],1]
it returns True
, as it's supposed to do.
What I want to do now: my Matrix is a little longer, contains approx. 5'000 rows.
I want to check every seperate list mentioned above for the appearance of a specific integer, as I did above with the MemberQ
.
As a result it should give me something like the following (taking M
as example): {True,False}
.
I thought that's supposed to be easy with a for-loop as it is in MATLAB, but Mathematica always stops when condition is not met...
Looking forward to your answers. Please state if I need to clarify my question!
{1,{1,3,6,7},0}
. The elements of the second row are not lists, contradicting what you said.memberQ[M[2,2],1]
is not correct Mathematica code and won't returnTrue
. If you meanMemberQ[M[[2,2]],1]
, please write it as such. $\endgroup$B
is a list then? $\endgroup$MemberQ[#[[2]], 1] & /@ M
what you are looking for? $\endgroup$