From 348d16d99b44b95f41af93be3f963c39b3094f92 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 4 Oct 2021 20:42:02 +0200 Subject: [PATCH] includes/std: Added string reverse function --- includes/libstd/string.pat | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/includes/libstd/string.pat b/includes/libstd/string.pat index 82c7380..9d0fa98 100644 --- a/includes/libstd/string.pat +++ b/includes/libstd/string.pat @@ -27,4 +27,18 @@ namespace std::string { return false; }; + fn reverse(str string) { + str result; + + s32 i; + i = std::string::length(string); + while (i > 0) { + i = i - 1; + result = result + std::string::at(string, i); + } + + return result; + }; + + } \ No newline at end of file