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.180 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.179 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.178 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.177 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.176 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.175 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.174 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.173 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.172 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.171 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.170 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.169 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.167 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.166 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.165 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.164 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.163 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.162 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.161 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs
trackler-2.2.1.160 tracks/haskell/exercises/roman-numerals/examples/success-standard/src/Roman.hs