Created
October 6, 2017 07:07
-
-
Save fgaz/e01e7367195752f826a2471b97cf4bf3 to your computer and use it in GitHub Desktop.
integral to roman number converter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Roman where | |
values = [ (1000, "M") | |
, (900, "CM") | |
, (500, "D") | |
, (400, "CD") | |
, (100, "C") | |
, (50, "L") | |
, (40, "XL") | |
, (10, "X") | |
, (9, "IX") | |
, (5, "V") | |
, (4, "IV") | |
, (1, "I") ] | |
f n = case dropWhile ((>n) . fst) values | |
of [] -> "" | |
(d,r):_ -> r ++ f (n - d) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment