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.0.0.5 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.0.0.4 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.0.0.3 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.0.0.2 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-2.0.0.1 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-2.0.0.0 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.4.1 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.4.0 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.3.0 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.2.1 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.2.0 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.1.2 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.1.1 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.1.0 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.0.1 tracks/haskell/exercises/roman-numerals/src/Example.hs
trackler-1.0.0 tracks/haskell/exercises/roman-numerals/src/Example.hs