Is there a way to split a list into sublists based on a pattern while keeping the matching value in the sublist?
For instance, we have the following list:
{a, x, x, a, b, y, a, c, z}
and we want to produce the following (split on a
):
{{a, x, x}, {a, b, y}, {a, c, z}}
then how might we achieve this? In other words, we want to split a list based on a condition while keeping the condition in the sublist. So far I've tried SequenceSplit which produces the list without a
(in this case). However, I'm having trouble formulating the pattern which will keep the split value in the sublist.
Thanks very much for your time!