|
In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and the length changed, or it may be fixed (after creation). A string is generally understood as a data type and is often implemented as an array of bytes (or words) that stores a sequence of elements, typically characters, using some character encoding. A string may also denote more general arrays or other sequence (or list) data types and structures. Depending on programming language and precise data type used, a variable declared to be a string may either cause storage in memory to be statically allocated for a predetermined maximum length or employ dynamic allocation to allow it to hold variable number of elements. When a string appears literally in source code, it is known as a string literal or an anonymous string.〔(【引用サイトリンク】title=Introduction To Java - MFC 158 G )〕 In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set called an alphabet. == Formal theory == Let Σ be a non-empty finite set of symbols (alternatively called characters), called the ''alphabet''. No assumption is made about the nature of the symbols. A string (or word) over Σ is any finite sequence of symbols from Σ. For example, if Σ = , then ''01011'' is a string over Σ. The ''length'' of a string ''s'' is the number of symbols in ''s'' (the length of the sequence) and can be any non-negative integer; it is often denoted as |''s''|. The ''empty string'' is the unique string over Σ of length 0, and is denoted ''ε'' or ''λ''.〔〔 Here: sect.1.1, p.1〕 The set of all strings over Σ of length ''n'' is denoted Σ''n''. For example, if Σ = , then Σ2 = . Note that Σ0 = for any alphabet Σ. The set of all strings over Σ of any length is the Kleene closure of Σ and is denoted Σ *. In terms of Σ''n'', : For example, if Σ = , then Σ * = . Although the set Σ * itself is countably infinite, each element of Σ * is a string of finite length. A set of strings over Σ (i.e. any subset of Σ *) is called a ''formal language'' over Σ. For example, if Σ = , the set of strings with an even number of zeros, , is a formal language over Σ. 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「String (computer science)」の詳細全文を読む スポンサード リンク
|