# Searching a deeply nested list [closed]

I have a deep nested ragged list.

list= {{{
{{0}, 13}, {{1}, 15}, {{0, 0}, 12}, {{1, 1}, 9}, … ,
{{0}, 3}, {{1}, 5}, {{0, 0}, 2}, {{1, 1}, 19}, …
}}}


The list is the result of obtaining a Tally around a string of 0s and 1s that has been Split to identify runs.

I am interested in finding all of the occurrences of say {0, 0} from the nested list. I tried Position

Position[list, {0, 0}]


It works fine and I get:

{{1, 1, 3, 1}, {1, 2, 3, 1}, {1, 3, 2, 1}, …


However, I wanted to use Select or Cases to pull out the elements that contained the element of interest. I've tried to follow some examples at https://stackoverflow.com/questions/7893090/selectnested-list-condition-in-mathematica.

For example, I tried:

   Select[list, #[[_, _, _, y_]] == {0, 0} &]
Cases[list, {_, _, _, y_} /; y == {0, 0}]


However, I was unsuccessful. I suspect that I am not defining the depth for the search as a proper list.

• Cases[list, {0, 0}, Infinity]? – garej Feb 23 '16 at 21:01
• @Muralli, you may also want to see Extract, as Extract[list, Position[list, {0, 0}]] – garej Feb 23 '16 at 21:04
• Murally, please include a more representative example of your list. If too big, use pastebin or a similar service to post the whole list. Also, when you say that you want to extract the elements that contain {0, 0}, do you mean the immediately enclosing list? – MarcoB Feb 23 '16 at 21:20
• Cases[list, {{0, 0}, _}, ∞] – m_goldberg Feb 23 '16 at 22:21
• @m_goldberg: {0,0} is an example of the pattern I am searching for in the ragged nested list. It is a vector list itself. I am going to see if I post the list on pastern. Will let you know when I do. – Murali Feb 23 '16 at 22:34