aboutsummaryrefslogtreecommitdiff
path: root/pseudocode-lib/_exp_string.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-20 10:56:22 +0000
committer_ov4 <ov4@ov4.org>2026-10-20 10:56:22 +0000
commitcf9af14fe749c52473fdf5a327c3e935e45bf0e7 (patch)
tree4c22c4a919e3da709b16055ff6762ea1195b6237 /pseudocode-lib/_exp_string.cc
parent1ed0e276a37d39386b22b08c1f9e575a8f8f8725 (diff)
feat(library): add experimental string LEFT function
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'pseudocode-lib/_exp_string.cc')
-rw-r--r--pseudocode-lib/_exp_string.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/pseudocode-lib/_exp_string.cc b/pseudocode-lib/_exp_string.cc
index 248b718..ada7c8c 100644
--- a/pseudocode-lib/_exp_string.cc
+++ b/pseudocode-lib/_exp_string.cc
@@ -1,3 +1,4 @@
+#include <algorithm>
#include <cstdio>
#include <exception>
#include <stdexcept>
@@ -65,6 +66,13 @@ double _exp_string_impl_to_real(void *Handle) {
long long _exp_string_impl_length(void *Handle) {
return checked([&] { return static_cast<long long>(text(Handle).size()); });
}
+void _exp_string_impl_left(void *Target, void *Handle, long long Count) {
+ checked([&] {
+ const auto &Source = text(Handle);
+ auto Length = Count <= 0 ? 0 : std::min(static_cast<std::size_t>(Count), Source.size());
+ text(Target) = Source.substr(0, Length);
+ });
+}
void _exp_string_impl_output(void *Handle) {
checked([&] {
const auto &Text = text(Handle);