Skip to content

Instantly share code, notes, and snippets.

@kgtkr
Created March 15, 2018 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgtkr/74b1f388665c1d0ddc62c8ed721852cd to your computer and use it in GitHub Desktop.
Save kgtkr/74b1f388665c1d0ddc62c8ed721852cd to your computer and use it in GitHub Desktop.
bit2int(hs)
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