My first request would be to create a .join method for the builtin Array-type.
Since the String object has a .split method, which splits a string into an Array, this would make sense to implement.
The method could join the Array to a String with the delimeter as a parameter.
Here is a reference implementation in TScript:
function join(arr, sep = "")
{
var out = "";
for var em in arr do {
if out.size() > 0 then
out += sep;
out += em;
}
return out;
}
The function would make dealing with strings much more pleasant (And more akin to both c and c++), because it allows simple conversion between Strings and Arrays with member modification.
My second request would be iterating over reverse ranges (for x in 100:0), which could have been handy together with the .join method for base-conversion.
function base8(n)
{
var out = Array(8, 0);
for var x in out.size():0 do {
out[x] = (n % 8); n //= 8;
if n == 0 then
break;
}
if n > 0 then error("number too large");
return join(out);
}
My first request would be to create a
.joinmethod for the builtin Array-type.Since the String object has a
.splitmethod, which splits a string into an Array, this would make sense to implement.The method could join the Array to a String with the delimeter as a parameter.
Here is a reference implementation in TScript:
The function would make dealing with strings much more pleasant (And more akin to both c and c++), because it allows simple conversion between Strings and Arrays with member modification.
My second request would be iterating over reverse ranges (
for x in 100:0), which could have been handy together with the .join method for base-conversion.