Created
March 15, 2018 11:19
-
-
Save kgtkr/74b1f388665c1d0ddc62c8ed721852cd to your computer and use it in GitHub Desktop.
bit2int(hs)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main :: IO () | |
main = print $ bit2int "11111111" 0 | |
bit2int :: [Char] -> Int -> Int | |
bit2int [] x = x | |
bit2int ('0':ss) x = bit2int ss x | |
bit2int ('1':ss) x = bit2int ss x + 2 ^ length ss | |
bit2int _ _ = undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment