Dear J enthusiasts, I wonder how to elegantly implement dyad f that takes as x=1,2,3... and y vector and returns nth duplicate value with index of that occurence:
d=: 1 _1 2 3 4 2 5 6 3 8 10 3 2 NB. the earliest first duplicate is for 2 and index 2 1 f d 2 2 NB. the earliest second duplicate is for 3 for index 11 2 f d 3 11 In Haskell for nth occurence I would just use accumulator as (Map with key being element and value the number of occurence of this element, current index count) and left fold that with starting accumulator (Map.empty, 0). Kindest regards, Pawel ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
