Actually, I played around with the idea of generating all pairs and then filtering the result. What I came up with turned out rather slow
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Roger Hui Sent: 10 November 2008 21:37 To: Programming forum Subject: Re: [Jprogramming] pairs Actually, the "amend" idea does not use boxing. pair6a=: 3 : 0 t=. ((2!y),2)$0 1+0 t=. (1,.-.(-i.)y-2) (}:+/\(-i.)y-1)}t +/\t ) However, the idea of generating all possible pairs and then selecting the suitable ones is good. Variations on that theme: pair7 =: (</ #&(,/) ,"0/)[EMAIL PROTECTED] pair7a=: (</"1 # ])@(,/)@(,"0/~)@i. ----- Original Message ----- From: Andrew Nikitin <[EMAIL PROTECTED]> Date: Monday, November 10, 2008 11:26 Subject: [Jprogramming] pairs To: J programming <[email protected]> > > I haven't seen a flat version, that is the one that does not use > boxing. If I just missed it, sorry for duplication. If there > wasn't one then here it is. > > (</ #&(,/) ,"0/)[EMAIL PROTECTED] 40 10 20 31 21 32 3 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
