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.180 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.179 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.178 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.177 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.176 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.175 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.174 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.173 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.172 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.171 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.170 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.169 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.167 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.166 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.165 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.164 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.163 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.162 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.161 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.160 tracks/sml/exercises/roman-numerals/example.sml