A variable-length color set. The values are a sequence whose color set must be the same type.

## Declaration syntax

colsetname =listname0 [withint-exp1..int-exp2];

### Order

lexicographic (with respect to ordering of base color set)

### Values

[v1, v2, …, vn]

where `vi`

has type `name0`

for i=1..n.

### Optional `with`

clause

The

clause specifies the minimum and maximum length of the lists.**with**

## Declaration examples

colset INTlist = list INT;

colset ShortBoolList = list Bool with 2..4;

var shortBoolList : ShortBoolList;

If `Bool`

has been declared as a Boolean color set, then the CPN variable `shortBoolList`

must be a list with length >=2 and <=4, and all values in the list must be either `true`

or `false`

. For example, `[true,false]`

and `[false,true,false]`

are legal values, but `[true]`

and `[true,false,true,true,false]`

are not.

## Operations

See also color set functions.

### List functions from Standard ML

: empty list (same as**nil**`[]`

)`e`

: prepend element e as head of list**::**l`l`

‘: head, the first element of the list**hd**l`l`

: tail, list with exception of first element**tl**l

: length of list**length**l`l`

: reverse list**rev**l`l`

: use function**map**f l`f`

on each element in list`l`

and returns a list with all the results

: use function**app**f l`f`

on each element in list`l`

and returns`()`

: returns**foldr**f z l`f(e1, f(e2, ...,f(en, z) ...))`

where`l = [e1, e2,..., en]`

: returns**foldl**f z l`f(en, ...,f(e2,f(e1, z)) ...)`

where`l = [e1, e2,..., en]`

:**List.nth**(l,n)`n`

th element in list`l`

, where 0 <=`n`

<`length l`

: returns first**List.take**(l,n)`n`

elements of list`l`

: returns what is left after dropping first**List.drop**(l,n)`n`

elements of list`l`

: returns**List.exists**p`true`

if`p`

is true for some element in list`l`

: returns**List.null**l`true`

if list`l`

is empty

For additional details and functions see the LIST structure in the SML Basis Library Manual.

### Additional list functions

`l1`

: concatenate the two lists**^^**l2`l1`

and`l2`

: returns**mem**l x`true`

if element`x`

is in the list`l`

: removes duplicates from list**remdupl**l`l`

: removes the first appearance (if any) of element**rm**x l`x`

from list`l`

: removes all appearances (if any) of element**rmall**x l`x`

from list`l`

: returns**contains**l1 l2`true`

if all elements in list`l2`

are elements in list`l1`

, ignoring the multiplicity of elements in`l2`

: similar to**contains_all**l1 l2`contains`

but does not ignore multiplicity of elements in`l2`

: returns the intersection of lists**intersect**l1 l2`l1`

and`l2`

: returns the union, i.e. the concatenation, of lists**union**l1 l2`l1`

and`l2`

: inserts element**ins**l x`x`

at the end of list`l`

: if**ins_new**l x`x`

is not a member of list`l`

, then`x`

is inserted at the end of`l`

, otherwise`l`

is returned

: sorts list**sort**lt_fun l`l`

using the function`lt_fun`

to determine when one element in the list is less than another. Note that all color sets have a less-than function`cs.lt`

(see color set functions).

: removes all elements in list**listsub**l1 l2`l2`

from list`l1`

. Raises`Subtract`

if there is an element in`l2`

that is not in`l1`

.

See also Implementation of list functions for examples of how to use some of the the list functions, as well as to see how some of the functions are defined in Standard ML.

You must be logged in to post a comment.