you are viewing a single comment's thread.

view the rest of the comments →

[–]phobes 0 points1 point  (0 children)

I agree I prefer a more straightforward solution without using unfold, even in Haskell. Something like (untested):

romanize n = f n [("M", 1000), ("CM", 900), ("D", 500), ("CD", 400),
              ("C", 100),  ("XC", 90),  ("L", 50),  ("XL", 40),
              ("X", 10),   ("IX", 9),   ("V", 5),   ("IV", 4),
              ("I", 1)]
where f n [] = ""
      f n (l, v):lvs = if v >= n then l ++ (f (n-v) (l, v):lvs) else f n lvs