protelis.coord.nonselfstabilizing.accumulation.pt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of protelis-lang Show documentation
Show all versions of protelis-lang Show documentation
Essential libraries for the Protelis language
module protelis:coord:nonselfstabilizing:accumulation
import protelis:coord:spreading
import protelis:coord:accumulation
/**
* Gossip a value manipulated according to f.
*
* @param value T, what to gossip
* @param f (T, T) -> T, how to manipulate value
* @return T the value resulting from gossip
*/
public def gossip(value, f) {
share (v <- value) {
f(value, hood(f, value, v))
}
}
/**
* Gossip whether the device has ever experienced a given condition.
*
* @param a bool, condition
* @return bool, true if the device has experienced the condition, false otherwise
*/
public def gossipEver(a) {
share (ever <- false) {
a || anyHood(ever)
}
}