exchange
This function computes the local value of e_i, substituting variable n with the nvalue w of messages received from neighbours, using the local value of e_i (initial) as a default. The exchange returns the neighbouring or local value v_r from the evaluation of e_r applied to the body. e_s evaluates to a nvalue w_s consisting of local values to be sent to neighbour devices δ′, which will use their corresponding w_s(δ') as soon as they wake up and perform their next execution round.
Often, expressions e_r and e_s coincide, so this function provides a shorthand for exchange(e_i, (n) => (e, e)).
Example
exchange(0){ f ->
f.mapField { _, v -> if (v % 2 == 0) v + 1 else v * 2 }
}The result of the exchange function is a field with as messages a map with key the id of devices across the network and the result of the computation passed as relative local values.