Given a file that looks like this:
[ -1, 5, 1 ], [ 0, 5, 1 ], [ 0, 5, 1 ], [ 1, 5, 1 ], [ 3, 4, 1 ], [ 5, 1, 1 ], [ 5, 0, 1 ], [ 5, 0, 1 ], [ 5, 0, 1 ], [ 5, 0, 1 ], [ 5, 0, 1 ], [ 5, 0, 1 ], [ 0, -5, 1 ], [ 0, -5, 1 ], [ 0, -5, 1 ], [ 0, -5, 1 ], [ 0, -5, 1 ], [ 0, -5, 1 ], [ 0, -5, 1 ], [ 0, -5, 1 ], [ 0, -5, 1 ], [ -23, -64, 0 ], [ -5, 0, 1 ], [ -5, 1, 1 ],
I'm trying to collapse repeated lines that have a 0 in the 1st or the 2nd position into a single line that sums up the non-zero element while ignoring the 3rd one - i.e., 7 repeats of [ 0, -5, 1 ] should be replaced with [ 0, -35, 1 ]. All other lines should just be printed out. Unfortunately, my brain has decided to take a vacation today, and isn't being helpful - so I'm hoping for some Wisdom from the Monastery. :)
-- I hate storms, but calms undermine my spirits. -- Bernard Moitessier, "The Long Way"
In reply to Summing up duplicate lines by oko1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |