Date: Thu, 30 Aug 2007 14:18:15 +0200
From: "R.E. Boss" <[EMAIL PROTECTED]>
> > > > On Tue, 28 Aug 2007, Roger Hui wrote:
> > > >
> > > > > and =: 17 b.
> > > > > xor =: 22 b.
> > > > > or =: 23 b.
> > > > > shift=: 33 b.
> > > > >
> > > > > nc=: 3 : 0
> > > > > n=. y
> > > > > t=. n xor n and n-1
> > > > > b=. t+n
> > > > > b or _2 shift (b xor n) <[EMAIL PROTECTED] t
> > > > > )
I should have mentined it earlier. The expression
t=n^(n&(n-1));
b=t+n;
return b|(((b^n)/t)>>2);
was inspired by the following phrase from 7.2.1.3
(See also exercise 7.1-00, which presents a remarkable sequence of
seven bitwise operations that will convert any given binary number to
lexicographically next t-combination, assuming that n does not exceed
the computer's word length.)
Excersize 7.1-00 is probably in unwritten yet part.
Anyway, my solution contains 8 operations (unless I count them wrong) and
Knuth mentions 7. So three is still some room for improvement if you want to
go in this direction.
_________________________________________________________________
A new home for Mom, no cleanup required. All starts here.
http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm