Created
October 14, 2015 16:15
-
-
Save lucian1900/b52bf440f8234243837a 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 rec prompt convert msg = | |
printf msg | |
try | |
Console.ReadLine() |> convert | |
with _ -> prompt convert msg | |
let processPersonInfo() = | |
let name = prompt string "Name: " | |
let age = prompt int "Age: " | |
let kind = if age >= 20 then "no longer a teenager" | |
elif age < 20 && age > 13 then "teenager" | |
else "child" | |
printf "%s (%i) is a %s.%s" name age kind Environment.NewLine | |
[<EntryPoint>] | |
let main argv = | |
let n = prompt int "How many people? " | |
for i = 1 to n do | |
processPersonInfo() | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment