Embed
Email

Empty_string

Document Sample

Shared by: roy ashbrook
Categories
Tags
Stats
views:
0
posted:
12/29/2011
language:
pages:
2
From Wikipedia, the free encyclopedia Empty string









Empty string

In computer science and formal language theory, the form any operation on it, but an empty string is less

empty string (or null string [1] is the unique string of

string) likely to do so. The empty string is a legitimate string,

length zero. upon which most string operations should work. Some

languages treat some or all of the following in similar

Formal Theory ways, which can lessen the danger: empty strings, null

references, the integer 0, the floating point number 0,

Formally, a string is a finite sequence of symbols such the boolean value false, the ascii character NUL, or other

as letters or digits. The empty string is the extreme case such values.

where the sequence has length zero, so there are no sym- The empty string is usually represented similarly to

bols in the string. There is only one empty string, because other strings. In implementations with string terminat-

two strings are only different if they have different ing character (null-terminated strings or plain text

lengths or a different sequence of symbols. In formal lines), the empty string is indicated by the immediate use

treatments, the empty string is denoted with λ or some- of this terminating character.

times Λ or ε.

The empty string should not be confused with the Examples of Empty Strings

empty language ?, which is a formal language (i.e. a set The empty string is a syntactically valid representation

of strings) that contains no strings, not even the empty of zero in positional notation (in any base), which does

string. not contain leading zeros. Since the empty string does

The empty string has several properties: not have a standard visual representation outside of for-

• . The string length is zero. mal language theory, the number zero is traditionally

• . The empty string is the represented by a single decimal digit 0 instead.

identity element of the concatenation operation Zero-filled memory area, interpreted as a null-termi-

(which forms a free monoid on the alphabet Σ). nated string, is an empty string.

Empty lines of text show the empty string. This can

• . Reversal of the empty string produces

occur from two consecutive EOLs), as often occur in text

the empty string.

files, and this is sometimes used in text processing to sep-

• The empty string precedes any other string under

arate paragraphs, e.g. in MediaWiki.

lexicographical order, because it is the shortest of all

strings.[2]

See also

Use In Programming Lan- • Empty set

• Null-terminated string

guages

In most programming languages, strings are a data type. References

Individual strings are typically stored in consecutive

memory locations. This means that the same string (for [1] Kernighan and Ritchie, C, p. 38

example the empty string) could be stored in two differ- [2] CSE1002 Lecture Notes - Lexicographic

ent places in memory. (Note that even a string of length

zero can require memory to store it, depending on the

format being used.) In this way there could be multiple

empty strings in memory, in contrast with the formal

theory definition, for which there is only one possible

empty string. However, a string comparison function

would indicate that all of these empty strings are equal to

each other.

The empty string is distinct from a null reference

(or null pointer) because a null reference does not point

to any string at all, not even the empty string. A null

reference is likely to cause an error if one tries to per-





1

From Wikipedia, the free encyclopedia Empty string





λ representation Programming languages

"" C, C++, Perl, Python, C#, Go, PHP, Visual Basic .NET, Java, Turing, JavaScript, Haskell, Objective

Caml, Scala, Tcl

’’ Perl, PHP, Python, JavaScript, Delphi, Pascal

{’\0’} C, C++

std::string() C++

@"" Objective-C

qw() Perl

"""""" Python

str()

string.Empty C#

String.Empty Visual Basic .NET

String.make 0 Objective Caml

’-’

{} Tcl









Retrieved from "http://en.wikipedia.org/w/index.php?title=Empty_string&oldid=467963315"



Categories:

• Formal languages

• String (computer science)

• Zero

• Formal methods stubs





This page was last modified on 27 December 2011 at 20:03. Text is available under the Creative Commons Attribution-

ShareAlike License; additional terms may apply. See Terms of use for details. Wikipedia® is a registered trademark of

the Wikimedia Foundation, Inc., a non-profit organization.Contact us

Privacy policy About Wikipedia Disclaimers



2



Related docs
Other docs by roy ashbrook
Philip_Taaffe
Views: 48  |  Downloads: 0
Philip_Dodd__broadcaster_
Views: 36  |  Downloads: 0
Philippa_of_Champagne
Views: 31  |  Downloads: 0
Philadelphians
Views: 26  |  Downloads: 0
Phaansi
Views: 22  |  Downloads: 0
Peykasa
Views: 22  |  Downloads: 0
Pet_door
Views: 41  |  Downloads: 0
Peter_Rice__Chairman_of_Fox_Broadcasting_
Views: 34  |  Downloads: 0
Perittia_farinella
Views: 14  |  Downloads: 0
Perissoza_scripta
Views: 15  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!