Skip to content

Instantly share code, notes, and snippets.

@estebistec
Last active August 29, 2015 13:56
Show Gist options
  • Save estebistec/9147499 to your computer and use it in GitHub Desktop.
Save estebistec/9147499 to your computer and use it in GitHub Desktop.
Haskell 4 Madhurima
intToBinStr :: Int -> String
intToBinStr n =
let _shiftBits 0 s = s ++ "0"
_shiftBits 1 s = s ++ "1"
_shiftBits x s = _shiftBits (div x 2) (s ++ show (mod x 2))
in _shiftBits n ""
main :: IO ()
main = print $ intToBinStr 19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment