Ah, thanks! I guess there is some limitation that I cannot just have a function (e.g. join) insert bits of code into an equation, as I’m familiar to do with LaTeX, so the processing of the code into contents has to be made explicit by eval? Probably this has to do with functions being pure?
It can be done! Without string wrangling or eval or a third party package. The key is not to convert strings and numbers to math, but just use math to begin with.
#let N = 6
$
sum_(i=1)^#N i =
#range(1, N).map(num => $& num +$).join($ \ $) \
& #N \
=& #range(N + 1).sum()
$
This is the answer to the literal question and for everyone who will stumble upon this in the future, I am glad you put in this answer; the proposal by Jollywatt however is the suggestion I needed in this case.