Skip to content

Commit 92324e2

Browse files
authored
Add an algorithm for checking if a string is in lowercase (#131)
1 parent c2dcaff commit 92324e2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

text_manipulation/is.lower.R

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
is.lowercase <- function(string) {
2+
# split the string at character level
3+
string_split <- c(unlist(strsplit(string, split = "")))
4+
# check if the split string exactly matches its lowercase version
5+
check_case <- string_split == tolower(string_split)
6+
# return a boolean value based on the outcome of the check
7+
return(all(check_case))
8+
}
9+
10+
is.lowercase("social")
11+
12+

0 commit comments

Comments
 (0)