(Double.MaxValue, field) ){ dv => mux(src) { (0.0, field) } { minHoodPlus { val (d, v) = nbr { (dv._1, dv._2) } (d + metric, acc(v)) } } }._2 def gradient(source: Boolean): Double = G[Double](source, 0, _ + nbrRange(), nbrRange()) def broadcast[V:OB](source: Boolean, field: V): V = G[V](source, field, x=>x, nbrRange()) def distBetween(source: Boolean, target: Boolean): Double = broadcast(source, gradient(target)) def dilate(region: Boolean, width: Double): Boolean = gradient(region) < width } Regiment The following program in the Regiment language can be used to compute the mean temperature perceived by the whole system: % function definition doSum :: float (float, int) -> (float, int); doSum(temperature, (sum, count)) { (sum+temperature, count+1) } % functional reactive program logic temperatureRegion = rmap(fun(node){ sense("temperature", node) }, world); sumSignal = rfold(doSum, (0.0, 0), temperatureRegion) avgSignal = smap(fun((sum,count)){ sum / count }, sumSignal) BASE <- avgSignal % move such information to the base station PyoT The following program in PyoT can be used to turn on a fan if the mean temperature computed by several sensors exceeds a certain threshold. temperatures = Resource.objects.filter(title="temp") results = [temp.GET() for temp in temperatures] avg = sum(results) / len(results) TEMP_THRESHOLD = 24 if avg > TEMP_THRESHOLD: Resource.objects.get(title="fan").PUT("on") TinyDB In TinyDB, a data-oriented macroprogramming approach is used where the programmer writes a query which turns into single-node operations and routing in a wireless sensor network. SELECT nodeId , temperature WHERE temperature > k FROM sensors SAMPLE PERIOD 5 minutes See also Multitier programming Choreographic programming Aggregate computing Distributed computing References Programming paradigms Programming languages Distributed computing Articles with example Python (programming language) code Articles with example Scala code