diff options
| author | Kai Gunger <kgunger12@gmail.com> | 2025-12-30 23:16:01 -0500 |
|---|---|---|
| committer | Kai Gunger <kgunger12@gmail.com> | 2025-12-30 23:16:01 -0500 |
| commit | aef2a1e4fae812220b29ec939be239cee5225b1a (patch) | |
| tree | 7464ef01fb4957b8a4e726ea2072ce57ec677077 /tnslc/utils | |
| parent | 3a98cbd4d96041e78cb8748d674e9d5ea311054e (diff) | |
finding parent scopes
Diffstat (limited to 'tnslc/utils')
| -rw-r--r-- | tnslc/utils/algo.tnsl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tnslc/utils/algo.tnsl b/tnslc/utils/algo.tnsl index 49c4636..bde7b57 100644 --- a/tnslc/utils/algo.tnsl +++ b/tnslc/utils/algo.tnsl @@ -15,6 +15,25 @@ return out ;/ +/; ends_with (~uint8 str, suffix) [bool] + int chk = strlen(suffix) + int counter = 0 + + /; loop (str` !== 0) [str++] + /; if (suffix{counter} !== 0) + /; if (suffix{counter} == str`) + counter++ + ;; else + counter = 0 + ;/ + ;; else + counter = 0 + ;/ + ;/ + + return chk == counter +;/ + /; base_for_char (uint8 c) [int] /; if (c == 'b' || c == 'B') return 2 |