Say I have two lists
[16, 0, 0, ';', 17, 0, 2, ';', 0, 2, 1, ';']
[-1, 0, ';', 0, -2, ';', -2, -1, ';']
Is there a simpler way to merge these list elements conditionally on meeting the ‘;’ character than individually iterating through them both and combining them?
The output should be
[16, 0, 0, -1, 0, ';', 17, 0, 2, 0, -2, ';', 0, 2, 1, -2, -2,';']
Now we can zip together your lists:
Of course, at it’s core, this is essentially iterating over both of them and combining … so in answer to your question, I don’t think there’s a better way.
Perhaps a better way to store your lists would be storing them as a list of lists — e.g.:
stored like this, you can just do: