Last active
July 12, 2018 07:51
-
-
Save mrange/ac3f3d2c3bbb5efb1711e717d6112ac1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cuteParse = | |
let split (c: char) (s: string) = s.Split c | |
let trim (s: string) = s.Trim () | |
let op c r f = split c >> Seq.map (trim >> f) >> Seq.reduce r | |
int |> op '/' (/) |> op '*' (*) |> op '-' (-) |> op '+' (+) | |
[<EntryPoint>] | |
let main argv = | |
let examples = [| "1"; "1-3"; "1*3"; "1 + 2*3 - 2" |] | |
for example in examples do | |
printfn "%s -> %d" example <| cuteParse example | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment