Sha256: 4957da7afae24713e6d8e39b3e93a108c234f21c7954b7d607f5fc5cec2beb95

Contents?: true

Size: 549 Bytes

Versions: 142

Compression:

Stored size: 549 Bytes

Contents

fun roman number =
  let
    val pairs = [
        (1000, "M"),
        (900 , "CM"),
        (500 , "D"),
        (400 , "CD"),
        (100 , "C"),
        (90  , "XC"),
        (50  , "L"),
        (40  , "XL"),
        (10  , "X"),
        (9   , "IX"),
        (5   , "V"),
        (4   , "IV"),
        (1   , "I") 
    ]

    fun loop 0 _  = []
      | loop _ [] = []
      | loop n (ps as ((num, rep) :: ps')) =
          if n < num
          then loop n ps'
          else rep :: loop (n - num) ps
  in
    concat (loop number pairs)
  end

Version data entries

142 entries across 142 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.97 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.96 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.95 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.94 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.93 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.92 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.91 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.90 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.89 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.88 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.87 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.86 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.85 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.84 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.83 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.82 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.81 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.80 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.79 tracks/sml/exercises/roman-numerals/example.sml