I have the following list consisting of strings and integers:
testList = {a, Abc, b, 3, a, c, d, b, Abc, m, n, 2, q, r, w, Def, q, 3, a, Def, 1, a, g};
and I would like to obtain the following sublists:
desiredResult = {{Abc, 3, a, c, d, b}, {Abc, 2, q, r, w}, {Def, 3, a}, ={Def, 1, a, g}}
This involves eliminating everything before the first instance of the "Abc" string, picking the "Abc" string, omitting anything between it and the next integer, and adding everything following this integer until the next instance of "Abc" etc. I think it's easier to look at the example than to describe it in words. I'm not sure how to use pattern matching for this, any ideas would be gratefully received.
Comments
Post a Comment