From 8ebed0e7018552fe22632361583d7a76d66c5a3b Mon Sep 17 00:00:00 2001 From: Alex Nejman <55002482+anejman@users.noreply.github.com> Date: Fri, 1 Dec 2023 07:31:37 -0500 Subject: [PATCH] Resolved Issue [Program]: Write a F# program to convert string to vowelcase #3593 (#4803) Co-authored-by: Anandha Krishnan S Co-authored-by: Baliram Singh --- .../ConvertStringToVowelcase.fs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 program/program/convert-string-to-vowelcase/ConvertStringToVowelcase.fs diff --git a/program/program/convert-string-to-vowelcase/ConvertStringToVowelcase.fs b/program/program/convert-string-to-vowelcase/ConvertStringToVowelcase.fs new file mode 100644 index 000000000..aaa044066 --- /dev/null +++ b/program/program/convert-string-to-vowelcase/ConvertStringToVowelcase.fs @@ -0,0 +1,16 @@ +let convertToVowelCase (inputString: string) = + let vowels = "aeiouAEIOU" + + let isVowel (c: char) = vowels.Contains(c) + + let applyVowelCase (c: char) = + if isVowel c then System.Char.ToUpper(c) else System.Char.ToLower(c) + + let result = inputString.ToCharArray() |> Array.map applyVowelCase |> System.String + + result + +// Example usage: +let input = "hello world" +let output = convertToVowelCase input +printfn "Input: %s\nOutput: %s" input output \ No newline at end of file