|
Subset or tuple membership |
Top Previous Next |
|
One may wish to do conditional processing dependent upon whether a set element is defined in a particular subset or tuple. The form of the syntax that can be employed in the subset case is
Action$subset(setelement) or If(subset("quotedsetelement"), Action); or While(subset("quotedsetelement"), Action);
or in the tuple case is
Action$tuplename(setelement, set2element) or If(tuplename(setelement, set2element), Action); or While(tuplename(setelement, set2element), Action);
where in both setelement is a set name which must be controlled within the action or earlier in a Loop statement and quotedsetelement is a particular set element name encased in quotes. Examples: ciZ=sum((allcity,cityj) $cityi(allcity),1); ciZ$cityi("boston")=sum(allcity,1); loop((allcity,cityj) $ tuple(allcity,cityj), ciz=ciz+ord(allcity)+ord(cityj)*100); if(cityj("boston"),ciz=1); if(tuple("orlando","boston"),ciz=1); |