-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(stdlib): add new functions in
std/text
(#373)
* feat(stdlib): add new functions in `std/text` - `reverse`: reverses the given text. - `is_prefix`: checks if a string is a prefix of another string. - `is_suffix`: checks if a string is a suffix of another string. These addition of `is_prefix` & `is_suffix` complement the existing `contains` function. * refactor: change `is_prefix` & `is_suffix` function names is_prefix -> starts_with is_suffix -> ends_with
- Loading branch information
1 parent
03c7705
commit 71224ec
Showing
4 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * from "std/text" | ||
|
||
main { | ||
if ends_with("hello world", "world") { | ||
echo "Succeded" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * from "std/text" | ||
|
||
// Output | ||
// dlrow olleh | ||
|
||
main { | ||
echo reverse("hello world") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * from "std/text" | ||
|
||
main { | ||
if starts_with("hello world", "hello") { | ||
echo "Succeded" | ||
} | ||
} |