math.extras: faster next-permutation-bits using /i.
parent
336e2bfd58
commit
83659c228a
|
@ -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
|
||||
|
||||
{
|
||||
|
|
|
@ -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 _ >= ] ]
|
||||
|
|
Loading…
Reference in New Issue