nv nv3 nc nct were written to satisfy the specifications which were that there was insufficient memory to hold all m!n entries at once, or n could be larger than the number of bits in a machine word. That is, the next string should be computed. Under such conditions nv nv3 nc nct could run where ncb would fail with an "out-of-memory". Moreover, if n > word size, nv nv3 would give right answers when nc nct ncb would not.
----- Original Message ----- From: "R.E. Boss" <[EMAIL PROTECTED]> Date: Thursday, August 30, 2007 10:46 Subject: RE: [Jprogramming] Permutations of a sort. To: 'Programming forum' <[email protected]> > To conclude: (NB. beware of line wraps!) > > First, all output is equal > > 2-:&>/\ ".&.> > 'nv^:(i.5!28)_28{.5#1';'nv3^:(i.5!28)_28{.5#1';'#:nc^:(i.5!28) > 31';'#: nct^:(i.5!28) 31';'#: 5 ncb 28' > 1 1 1 1 > > > although some verbs perform better than others: > > ('nv';'nv3';'nc';'nct';'ncb')rnkng > score 'nv^:(i.5!28)_28{.5#1'; > 'nv3^:(i.5!28)_28{.5#1'; '#: nc^:(i.5!28) 31'; '#: nct^:(i.5!28) 31'; > '#: 5 ncb 28' > > +-----+-------+------+----+-----+ > |place| rlprf | rlt |rls |verbs| > +-----+-------+------+----+-----+ > |3 | 861.83|216.89|3.97| nv | > +-----+-------+------+----+-----+ > |4 |1029.54|259.10|3.97| nv3 | > +-----+-------+------+----+-----+ > |2 | 580.08|210.85|2.75| nc | > +-----+-------+------+----+-----+ > |1 | 207.48| 75.42|2.75| nct | > +-----+-------+------+----+-----+ > |0 | 1.00| 1.00|1.00| ncb | > +-----+-------+------+----+-----+ > > > where the verbs are > > +----+----------------------------------------------------------- > ----------+ > | nv |+-+-+-------------------------------- > + | > | ||3|:| j=. 0 i:~ (>: +./\.) > y | | > | || | | (j{.y),1,(1+j- > #y){.1$~_1++/j}.y| | > | |+-+-+-------------------------------- > + | > +----+----------------------------------------------------------- > ----------+ > | nv3|+-+-+--------------------------------------- > + | > | ||3|:| one=.y i: > 1 | | > | || | | zer=.y i: > 0 | | > | || | | if. one < zer > do. | | > | || | | zer=. (one {. y) i: > 0 | | > | || | | 1 0 (zer+0 1)} y /: > y+2*(2+zer)<.i.#y| | > | || | | > else. | | > | || | | 1 0 (zer+0 1)} > y | | > | || | | > end. | | > | |+-+-+--------------------------------------- > + | > +----+----------------------------------------------------------- > ----------+ > | nc |+-+-+-------------------------------- > + | > | ||3|:| n=. > y | | > | || | | t=. n xor n and n- > 1 | | > | || | | b=. > t+n | | > | || | | b or _2 shift (b xor n) <[EMAIL PROTECTED] > t| | > | |+-+-+-------------------------------- > + | > +----+----------------------------------------------------------- > ----------+ > | nct|(] 23 b. (_2"_) 33 b. -~ <[EMAIL PROTECTED] ] 22 b. [) (] + ] 22 b. > ] 17 b. ]- 1:)| > +----+----------------------------------------------------------- > ----------+ > | ncb|[: |.@; [: (+&.> <@;\.)/ [ */&(2 <[EMAIL PROTECTED] |[EMAIL PROTECTED]) > >:@- > ~ | > +----+----------------------------------------------------------- > ----------+ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
