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 list l
  • hd l‘: head, the first element of the list l
  • tl l: tail, list with exception of first element
  • length l: length of list l
  • rev l: reverse list l
  • map f l: use function f on each element in list l and returns a list with all the results
  • app f l: use function f on each element in list l and returns ()
  • foldr f z l: returns f(e1, f(e2, ...,f(en, z) ...)) where l = [e1, e2,..., en]
  • foldl f z l: returns f(en, ...,f(e2,f(e1, z)) ...) where l = [e1, e2,..., en]
  • List.nth(l,n): nth element in list l, where 0 <= n < length l
  • List.take(l,n): returns first n elements of list l
  • List.drop(l,n): returns what is left after dropping first n elements of list l
  • List.exists p : returns true if p is true for some element in list l
  • List.null l: returns 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^^l2: concatenate the two lists l1 and l2
  • mem l x: returns true if element x is in the list l
  • remdupl l: removes duplicates from list l
  • rm x l: removes the first appearance (if any) of element x from list l
  • rmall x l: removes all appearances (if any) of element x from list l
  • contains l1 l2: returns true if all elements in list l2 are elements in list l1, ignoring the multiplicity of elements in l2
  • contains_all l1 l2: similar to contains but does not ignore multiplicity of elements in l2
  • intersect l1 l2: returns the intersection of lists l1 and l2
  • union l1 l2: returns the union, i.e. the concatenation, of lists l1 and l2
  • ins l x: inserts element x at the end of list l
  • ins_new l x: if x is not a member of list l, then x is inserted at the end of l, otherwise l is returned
  • sort lt_fun l: sorts list 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).
  • listsub l1 l2: removes all elements in list 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.

 

Size and complexity of color sets
Large Integer color sets

You must be logged in to post a comment.