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 _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
