Description
The @x:Act string type is based on the Java String type and holds sequences of 16-bit characters. Unlike Java that uses reference semantics for string == equality, in @x:Act == string equality is always value equality that compares the characters in the string.
String iterators include Chars[s] and Lines[s].
Views of string include boolean, fold, date, and file.
Examples of how to use the date view can be found in the string example.
Type string
@x:type string
@x:type |
@x:func sys:Cat(a, |
@x:type |
@x:func sys:Eq(a~string, |
@x:type |
@x:func sys:Ne(a~string, |
@x:type |
@x:func sys:Less(a~string, |
@x:type |
@x:func sys:LessEq(a~string, |
@x:type |
@x:func sys:Greater(a~string, |
@x:type |
@x:func sys:GreaterEq(a~string, |
@x:self | @x:func sys:Init(a)~void |
@x:self | @x:func sys:Subscript(index) |
@x:self | @x:const size~int |
Type Function sys:Cat
@x:func sys:Cat(a, |
||||
|
Semantics
The result is the string concatenation of string(a) and string(b).Type Function sys:Eq
@x:func sys:Eq(a~string, |
||||
|
Semantics
If a and b have the same size and same characters, then the result is true, else the result is false.Type Function sys:Ne
@x:func sys:Ne(a~string, |
||||
|
Semantics
If a and b have the same size and same characters, then the result is false, else the result is true.Type Function sys:Less
@x:func sys:Less(a~string, |
||||
|
Semantics
If a is less than b, then the result is true, else the result is false.Type Function sys:LessEq
@x:func sys:LessEq(a~string, |
||||
|
Semantics
If a is less than or equal to b, then the result is true, else the result is false.Type Function sys:Greater
@x:func sys:Greater(a~string, |
||||
|
Semantics
If a is greater than b, then the result is true, else the result is false.Type Function sys:GreaterEq
@x:func sys:GreaterEq(a~string, |
||||
|
Semantics
If a is greater than or equal to b, then the result is true, else the result is false.Self Function sys:Init
@x:func sys:Init(a)~void | ||
|
Semantics
There are two forms of string constructor: a special single character constructor and a general purpose string constructor.
For the special single character constructor, a should have the form code=nnn where nnn is an integer value in the range 0 to 65535. The result will be a string with a single character whose internal code was given by n.
All other cases are general purpose string constructors.
If a?string then the object is initialized to
a
otherwise the object is initialized to
Type[a].toString()
Self Function sys:Subscript
@x:func sys:Subscript(index) | ||
|
Semantics
There are two kinds of string subscript: character subscript and substring.
For a character subscript of a string s, index should be an integer in the range 0 to s.size. The result will be the integer character code for the index'th character. The value will be in the range 0..65535.
For a substring of a string s, index should have the form i..j where i and j have type int. If i == j + 1 the result is the empty string (""). Otherwise we require 1 <= i & i <= j & j <= s.size. In this case the result will be the substring of s containing character in positions i through j inclusive.
Self Const size
@x:const size~int |
Semantics
The number of character in the string.