I definitely agree with you that we, as a community, should be suggesting cleaner alternatives.
But I don't think we should go overboard there. (1) That's a "should" and not a "must", and (2) It's also good to show how exact requirements can be met, and (3) it's easy to mis-generalize, and all-too-often there's conflicting generalizations which can fit a problem statement. (Also, good software implementations are generally guided by relevant examples, and we should also be encouraging people to get into the habit of identifying and stating those, and their motivations.) Basically, I guess I am suggesting that discussions have an organic quality to them... Thanks, -- Raul On Fri, Jan 28, 2022 at 6:14 AM R.E. Boss <[email protected]> wrote: > > In my opinion we should point out if a question is more atom-like then is > appropriate for J. > The most important in using J is thinking J-like, which I learned by studying > Rich's J for C-programmers. > So my wholistic solution is > > (</. i.@#) 20 ?.@# 8 > +-----+------------+-------------+----+-----+-----+ > |0 3 6|1 2 5 7 8 17|4 10 13 18 19|9 12|11 15|14 16| > +-----+------------+-------------+----+-----+-----+ > > in which everything about the nth duplicate can be found. > E.g., if you want the value as well > > (~.;"0 (</. i.@#)) 20 ?.@# 8 > +-+-------------+ > |2|0 3 6 | > +-+-------------+ > |4|1 2 5 7 8 17 | > +-+-------------+ > |1|4 10 13 18 19| > +-+-------------+ > |3|9 12 | > +-+-------------+ > |0|11 15 | > +-+-------------+ > |5|14 16 | > +-+-------------+ > > > R.E. Boss > > > -----Original Message----- > From: Programming <[email protected]> On Behalf Of > Raul Miller > Sent: donderdag 27 januari 2022 19:11 > To: Programming forum <[email protected]> > Subject: Re: [Jprogramming] Find nth duplicate in vector > > Well, ... the implementation posted by xash is very nice, but in > http://jsoftware.com/pipermail/programming/2022-January/059790.html > Pawel Jakubas specified that the value appears first, and the index appears > second, and that the indices start with 1 for the first value. > > Also, somewhere along the line, was the suggestion that the result of f > should be empty rather than throwing an error if there was no such duplicate > value. > > FYI, > > -- > Raul > > > On Thu, Jan 27, 2022 at 12:50 PM Hauke Rehr <[email protected]> wrote: > > > > I wonder why there’s still so much traffic on this thread > > (okay, I’m to blame for quite some of it) > > I thought xash published the best correct solution. > > Am I wrong? > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
