> NB. Why doesn't something like this work: > NB. rs=. (1) ri}&><bs
It doesn't work because the parse is rs=. (1) (ri})&><bs and it parses like that because } is an adverb. ----- Original Message ----- From: Devon McCormick <[EMAIL PROTECTED]> Date: Tuesday, August 28, 2007 4:56 Subject: Re: [Jprogramming] Permutations of a sort. To: Programming forum <[email protected]> > Roger's method is undoubtedly better but is something like this > suitable? > ri=. 28?~&.>1000$4 > 3{.ri > +----------------------------+ > ¦22 1 4 7¦2 27 11 8¦27 26 8 3¦ > +----------------------------+ > putin1s=: 4 : '1 x}y' > NB. Why doesn't something like this work: > NB. rs=. (1) ri}&><bs > NB. ? > $rs=. ri putin1s&><28$0 > 1000 28 > 4*./ . =+/"1 rs > 1 > $~.rs > 984 28 > NB. 984 unique > > NB. Could also do this (slightyly faster): > $rs2=. (1) (ri,~&.>&>i.#ri)}1000 28$0 > 1000 28 > rs2-:rs > 1 > > > On 8/27/07, Ralph G Selfridge <[EMAIL PROTECTED]> wrote: > > > > Here's my problem. I have a binary string, potentially long, > in my case > > 28. I need to get all binary strings with a specified number > of 1s. I > > doubt > > I can get them all at once, too many, so how do I get from one > to the > > next? > > > > What next means is irrelvant, just so I get them with no > duplicates if I > > run long emough. > > > > While I have an answer, I'm curious to see if there is a > better way. > > > > > > Ralph S ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
