How would you implement "takeout"(Less with equally valued cell numbers
significant) in the following test cases?

assert 1 2   -:&(/:~) 1 2 3 takeout 3
assert (,:1) -:&(/:~) 1 1 1 takeout 1 1
assert 1 3 4 -:&(/:~) 1 2 3 4 1 1 takeout 1 2 1
assert 1 2 3 -:&(/:~) 1 2 3 3 2 takeout 3 2

My first quick implementation(without much thought):

keyind=:([:< i...@# ,. ])/.~
takeout =: {:"1...@-.&(;@:keyind)

I would appreciate simpler and more elegant solutions.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to