String (computer science): Difference between revisions

Content deleted Content added
String length: keep prev. version: stop char needn't be 0x00, link to subsection here
Tag: Reverted
Line 267:
 
=== Concatenation and substrings ===
''[[Concatenation]]'' is an important [[binary operation]] on Σ<sup>*</sup>. For any two strings ''s'' and ''t'' in Σ<sup>*</sup>, their concatenation is defined as the sequence of symbols in ''s'' followed by the sequence of characters in ''t'', and is denoted ''st''. For example, if Σ = {a, b, ..., z}, ''s''&nbsp;=&nbsp;{{code|bearfoot}}, and ''t''&nbsp;=&nbsp;{{code|hugball}}, then ''st''&nbsp;=&nbsp;{{code|bearhugfootball}} and ''ts''&nbsp;=&nbsp;{{code|hugbearballfoot}}.
 
String concatenation is an [[associative]], but non-[[commutative]] operation. The empty string ε serves as the [[identity element]]; for any string ''s'', ε''s'' = ''s''ε = ''s''. Therefore, the set Σ<sup>*</sup> and the concatenation operation form a [[monoid]], the [[free monoid]] generated by Σ. In addition, the length function defines a [[monoid homomorphism]] from Σ<sup>*</sup> to the non-negative integers (that is, a function <math>L: \Sigma^{*} \mapsto \mathbb{N} \cup \{0\}</math>, such that <math>L(st)=L(s)+L(t)\quad \forall s,t\in\Sigma^*</math>).