How do you run nv2 so that you get all possible
boolean vectors of length n with m 1s?
 
   nv2^:(i.5) 0 0 0 0 1 1 1
0 0 0 0 1 1 1
0 0 0 1 1 1 0
0 0 1 1 1 0 0
0 1 1 1 0 0 0
1 1 1 0 0 0 0



----- Original Message -----
From: Raul Miller <[EMAIL PROTECTED]>
Date: Tuesday, August 28, 2007 13:39
Subject: Re: [Jprogramming] Permutations of a sort.
To: Programming forum <[email protected]>

> On 8/28/07, Roger Hui <[EMAIL PROTECTED]> wrote:
> > Algorithm to find the next boolean list with m 1s:
> > Find the rightmost 0 which has k 1s on its right
> > where k>0.  Move a 1 into that position and move
> > the other (k-1) 1s all the way to the right.
> 
> nv2=:3 :0
>   one=.y i: 1
>   zer=.(one{.y) i: 0
>   assert.zer < one
>   1 0 (zer,one)} y
> )
> 
> Note that neither nv nor nv2 deals well with cases which
> do not have a successor with the supplied number of bits.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to