
2 Sep
2010
2 Sep
'10
2:56 a.m.
2010/9/2 Alec Benzer
What's the quickest/the best/a way of converting a series of bits into bytes? Ie, converting a [Bool] to a [Word8]. So if I had replicate 8 True ++ replicate 8 False :: [Bool], it would spit out [255,0] :: [Word8].
Simple way : l = [False,False,False,True,False,False,True] foldl' (\a b -> a*2 + if b then 1 else 0) 0 l