Add flags to math.bitfields
parent
d864ff63a7
commit
16e206b3b8
|
@ -54,6 +54,8 @@ M: pair (bitfield-quot) ( spec -- quot )
|
||||||
|
|
||||||
\ bitfield [ bitfield-quot ] 1 define-transform
|
\ bitfield [ bitfield-quot ] 1 define-transform
|
||||||
|
|
||||||
|
\ flags [ flags [ ] curry ] 1 define-transform
|
||||||
|
|
||||||
! Tuple operations
|
! Tuple operations
|
||||||
: [get-slots] ( slots -- quot )
|
: [get-slots] ( slots -- quot )
|
||||||
[ [ 1quotation , \ keep , ] each \ drop , ] [ ] make ;
|
[ [ 1quotation , \ keep , ] each \ drop , ] [ ] make ;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
! Copyright (C) 2007 Slava Pestov.
|
! Copyright (C) 2007, 2008 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: arrays kernel math sequences words ;
|
USING: arrays kernel math sequences words ;
|
||||||
IN: math.bitfields
|
IN: math.bitfields
|
||||||
|
@ -13,3 +13,6 @@ M: pair (bitfield) ( value accum pair -- newaccum )
|
||||||
|
|
||||||
: bitfield ( values... bitspec -- n )
|
: bitfield ( values... bitspec -- n )
|
||||||
0 [ (bitfield) ] reduce ;
|
0 [ (bitfield) ] reduce ;
|
||||||
|
|
||||||
|
: flags ( values -- n )
|
||||||
|
0 [ execute bitor ] reduce ;
|
||||||
|
|
Loading…
Reference in New Issue