Created
January 24, 2016 04:28
-
-
Save glebd/97594d5df97fe872c1b8 to your computer and use it in GitHub Desktop.
Solution to Module 2 Problem of Microsoft F# Course on edX
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 | |
[<EntryPoint>] | |
let main argv = | |
printf "Enter empty name or age to quit.\n" | |
let mutable canContinue = true | |
while canContinue do | |
printf "Name: " | |
let name = Console.ReadLine() | |
if name = "" then canContinue <- false | |
else | |
printf "Age: " | |
let parsed, age = Int32.TryParse(Console.ReadLine()) | |
if parsed = true && age > 0 then | |
let group = | |
if age >= 20 then "no longer a teenager" | |
elif age < 20 && age > 13 then "teenager" | |
else "child" | |
printf "%s (%d): %s\n" name age group | |
else canContinue <- false | |
0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment