1. ally
2. army
3. baby
4. lady
5. navy
- // Learn more about F# at http://fsharp.net
- open System
- //change the console title
- System.Console.Title<-"Convert to Plural"
- //adds the foreground and background color
- System.Console.ForegroundColor<-ConsoleColor.Blue
- System.Console.BackgroundColor<-ConsoleColor.White
- //clears the screen. This is to apply the background color once the
- //console application is loaded
- System.Console.Clear()
- //assigns the singular nouns to our array variable singularnouns
- let singularnouns=[|"ally";"army";"baby";"lady";"navy"|]
- printfn "Singular words:"
- //iterates through the values of our singularnouns array variable
- singularnouns|>Array.iter(fun singularwords->printfn "%s" singularwords)
- printfn "Plural words:"
- //iterates through the values of our singularnouns array variable
- //replace the word in each array element from "y" to "ies"
- singularnouns|>Array.iter(fun pluralnouns->
- let pluralwords= pluralnouns.Replace("y","ies")
- printfn "%s" pluralwords)
This will display the following output: