String colour sets
CPN ML


Strings are specified by seqences of printable ASCII characters surrounded with double quotes. The string colour set is large unless restricted by the with ... and clause, in which case it is small.

Declaration Syntax

colset name = string [with string-exp1..string-exp2 [and int-exp1..int-exp2]];

Order

lexicographic (with the ASCII ordering)

Optional with Clause

Restricts the character set of string colour sets. The character set is specified by the string expressions string-exp1 and string-exp2.

Each string expression must evaluate to a string of length 1, and it must be the case that string-exp1<=string-exp2.

Optional and Clause

Restricts the length of string colour sets. The minimum and maximum length of the string is specified by the integer expressions int-exp1 and int-exp2. It must be the case that 0<=int-exp1<=int-exp2.

Declaration Examples

colset S = string;

A string colour set is used in the example CP-net Simple Protocol.

colset LowerString = with "a".."z";

var lowerString : LowerString;

The CPN variable lowerString may contain only the lowercase letters a,b,...,z . For example, "ab" and "lowercase" are legal values, but "Lowercase letters" and "ab345" are not.

colset SmallString = with "a".."d" and 3..9

var smallString : SmallString;

The CPN variable smallString may contain only the letters a,b,c and d. Its length must be >=3 and <=9. For example, "abcd" and "bbacdab" are legal values, but "ab" and "bcde" are not.

Operations

s1^s2 concatenate the strings s1 and s2
String.size s number of characters in s
substring (s,i,len) extract a substring of length len starting at position i in s, first position is 0
explode s convert string s to list of chars
implode l convert list l of chars to a string

See also colour set functions.

For additional details and functions see the STRING signature in the SML Basis Library Manual.

All Colour Sets