Skip to content

Commit

Permalink
math.bitwise: remove duplicate logic in bitfield.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Aug 5, 2020
1 parent 70687a0 commit 126f3ac
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions basis/math/bitwise/bitwise.factor
Expand Up @@ -68,18 +68,16 @@ M: pair (bitfield-quot) ( spec -- quot )
'[ _ _ shift ]
] if ;

PRIVATE>

MACRO: bitfield ( bitspec -- quot )
: (bitfield) ( bitspec -- quot )
[ [ 0 ] ] [
[ (bitfield-quot) ] [ '[ @ _ dip bitor ] ] map-reduce
] if-empty ;

MACRO: bitfield* ( bitspec -- quot )
reverse
[ [ 0 ] ] [
[ (bitfield-quot) ] [ '[ @ _ dip bitor ] ] map-reduce
] if-empty ;
PRIVATE>

MACRO: bitfield ( bitspec -- quot ) (bitfield) ;

MACRO: bitfield* ( bitspec -- quot ) reverse (bitfield) ;

! bit-count
<PRIVATE
Expand Down

0 comments on commit 126f3ac

Please sign in to comment.