language-icon Old Web
English
Sign In

Concatenation

In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of 'snow' and 'ball' is 'snowball'. In some but not all formalisations of concatenation theory, also called string theory, string concatenation is a primitive notion. In formal language theory and computer programming, string concatenation is the operation of joining character strings end-to-end. For example, the concatenation of 'snow' and 'ball' is 'snowball'. In some but not all formalisations of concatenation theory, also called string theory, string concatenation is a primitive notion. In many programming languages, string concatenation is a binary infix operator. The + (plus) operator is often overloaded to denote concatenation for string arguments: 'Hello, ' + 'World' has the value 'Hello, World'. In other languages there is a separate operator, particularly to specify implicit type conversion to string, as opposed to more complicated behavior for generic plus. Examples include . in Edinburgh IMP, Perl, and PHP, .. in Lua, and & in Ada, AppleScript, and Visual Basic. Other syntax exists, like || in PL/I and Oracle Database SQL. In a few languages, notably C, C++, and Python, there is string literal concatenation, meaning that adjacent string literals are concatenated, without any operator: 'Hello, ' 'World' has the value 'Hello, World'. In other languages, concatenation of string literals with an operator is evaluated at compile time, via constant folding, although this is often an implementation detail of the compiler, rather than a language feature. In programming, string concatenation generally occurs at run time, as string values are not in general known until run time. However, in the case of string literals, the values are known at compile time, and thus string concatenation can be done at compile time, either via string literal concatenation or via constant folding. In formal language theory and pattern matching (including regular expressions), the concatenation operation on strings is generalised to an operation on sets of strings as follows: For two sets of strings S1 and S2, the concatenation S1S2 consists of all strings of the form vw where v is a string from S1 and w is a string from S2, or formally S1S2 = { vw : v ∈ S1, w ∈ S2 }. Many authors also use concatenation of a string set and a single string, and vice versa, which are defined similarly by S1w = { vw : v ∈ S1 } and vS2 = { vw : w ∈ S2 }. In these definitions, the string vw is the ordinary concatenation of strings v and w as defined in the introductory section. For example, if F = { a, b, c, d, e, f, g, h }, and R = { 1, 2, 3, 4, 5, 6, 7, 8 }, then FR denotes the set of all chess board coordinates in algebraic notation, while eR denotes the set of all coordinates of the kings' file. In this context, sets of strings are often referred to as formal languages. The concatenation operator is usually expressed as simple juxtaposition (as with multiplication). The strings over an alphabet, with the concatenation operation, form an associative algebraic structure with identity element the null string—a free monoid.

[ "Algebra", "Artificial intelligence", "Programming language", "Utility model", "Diphone", "Link Capacity Adjustment Scheme", "Concatenated DNA", "Concatenative synthesis" ]
Parent Topic
Child Topic
    No Parent Topic