Based on what you have told me, I can now guess what the problem is. Your question is the following:
list = {1, 2, 1, 3};
Position[list, 1]
returns {{1},{3}}
. On the other hand,
list[1] = 1
list[2] = 2
list[3] = 1
list[4] = 2
Position[list, 1]
gives just {}
, while you expected it to be the same thing. If this is the case then you have a lot to learn about Mathematica (which is OK, we all had to start somewhere), because that is not at all how it works.
Answering this question in this format is difficult because it would require me to go cover a lot of material. I recommend that you start with the following three texts instead:
If you read these then you will understand that the corresponding concept of an array in Mathematica is a list and that it is not manipulated like this:
list[1] = 1
list[2] = 2
list[3] = 1
list[4] = 2
What you would have to do is this:
list = ConstantArray[0, 4];
list[[1]] = 1;
list[[2]] = 2;
list[[3]] = 1;
list[[4]] = 2;
Position[list, 1]
This code will give you {{1}, {3}}
. The assignment list[1] = 1
is also allowed but it does something else than what you think it does. (In short: list
is now a function which takes as its input either 1, 2, 3, or 4 and outputs either 1 or 2.)
m
and an array for you? Please give an example of whatArraym
could be. $\endgroup$List
of lists, nested as deep as the number of dimensions of the matrix.Position
check only the top level of the nested lists, unless told to look deeper. Review the documentation for the third argument ofPosition
. $\endgroup$Position[MyArray,0]
gives blank brackets. what you say? $\endgroup$