Skip to content

Commit e23a607

Browse files
Added uppercase to Strings
1 parent 487f64e commit e23a607

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Algorithms/Algorithms.fsproj

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
<Compile Include="Strings/WordOccurrence.fs" />
2222
<Compile Include="Strings/RemoveDuplicates.fs" />
2323
<Compile Include="Strings/ReverseWords.fs" />
24+
<Compile Include="Strings\Upper.fs" />
2425
<Compile Include="Program.fs" />
2526
</ItemGroup>
2627
</Project>

Algorithms/Strings/Upper.fs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace Algorithms.Strings
2+
3+
module Upper =
4+
/// <summary>
5+
/// Will convert the entire string to uppercase letters
6+
/// </summary>
7+
/// <param name="input">String to change to uppercase.</param>
8+
/// <returns>Uppercased string</returns>
9+
let upper (input: string) =
10+
let mutable str = ""
11+
for phrase in input.Split() do
12+
let mutable word = ""
13+
for letter in phrase do
14+
if letter >= 'a' && letter <= 'z'
15+
then word <- word + (string) ((char) ((int) letter - 32))
16+
else word <- word + (string) letter
17+
str <- str + word + " "
18+
str

0 commit comments

Comments
 (0)