elm-binary
elm-binary copied to clipboard
suggestion about fromDecimal
{- toBinary 4 -> [ 1, 0, 0] -}
toBinary : Int -> List Int
toBinary n =
case n of
0 ->
[ 0 ]
1 ->
[ n ]
_ ->
toBinary (n // 2) ++ [ remainderBy 2 n ]