Skip to content

Commit

Permalink
add lower_case string algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
lareii committed Jul 26, 2023
1 parent 8c09d4a commit 87408b9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/string/lower_case.jule
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pub fn lower_case(mut string: str): str {
for i, c in string {
if c >= 'A' && c <= 'Z' {
string[i] = 'z' - ('Z' - c)
}
}

ret string
}
5 changes: 5 additions & 0 deletions test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use src::string::{
is_alpha,
is_digit,
upper_case,
lower_case,
}

static mut TESTS: TestStack = TestStack.new()
Expand Down Expand Up @@ -85,6 +86,10 @@ fn add_tests_string() {
TESTS.add("upper_case", fn(): bool {
ret upper_case("foO") == "FOO"
})

TESTS.add("lower_case", fn(): bool {
ret lower_case("FOo") == "foo"
})
}

fn main() {
Expand Down

0 comments on commit 87408b9

Please sign in to comment.