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.159 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.158 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.157 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.156 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.155 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.154 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.153 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.152 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.151 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.150 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.149 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.148 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.147 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.146 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.145 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.144 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.143 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.142 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.141 tracks/sml/exercises/roman-numerals/example.sml
trackler-2.2.1.140 tracks/sml/exercises/roman-numerals/example.sml