I have a nested list where each element looks like
{{x, y}, {{a, b}, {c, d}}}
I would like to extract elements of a list with $ b < 0 $, so I look for structure
{{x1, y1}, {{a1, b1}, {c1, d1}}},
{x1, y1}, {{a1, b1}, {c1, d1}}},
...}
First I try
Cases[list, {A_, B_} /; B < 0, 3]
but this gives undesired results:
{{x1, y1}, {a1, b1}, {x2, y2}, {a2, b3}, ...}
so original structure of list disappears and I have. Then I try
Cases[list, {A_, B_} /; B < 0, {3}]
and obtain a list of pairs
{{a1, b1}, {a2, b2}, ...}
What should I do to obtain the desired results?
The second question is how to deal with list with the following structure:
{ {{x1,y1},{{a1,-1},{a2,b2},{a3,b3}}}, {{x2,y2},{{a4,-1},{a5,b4}}} }
I mean that a number of pairs {ai,bi}
in the second ''part'' of element can be different for each element.