For – Create loops

The for command iterates over all elements in the set or array or deque, or all key-value pairs in the map or array or deque. It executes for each element / key-value pair the nested graph rewrite sequence. It completes successfully if all sequences were executed successfully. The key in the key-value pair iteration of an array or deque is the integer typed index.

Example code:

1  rule myRule(productNode:Product){                
2     productNode -edge1:Contains->part:Part;
3     productNode -edge2:Contains->part;
4     modify{
5        delete(edge2);
6   }
7  }
1 sequence sequence1{                //Call a sequence
3   for { node:Product in nodes(Product); //Loop through all nodes of type Product in the nodes of product
4       { myRule(node); } //and execute the rule to the node
5    }
6 }

Parts of this code example can be found in the Soley Studio Tutorial.


Was this article helpful?

Related Articles