From aef2a1e4fae812220b29ec939be239cee5225b1a Mon Sep 17 00:00:00 2001 From: Kai Gunger Date: Tue, 30 Dec 2025 23:16:01 -0500 Subject: finding parent scopes --- tnslc/utils/algo.tnsl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tnslc/utils/algo.tnsl') 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 -- cgit v1.2.3