[Jprogramming] all pairs

Devon McCormick devonmcc at gmail.com
Sat Feb 10 02:50:39 HKT 2007


How about this?
   successivePairs=: 13 : '({.y),&.>y'
   successivePairs
{. ,&.> ]
   successivePairs 'abcd'
+--+--+--+--+
|aa|ab|ac|ad|
+--+--+--+--+
     successivePairs ;.3 'abcd'
+--+--+--+--+
|aa|ab|ac|ad|
+--+--+--+--+
|bb|bc|bd| |
+--+--+--+--+
|cc|cd| | |
+--+--+--+--+
|dd| | | |
+--+--+--+--+

   NB. So,
   a:-.~,successivePairs ;.3 'abcd'
+--+--+--+--+--+--+--+--+--+--+
|aa|ab|ac|ad|bb|bc|bd|cc|cd|dd|
+--+--+--+--+--+--+--+--+--+--+

   NB. or
   a:-.~,({.,&.>]) ;.3 'abcd'
+--+--+--+--+--+--+--+--+--+--+
|aa|ab|ac|ad|bb|bc|bd|cc|cd|dd|
+--+--+--+--+--+--+--+--+--+--+


On 2/9/07, June Kim <juneaftn at gmail.com> wrote:
>
> 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.
>
. . .
-- 
Devon McCormick
^me^ at acm.
org is my
preferred e-mail


More information about the Programming mailing list