Given an array with zero or more annihilating pairs, i.e., two subsequent 
numbers which add up to zero, the question is to clean up the array by deleting 
all annihilating pairs such that no such pairs are left.
I do have a solution that is both elegant and efficient (I believe), but I am 
curious about other thoughts.

   foo  2 1 1 _1 2 _2 _1
2

   foo 1 _1 2 _2{~100?.@#4              NB. Notice (?.)
2 1 2 1 _2 _1 2 1 1 2 2 2 _1 2 _1 2 1 2 2 2 1 1 _2 _1 2 1 _2 _1 _2 _2 _2 _2 _1 
_2 _1 _1 _2 _2 1 1 1 2 1 _2 1 _2 _1 _1 _1 2


R.E. Boss
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to