Skip to content

Commit 87408b9

Browse files
committed
add lower_case string algorithm
1 parent 8c09d4a commit 87408b9

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/string/lower_case.jule

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pub fn lower_case(mut string: str): str {
2+
for i, c in string {
3+
if c >= 'A' && c <= 'Z' {
4+
string[i] = 'z' - ('Z' - c)
5+
}
6+
}
7+
8+
ret string
9+
}

test.jule

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use src::string::{
1616
is_alpha,
1717
is_digit,
1818
upper_case,
19+
lower_case,
1920
}
2021

2122
static mut TESTS: TestStack = TestStack.new()
@@ -85,6 +86,10 @@ fn add_tests_string() {
8586
TESTS.add("upper_case", fn(): bool {
8687
ret upper_case("foO") == "FOO"
8788
})
89+
90+
TESTS.add("lower_case", fn(): bool {
91+
ret lower_case("FOo") == "foo"
92+
})
8893
}
8994

9095
fn main() {

0 commit comments

Comments
 (0)