The same as C way. You can import Data.Bits and can use the functions. Prelude> import Data.Bits Prelude Data.Bits> Data.Bits. Data.Bits..&. Data.Bits.bitDefault Data.Bits.complementBit Data.Bits.rotate Data.Bits.shift Data.Bits.testBitDefault Data.Bits..|. Data.Bits.bitSize Data.Bits.isSigned Data.Bits.rotateL Data.Bits.shiftL Data.Bits.unsafeShiftL Data.Bits.Bits Data.Bits.clearBit Data.Bits.popCount Data.Bits.rotateR Data.Bits.shiftR Data.Bits.unsafeShiftR Data.Bits.bit Data.Bits.complement Data.Bits.popCountDefault Data.Bits.setBit Data.Bits.testBit Data.Bits.xor Prelude Data.Bits> (.&.) 1 2 0 Prelude Data.Bits> (.&.) 2 2 2 I wrote a minimum spanning tree code and rather than maintaining the list of visited nodes, I took a Integer because of arbitrary precision and set the bits accordingly. visited :: Int -> Integer -> ( Bool , Integer ) visited x vis = ( t == 0 , vis' ) where t = ( B..&. ) ( B.shiftL ( 1 :: Integer ) x ) vis vis' = ( B..|. ) ( B.shiftL ( 1 :: Integer ) x ) vis Mukesh On Tue, Feb 19, 2013 at 8:41 PM, Branimir Maksimovic <bmaxa@hotmail.com>wrote:
In C usual way is to set some bit in integer variable by shifting or oring, and than check flag integer variable by anding with particular flag value. What is Haskell way?
Thanks.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe