From e3abe07f4b287188407326b44267347ba3bd0239 Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Tue, 27 Jan 2026 12:19:26 +1100 Subject: [PATCH] Add intToString() and stringToInt() functions --- src/solstice_stdlib.cpp | 16 ++++++++++++++++ tests/convert.sols | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/convert.sols diff --git a/src/solstice_stdlib.cpp b/src/solstice_stdlib.cpp index 846aa57..7fd223b 100644 --- a/src/solstice_stdlib.cpp +++ b/src/solstice_stdlib.cpp @@ -28,6 +28,22 @@ def println(string msg) string { return msg } +def stringToInt(string in) int { + result = 0 + ground { + stoi $in &result + } + return result +} + +def intToString(int in) string { + result = "" + ground { + tostring $in &result + } + return result +} + // End Solstice stdlib )"; diff --git a/tests/convert.sols b/tests/convert.sols new file mode 100644 index 0000000..c99068f --- /dev/null +++ b/tests/convert.sols @@ -0,0 +1,8 @@ +myString = "312" +myInt = 435 + +myNewString = intToString(myInt) +myNewInt = stringToInt(myString) + +println(myNewString) +puts myNewInt