I'm searching for a function that is in a lot of other languages called join
. It would act like the the reverse of split
.
I would expect it to work that str_join(split("1;2", ";"), ";")
would become "1:2"
I'm not sure if it exist, but you could define it like this:
str_join(list, delim) := block(
if length(list) = 0 then return (""),
lreduce(
lambda(
[p,c],
if not(stringp(p)) then p: string(p),
if not(stringp(c)) then c: string(c),
concat(p, delim, c)
),
list
)
);