Posted By

aflatter on 02/03/09


Tagged

decimal binary conversion convert haskell


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

keigoi


Convert decimal to binary in Haskell


 / Published in: Other
 

  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
Posted By: aflatter on February 3, 2009

usage: decToBin 10 => [1,0,1,0]

You need to login to post a comment.