elm-binary icon indicating copy to clipboard operation
elm-binary copied to clipboard

suggestion about fromDecimal

Open hisusqristos opened this issue 2 years ago • 0 comments


{- toBinary 4 -> [ 1, 0, 0] -}

toBinary : Int -> List Int
toBinary n =
    case n of
        0 ->
            [ 0 ]

        1 ->
            [ n ]

        _ ->
            toBinary (n // 2) ++ [ remainderBy 2 n ]

hisusqristos avatar Nov 28 '23 15:11 hisusqristos