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.

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to