How to create an indexed, easily iterable, int Colset?
I need to pass ints by index to a transition function, and I'm thinking about something with an index such as
colset PH = index ph with 1..n
How to create an indexed, easily iterable, int Colset?
I need to pass ints by index to a transition function, and I'm thinking about something with an index such as
colset PH = index ph with 1..n
You have an example of how to use the index with a function in the following manual (Page 8)
Look at the declared Chopsticks
function:
val n = 5;
colset PH = index ph with 1..n;
colset CS = index cs with 1..n;
var p: PH;
fun Chopsticks(ph(i)) =
1`cs(i) ++ 1`cs(if i=n then 1 else i+1);
When you declare an index, you declare an id
such as ph
or cs
. You can pass an index by its integer value using the id
followed by its number, like cs(1)
.
So, if you want to iterate, you can use the integer value assigned to its id.