Skip to content

Commit

Permalink
An algorithm for checking if a string is in lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
Ifeanyi55 authored Oct 24, 2024
1 parent 7f00733 commit b356aa1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions text_manipulation/is.lower.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
is.lowercase <- function(string) {
# split the string at character level
string_split <- c(unlist(strsplit(string, split = "")))
# check if the split string exactly matches its lowercase version
check_case <- string_split == tolower(string_split)
# return a boolean value based on the outcome of the check
if (all(check_case) == TRUE) {
return(TRUE)
} else {
return(FALSE)
}
}

is.lowercase("social")


0 comments on commit b356aa1

Please sign in to comment.