say, I want to find an index of a specific element in a list using
Position[{a, b, c, d, e, f}, c]
and it returns {{3}}
How can I use this returned value as index to pick a certain element from another list? How can I convert {{3}}
to an integer or is there any other way to achieve what I want to do?
Thanks in advance!
Answer
If you put your cursor on the Position
command and press F1 for help, you will see the following under Properties and Relations: "Use Extract to extract parts based on results from Position." There is also an example. For your case:
p = Position[{a, b, c, d, e, f}, c]
Extract[list,p]
where list is the list you want to extract from.
Comments
Post a Comment