]> gitweb.factorcode.org Git - factor.git/commitdiff
math.bitwise: change bitfield to reduce from first argument rather than zero.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 31 May 2015 04:55:27 +0000 (21:55 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 31 May 2015 04:55:27 +0000 (21:55 -0700)
basis/math/bitwise/bitwise.factor

index 93765116dfa23451e3cbdcf4d8c1e624866cf4db..5ad335e7f99586861f467595f381fc0f17c8d586 100644 (file)
@@ -51,8 +51,7 @@ ERROR: bit-range-error x high low ;
 : W* ( x y -- z ) * 64 bits ; inline
 
 : symbols>flags ( symbols assoc -- flag-bits )
-    [ at ] curry map
-    0 [ bitor ] reduce ;
+    '[ _ at ] map 0 [ bitor ] reduce ;
 
 ! bitfield
 <PRIVATE
@@ -60,16 +59,22 @@ ERROR: bit-range-error x high low ;
 GENERIC: (bitfield-quot) ( spec -- quot )
 
 M: integer (bitfield-quot) ( spec -- quot )
-    [ swapd shift bitor ] curry ;
+    '[ _ shift ] ;
 
 M: pair (bitfield-quot) ( spec -- quot )
-    first2-unsafe over word? [ [ swapd execute ] dip ] [ ] ?
-    [ shift bitor ] append 2curry ;
+    first2-unsafe over word? [
+        '[ _ execute _ shift ]
+    ] [
+        '[ _ _ shift ]
+    ] if ;
 
 PRIVATE>
 
 MACRO: bitfield ( bitspec -- )
-    [ 0 ] [ (bitfield-quot) compose ] reduce ;
+    [ [ 0 ] ] [
+        [ (bitfield-quot) ] map unclip
+        [ '[ @ _ dip bitor ] ] reduce
+    ] if-empty ;
 
 ! bit-count
 <PRIVATE