]> gitweb.factorcode.org Git - factor.git/commitdiff
math.extras: faster next-permutation-bits using /i.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 10 Apr 2013 21:44:21 +0000 (14:44 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 10 Apr 2013 21:44:21 +0000 (14:44 -0700)
extra/math/extras/extras-tests.factor
extra/math/extras/extras.factor

index 363192896fc4da163f9e985e930d0303b98aac63..a815283f7dc5db965ac5763da8fb401ce3f69d2d 100644 (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
 
 {
index 5cb45d06c9d3cff364a55bfd657b30e2ac37da22..6888226e15ab5cb528e1553008e11112ae517a8d 100644 (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 _ >= ] ]