For very low range numbers (less than 10), this could work

The problem with this approach is that it generates all permutations !n

(~.@(] /:"1 ])@(2]\])@;@(i.@!@# A. ]) i.) 4



On Fri, Dec 18, 2015 at 7:58 AM, 'Jon Hough' via Programming
<[email protected]> wrote:
> I've spent an hour on this, and am frustrated that I couldn't figure out a 
> way to do it (without using for_j or while).
>
> I want to get all pairs ( pair order not important e.g. 2 3 is the same as 3 
> 2) of integers up to some value.
>
> e.g. up to 4:
>
> 0 1
> 0 2
> 0 3
> 1 2
> 1 3
> 2 3
>
> in frustration this is what I came up with (for the case of 10):
> /:~ ~. /:~"1  (1000 # 2) ? 10
>
> which works but is not a very good solution.
>
> Any nice solutions?
>
> Thanks,
>
> Jon
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to