Created
August 21, 2015 13:54
-
-
Save stdray/29258310b4028c20b227 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| open System | |
| type Command = | |
| | DoSomeStuff | |
| | DoSomeOtherStuff | |
| let tryParse str = | |
| DoSomeStuff |> Some | |
| let execute cmd = | |
| printfn "%A" cmd | |
| let rec readLines stopCond = seq { | |
| let line = Console.ReadLine() | |
| if not (stopCond line) then | |
| yield line | |
| yield! readLines stopCond | |
| } | |
| [<EntryPoint>] | |
| let main argv = | |
| let lines = readLines (fun str -> String.IsNullOrEmpty(str) || str = "QQ") | |
| for line in lines do | |
| match tryParse line with | |
| | None -> printfn "Can not parse command" | |
| | Some(cmd) -> execute cmd | |
| 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment