Convert decimal to binary in Haskell


/ Published in: Other
Save to your folder(s)



Copy this code and paste it in your HTML
  1. decToBin x = reverse $ decToBin' x
  2. where
  3. decToBin' 0 = []
  4. decToBin' y = let (a,b) = quotRem y 2 in [b] ++ decToBin' a

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.