Skip to content

Instantly share code, notes, and snippets.

@fgaz
Created October 6, 2017 07:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fgaz/e01e7367195752f826a2471b97cf4bf3 to your computer and use it in GitHub Desktop.
Save fgaz/e01e7367195752f826a2471b97cf4bf3 to your computer and use it in GitHub Desktop.
integral to roman number converter
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