how about this, for wordSize? I used quickcheck to verify that my
wordSize2 is the same as yours.
Actually, it's not! if you allow negative integers in the list, it's not
at any rate. ("falsifiable after 50 tries")
I haven't thought through what this means... if your function isn't quite
right, or mine, or it doesn't really matter.
Also I would be curious to see this quickchecked but not allowing negative
integers in the list if someone can show me how to do that.
Also, I commented out intToBinWord because intToBin isn't in prelude nor
in any library I could track down and I'm not sure what it was supposed to
do.
thomas.
import Data.List
import Data.Maybe
import Test.QuickCheck
wordSize :: [Int] -> Int
wordSize xs = head (dropWhile (<(length xs)) $ iterate (*2) 8)
wordSize2 :: [Int] -> Int
wordSize2 xs = fromJust $ find (>(length xs)) $ iterate (*2) 8
main = quickCheck $ \xs -> wordSize2 ( xs :: [Int]) == wordSize xs
{-
intToBinWord :: Int -> [Int]
intToBinWord n = reverse (take elements (xs ++ repeat 0))
where
xs = reverse (intToBin n)
elements = wordSize xs
-}
PR Stanley