
30 Sep
2009
30 Sep
'09
10:27 a.m.
Very fast for long boolean lists by using a strict foldl and reversing the input: bsToInt :: [Bool] -> Integer bsToInt = foldl' ((.fromIntegral.fromEnum).(+).join(+)) 0. reverse Try this: (>1) $ bsToInt $ take 100000 $ cycle [True,True,False,True,True,False,True]
bitsToInt :: [Bool] -> Integer bitsToInt = foldr((.(flip shiftL 1)).(+)) 0. map (fromIntegral.fromEnum)
-- Met vriendelijke groet, =@@i