W Wrapl, The Programming Language

Libraries Std.String

Types

T

The type of all strings.

Constants

Empty : T

Empty string "".

Lower : T

String consisting of lower case letters.

Nil : T

String corresponding to the address 0. Needed for bindings to external libraries.

Upper : T

String consisting of upper case letters.

Functions

Add(a @ T, b @ T) : T

Returns the concatenation of a and b.

Chr(byte @ Std.Integer.SmallT) : T

Returns a string str of length 1 with Ord(str) = byte.

Compare(a @ T, b @ T) : Std.Object.T

Returns Std.Object.Less, Std.Object.Equal or Std.Object.Greater depending on whether a is lexically less than, equal to or greater than b.

Create(value1,...,valuek) : T

returns the concatenation of value1, ... , valuek after converting them (if necessary) to strings.

FromAddress(address @ Std.Address.T, length @ Std.Integer.SmallT) : T

Returns a string consisting of the length bytes at address.

The memory at address is not copied and should not be modified after this call.

GetBlockAddress(t @ T, n @ Std.Integer.SmallT) : Std.Address.T

Returns the address of the bytes of blockn of t, where block0 is the first block.

Fails if n is larger or equal than the number of blocks in t.

GetBlockLength(t @ T, n @ Std.Integer.SmallT) : Std.Integer.SmallT

Returns the length of the bytes of blockn of t, where block0 is the first block.

Fails if n is larger or equal than the number of blocks in t.

GetBlocks(t @ T, addr @ ANY, len @ ANY)

For each block in t, stores the address and length of the block into addr and len respectively and generates NIL.

Hash(t @ T) : Std.Integer.SmallT

Returns a hash code for t.

Ord(str @ T) : Std.Integer.SmallT

Returns the first byte of str as an integer.

Methods

:">"(_ @ T, _ @ T)

:">="(_ @ T, _ @ T)

:"<"(_ @ T, _ @ T)

:"<="(_ @ T, _ @ T)

:"*"(_ @ Std.Integer.SmallT, _ @ T)

:"*"(_ @ T, _ @ Std.Integer.SmallT)

:"="(_ @ T, _ @ T)

:"@"(_ @ T, _ = Std.Number.T)

:"[]"(_ @ T, _ @ Std.Integer.SmallT, _ @ Std.Integer.SmallT)

:"[]"(_ @ T, _ @ Std.Integer.SmallT)

:_count(_ @ T)

:_flatten(_ @ T)

:after(a @ T, b @ T) : :T

Returns the substring of a after the first occurance of a character in b. Returns all of a if no character in b occurrs in a.

:any(str @ T, chars @ T, m @ Std.Integer.SmallT) : Std.Integer.SmallT

Generates all positions after m in str with a character in chars.

:any(str @ T, chars @ T) : Std.Integer.SmallT

Generates all positions in str with a character in chars.

:before(a @ T, b @ T) : T

Returns the largest initial substring of a that does not contain any characters in b.

:begins(a @ T, b @ T) : T

Returns a if it begins with b, fails otherwise.

:centre(_ @ T, _ @ Std.Integer.SmallT, _ @ T)

:centre(_ @ T, _ @ Std.Integer.SmallT)

:chars(str @ T) : T

Generates the characters in str as strings of length 1.

:chr(_ @ Std.Integer.SmallT)

:ends(a @ T, b @ T) : T

Returns a if it ends with b, fails otherwise.

:find(a @ T, b @ T, m @ Std.Integer.SmallT, n @ Std.Integer.SmallT) : Std.Integer.SmallT

Generate each position between m and n where b occurs in a.

:find(a @ T, b @ T, m @ Std.Integer.SmallT) : Std.Integer.SmallT

Generate each position after m where b occurs in a.

:find(a @ T, b @ T) : Std.Integer.T

Generate each position where b occurs in a.

:gets(_ @ Std.Address.T)

:in(a @ T, b @ T) : T

Returns a if it is a substring of b, fails otherwise.

:left(_ @ T, _ @ Std.Integer.SmallT, _ @ T)

:left(_ @ T, _ @ Std.Integer.SmallT)

:length(string @ T)

Returns the length of string

:lower(str @ T) : T

Equivalent to str:map(Upper, Lower).

:map(string @ T, from @ Agg.List.T, to @ Agg.List.T) : T

Returns a copy of string with each occurance of a string in from with the corresponding string in to.

The strings in from are tried in the order they occur in from.

:map(str @ T, old @ T, new @ T) : T

Returns a copy of str with each character in old replaced with the corresponding character in new.

:new(_ = T)

:ord(_ @ T)

:reverse(s @ T) : Std.String.T

returns the a string consisting of the same bytes as s in reverse order.

:skip(str @ T, chars @ T, m @ Std.Integer.SmallT) : Std.Integer.SmallT

Generates all positions after m in str with a character not in chars.

:skip(str @ T, chars @ T) : Std.Integer.SmallT

Generates all positions in str with a character not in chars.

:split(str @ T, sep @ T) : T

Generates substrings of str separated by characters in sep.

:upper(str @ T) : T

Equivalent to str:map(Lower, Upper).

:"~="(_ @ T, _ @ T)