if you are going from back to front, it is a bit easier to "parse". So this time F# instead of my usual C# posts.
Yes, still learning...
let roman list : int = let getNumeralValue x = match x with | 'M' -> 1000 | 'm' -> 1000 | 'D' -> 500 | 'd' -> 500 | 'C' -> 100 | 'c' -> 100 | 'L' -> 50 | 'l' -> 50 | 'X' -> 10 | 'x' -> 10 | 'V' -> 5 | 'v' -> 5 | 'I' -> 1 | 'i' -> 1 | _ -> 0 let folder (sum,last) current = if last > current then (sum-current,last) else (sum+current,current) Seq.rev list |> Seq.map getNumeralValue |> Seq.fold folder (0,0) |> fst
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
if you are going from back to front, it is a bit easier to "parse".
So this time F# instead of my usual C# posts.
Yes, still learning...