You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Learn more about F# at http://docs.microsoft.com/dotnet/fsharp
open System
/// Decodes a Roman Number string to a int number // https://twitter.com/nikoloz_p/status/1421218836896960515
let DecodeRomanNumeral RomanNumeral =
let DigitToNumber = function
| 'I' -> 1
| 'V' -> 5
| 'X' -> 10
| 'L' -> 50
| 'C' -> 100
| 'D' -> 500
| 'M' -> 1000
| c -> failwith (sprintf "Invalid digit %c" c)
let rec sum' Numbers =
match Numbers with
| [] ->0
| x::y::rest when x < y -> y - x + sum' rest
| x::rest -> x + sum' rest
RomanNumeral
|> Seq.map DigitToNumber
|> Seq.toList
|> sum'
[<EntryPoint>]
let main argv =
let message = DecodeRomanNumeral "XVXV"
printfn "Hello world %i" message
0
The text was updated successfully, but these errors were encountered:
Copied from VSFeedback
The text was updated successfully, but these errors were encountered: