Elm
toHexadecimalLetter : Int -> String toHexadecimalLetter integer = case integer of 10 -> "A" 11 -> "B" 12 -> "C" 13 -> "D" 14 -> "E" 15 -> "F" _ -> String.fromInt integer toHexadecimal : Int -> String toHexadecimal integer = let clampedInteger = clamp 0 255 integer integerDivision = clampedInteger // 16 decimalDivision = toFloat clampedInteger / 16.0 rest = floor ((decimalDivision - toFloat integerDivision) * 16) in toHexadecimalLetter integerDivision ++ toHexadecimalLetter rest rgb : Int -> Int -> Int -> String rgb red green blue = [red, green, blue] |> List.map toHexadecimal |> String.join ""
Test.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Elm
Test.