Yield – Write RHS values to LHS variables/ Apply filters

General

A yield assignment writes the rhs variable value to the lhs variable. Yielding is only possible from compiled sequences, it always succeeds. Further on, the attributes of graph elements may be written to, the values at given positions of array or deque or map variables may be written to, and the visited status of graph elements may be changed.

Example code:

1 rule incidency
2 {
3   n:N;
4   def var i:int;
5   yield { yield i = incident(n).size(); }
6
7   modify{
8    eval { n.j = i; }
9       }
10 }
11
12 filter filterMultiply<incidency>(var f:int)
13 {
14 for(m:match<incidency> in this)
15 {
16 m.i = m.i * f;
17 }
18 }

How to use it:

More Examples can be found in these Packages:

Was this article helpful?

Related Articles