Suppose I have this list:
lst = {db, st1, 3, 333.33, 4, 543, 11, 323, de, db, st2, 9, 987, 8, 778, de};
What matters here is that block structures begin with an item db, followed by an item and end with another item de
What I need to do here is convert the list to something like this:
{
{st1,3, 333.33},
{st1,4, 543},
{st1,11, 323},
{st2,9, 987},
{st2,8, 778}
};
How would you write a rule to accomplish this?
I’m trying to stay away from procedural programming/
The biggest issue I’m struggling with is that the rule
{db, __, de} → axa
matches the entire list and I can’t tell Mathematica to look for the shortest such list
Shortest[] doesn’t seem to be working for me either, perhaps I’m not using it properly
Any suggestions?
Thanks in advance!