math.extras: faster next-permutation-bits using /i.

db4
John Benediktsson 2013-04-10 14:44:21 -07:00
parent 336e2bfd58
commit 83659c228a
2 changed files with 2 additions and 2 deletions

View File

@ -130,7 +130,7 @@ IN: math.extras.test
{ 10 } [ 12 5 round-to-step ] unit-test
{ 15 } [ 13 5 round-to-step ] unit-test
{ 0b101 } [ 0b11 next-permutation-bits ] unit-test
{ 0b101 } [ 0b011 next-permutation-bits ] unit-test
{ 0b110 } [ 0b101 next-permutation-bits ] unit-test
{

View File

@ -261,7 +261,7 @@ M: float round-to-even
: next-permutation-bits ( v -- w )
[ dup 1 - bitor 1 + dup ] keep
[ dup neg bitand ] bi@ / -1 shift 1 - bitor ;
[ dup neg bitand ] bi@ /i -1 shift 1 - bitor ;
: permutation-bits ( bit-count bits -- seq )
[ on-bits dup '[ dup _ >= ] ]