Created
August 18, 2014 23:48
-
-
Save AlexArchive/fc99785a94b6ededf03c 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
open System | |
let highLowGame () = | |
let rng = new Random() | |
let secretNumber = rng.Next() % 100 | |
let rec highLowGameStep () = | |
printfn "Guess the secret number:" | |
let guessStr = Console.ReadLine() | |
let guess = Int32.Parse(guessStr) | |
match guess with | |
| _ when guess > secretNumber | |
-> printfn "The secret number is lower." | |
highLowGameStep() | |
| _ when guess = secretNumber | |
-> printfn "You've guessed correctly!" | |
() | |
| _ when guess < secretNumber | |
-> printfn "The secret number is higher." | |
highLowGameStep() | |
highLowGameStep() | |
highLowGame() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment