Is there a notation for iterated/repeat concatenation?

873 Views Asked by At

Given a string x and natural number y, is there a commonly used notation for a function that concatenates string x to itself y times? Example:
$x = \mathrm{'foobar'}$
$y = 3$
$f(x,y)=\mathrm{'foobarfoobarfoobarfoobar'}=x||x||x||x$
Where $||$ denotes concatenation between the term before and after, in a left-to-right fashion.

2

There are 2 best solutions below

0
On BEST ANSWER

Formal concatenation of strings is often written as literal concatenation, with no symbol like $||$. With that convention, $$ (\text{foo})^3 = \text{foofoofoo}. $$

Perhaps that convention will work in your context. Just say so and readers will have no trouble.

4
On

You could probably generalize the notation that we might use in other contexts for iteration, e.g. $\sum, \prod, \bigoplus$: have a big operator (or representative of it like with the sigma/pi notation), and indices above and below. With this in mind, if we let $||$ be the operator, then we might expression iterated concatenation as

$$\underset{i=1} {\overset{k} {\LARGE ||}} x = \underbrace{x||x||x||...||x||x||x}_{\substack{ \text{x appears k+1 times} \\ \text{concatenation, ||, appears k times}}}$$

Thus, your function in question has

$$f(x,y) = \underset{i=1} {\overset{y} {\LARGE ||}} x$$

But I will make the caveat that I've never, ever seen this notation before, but then again I often also don't see concatenate expressed explicitly. So this is probably moreso a notation that is simply "inspired by," so to speak, other notations, and less so an actual, common convention.

Thus if you were planning to use this in anything "official" academically, e.g. publications, it would be prudent to at some point explain exactly what is meant by this notation. But it does luckily appeal to the same intuitions the other notations give us, so it at least might be easily understood.