A variable-length color set. The values are a sequence whose color set must be the same type.
Declaration syntax
colset name = list name0 [with int-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 with clause specifies the minimum and maximum length of the lists.
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
nil: empty list (same as[])e::l: prepend element e as head of listlhd l‘: head, the first element of the listltl l: tail, list with exception of first elementlength l: length of listlrev l: reverse listlmap f l: use functionfon each element in listland returns a list with all the resultsapp f l: use functionfon each element in listland returns()foldr f z l: returnsf(e1, f(e2, ...,f(en, z) ...))wherel = [e1, e2,..., en]foldl f z l: returnsf(en, ...,f(e2,f(e1, z)) ...)wherel = [e1, e2,..., en]List.nth(l,n):nth element in listl, where 0 <=n<length lList.take(l,n): returns firstnelements of listlList.drop(l,n): returns what is left after dropping firstnelements of listlList.exists p: returnstrueifpis true for some element in listlList.null l: returnstrueif listlis empty
For additional details and functions see the LIST structure in the SML Basis Library Manual.
Additional list functions
l1^^l2: concatenate the two listsl1andl2mem l x: returnstrueif elementxis in the listlremdupl l: removes duplicates from listlrm x l: removes the first appearance (if any) of elementxfrom listlrmall x l: removes all appearances (if any) of elementxfrom listlcontains l1 l2: returnstrueif all elements in listl2are elements in listl1, ignoring the multiplicity of elements inl2contains_all l1 l2: similar tocontainsbut does not ignore multiplicity of elements inl2intersect l1 l2: returns the intersection of listsl1andl2union l1 l2: returns the union, i.e. the concatenation, of listsl1andl2ins l x: inserts elementxat the end of listlins_new l x: ifxis not a member of listl, thenxis inserted at the end ofl, otherwiselis returnedsort lt_fun l: sorts listlusing the functionlt_funto determine when one element in the list is less than another. Note that all color sets have a less-than functioncs.lt(see color set functions).listsub l1 l2: removes all elements in listl2from listl1. RaisesSubtractif there is an element inl2that is not inl1.
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.