-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Lower.fs
39 lines (38 loc) · 1003 Bytes
/
Lower.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
namespace Algorithms.Strings
module Lower =
/// <summary>
/// Will convert the entire string to lowercase letters
/// </summary>
/// <example>
/// <code>
/// lower("wow")
/// 'wow'
///
/// lower("HellZo")
/// hellzo'
///
/// lower("WHAT")
/// 'what'
///
/// lower("wh[]32")
/// 'wh[]32'
///
/// lower("whAT")
/// 'what'
/// </code>
/// </example>
/// <param name="input"></param>
/// <returns></returns>
let lower (input: string): string =
input.Split()
|> Array.map
(fun word ->
word.ToCharArray()
|> Array.map
(fun character ->
if character >= 'A' && character <= 'Z' then
char (int character + 32)
else
character)
|> (fun characters -> System.String.Concat(characters)))
|> String.concat " "