f1=: (>:@[EMAIL PROTECTED] # i.) ,. ;@(}.&.> <)@i. f1 4 0 0 0 1 0 2 0 3 1 1 1 2 1 3 2 2 2 3 3 3
f2=: ,~ #: (<:/~)@i. #&, i.@,~ f2 4 0 0 0 1 0 2 0 3 1 1 1 2 1 3 2 2 2 3 3 3 ----- Original Message ----- From: Roger Hui <[EMAIL PROTECTED]> Date: Friday, February 9, 2007 10:49 am Subject: Re: [Jprogramming] all pairs > Combinations are usually defined to have unique elements. > http://www.jsoftware.com/jwiki/Essays/Combinations > However, if non-unique is what you want: > > ; (i. ([ ,. }.)&.> <@i.) 4 > 0 0 > 0 1 > 0 2 > 0 3 > 1 1 > 1 2 > 1 3 > 2 2 > 2 3 > 3 3 > > > > ----- Original Message ----- > From: June Kim <[EMAIL PROTECTED]> > Date: Friday, February 9, 2007 9:11 am > Subject: Re: [Jprogramming] all pairs > > > Thank you for interesting approaches, but those aren't what I > was > > expecting. > > What I meant was "2 combination N"; compare the # of results of mine > > and yours. Sorry if my description wasn't clear. > > > > Following is one more approach I found: > > ut=:[: -. >/[EMAIL PROTECTED] > > ([: > ([:,@ut [EMAIL PROTECTED]) # [: ,@{ 2 $ < ) 'abcd' > > aa > > ab > > ac > > ad > > bb > > bc > > bd > > cc > > cd > > dd ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
