Sha256: 2f68c1ec458dbe6d5c605a217bd9b667e7123667429b361efcf2cbabddc81492

Contents?: true

Size: 524 Bytes

Versions: 396

Compression:

Stored size: 524 Bytes

Contents

module Roman (numerals) where

numerals :: Int -> Maybe String
numerals = Just . go numeralMap
  where
    go pairs@((value, digits):pairs') n
      | n >= value = digits ++ go pairs (n - value)
      | otherwise  = go pairs' n
    go [] _ = ""
    numeralMap = [ (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") ]

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.97 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.96 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.95 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.94 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.93 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.92 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.91 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.90 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.89 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.88 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.87 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.86 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.85 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.84 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.83 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.82 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.81 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.80 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.79 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs