Sha256: 6aa45b74e1600f83f4c8ab6266640092e24108ec88d6ab070ad9d86bb4124403
Contents?: true
Size: 603 Bytes
Versions: 310
Compression:
Stored size: 603 Bytes
Contents
-module(example). -export([numerals/1, test_version/0]). -define(DIGITS, [{"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}]). -spec numerals(non_neg_integer()) -> string(). numerals(Number) -> to_roman(Number, "", ?DIGITS). test_version() -> 1. to_roman(0, Roman, _) -> Roman; to_roman(N, Roman, Digits) -> {R, D} = hd(Digits), if N >= D -> to_roman(N - D, Roman ++ R, Digits); true -> to_roman(N, Roman, tl(Digits)) end.
Version data entries
310 entries across 310 versions & 1 rubygems