2
$\begingroup$

Given a string $s$ over some alphabet, I'd like to use the proper nomenclature/notation for the operation/function $f$ which inflates $s$ by independently duplicating each of its characters.

For instance: $$ f(abc) = aabbcc$$ or, more generally, a second argument could be provided to specify the number of copies: $$ f(xy,4) = xxxxyyyy$$

This should be embarassingly standard, so don't hesitate to shoot me in your response! (on the other hand, it is always difficult to search for something you cannot name, but I wouldn't accept such a lame excuse from my students, so...)

$\endgroup$
  • $\begingroup$ Not sure about a standard name, but in haskell that would be concatMap (replicate 3) (where concatMap is the flipped bind for the list monad). $\endgroup$ – Radu GRIGore Dec 23 '14 at 22:42
  • 1
    $\begingroup$ I know the name for its reverse: squeeze, used in the context of regular expressions :) . However "function that duplicates each character of a string" seems fine (to me). $\endgroup$ – Marzio De Biasi Dec 23 '14 at 23:55
  • 1
    $\begingroup$ @YannPonty I know it's a nomenclature question. For me, Haskell's library is the standard reference for the name of such functions. The names are chosen very carefully, and inspired by things like category theory. The very fact that there's no one function doing what you want in Haskell's library indicates to me that the name (if there is one) can't be that standard. $\endgroup$ – Radu GRIGore Dec 24 '14 at 8:29
  • 1
    $\begingroup$ "stutter" seems like a natural name, google "stutter string function" for examples. $\endgroup$ – Marcus Ritt Dec 26 '14 at 10:18
  • 2
    $\begingroup$ This indeed seems to be the right term, and it is mentioned in multiple academic papers, including this '99 STACS review paper by Thomas Rilke. Could you turn your comment into an answer, so I can accept it (and it becomes properly indexed)? $\endgroup$ – Yann Ponty Dec 29 '14 at 2:44
3
$\begingroup$

As pointed out by Marcus Ritt, the correct name for this operation seems to be stutter.

As far as I could determine, it has mostly been used in the field of concurrency theory, where I could trace it back at least to Lamport's 1983 seminal paper on temporal logic.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.