Mainly transposing of the result an earlier thread 'pairs':
|:@;@(<@({.,.}.)\.@(i.&.<:)) 5
1 1 1 2 2 3
2 3 4 3 4 4=@@i ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
