Today, in this article we will try to create a very simple F# program whose work is to identify person's age details.When the user specifies some age, it should display the type of category that the person belongs to.
The Complete Code for this Application looks like this:
open System
let (|Teenage|Younger|) n = if n >= 1 && n < 8 then Teenage else Younger;
let (|Younger|MidAge|) n = if n >= 8 && n < 18 then Younger else MidAge;
let (|MidAge|Older|) n = if n >= 18 && n < 35 then MidAge else Older;
let (|Older|SeniorCitizen|) n = if n > 65 then SeniorCitizen else Older;
let Simple n =
match n with
| Teenage -> printfn "This Person's Age is : %d is Teenage \n" n
| Younger -> printfn "This Person's Age is : %d is Younger \n" n
| MidAge -> printfn "This Person's Age is : %d is MidAge \n" n


Join the conversation! Your thoughts help the community grow.