Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
|||
require! 'prelude-ls': {fold, sum}
|
||||
|
||||
# String → Number
|
||||
decimal_of_roman = do
|
||||
# [Number, Number] → String → [Number, Number]
|
||||
_convert = ([acc, last_value], ch) ->
|
||||
current_value = { M:1000 D:500 C:100 L:50 X:10 V:5 I:1 }[ch] ? 0
|
||||
op = if last_value < current_value then (-) else (+)
|
||||
[op(acc, last_value), current_value]
|
||||
# fold the string and sum the resulting tuple (array)
|
||||
fold(_convert, [0, 0]) >> sum
|
||||
|
||||
{[rom, decimal_of_roman rom] for rom in <[ MCMXC MMVII MDCLXVII MMMCLIX MCMLXXVII MMX ]>}
|
||||
Loading…
Add table
Add a link
Reference in a new issue