aboutsummaryrefslogtreecommitdiff
path: root/pseudocode-lib/_exp_string.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-20 11:04:39 +0000
committer_ov4 <ov4@ov4.org>2026-10-20 11:04:39 +0000
commit52e0674c54d4b53b2132e750106cc9acb266ed39 (patch)
tree9d605a6ca2bd6aa894dc46e18dc86da8298bf61d /pseudocode-lib/_exp_string.cc
parent8975d167c849f54664be8d5da418cd909694d26f (diff)
feat(library): add experimental string IS_NUM 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.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/pseudocode-lib/_exp_string.cc b/pseudocode-lib/_exp_string.cc
index ae53ac1..4cfd650 100644
--- a/pseudocode-lib/_exp_string.cc
+++ b/pseudocode-lib/_exp_string.cc
@@ -1,6 +1,7 @@
#include <algorithm>
#include <cctype>
#include <cstdio>
+#include <cstdlib>
#include <exception>
#include <stdexcept>
#include <string>
@@ -127,6 +128,14 @@ void _exp_string_impl_chr(void *Target, long long Code) {
text(Target).assign(1, static_cast<char>(static_cast<unsigned char>(Code)));
});
}
+int _exp_string_impl_is_num(void *Handle) {
+ return checked([&]() -> int {
+ const auto &Source = text(Handle);
+ char *End = nullptr;
+ std::strtod(Source.c_str(), &End);
+ return !Source.empty() && End == Source.c_str() + Source.size();
+ });
+}
void _exp_string_impl_output(void *Handle) {
checked([&] {
const auto &Text = text(Handle);