UNITY is a programming language that was constructed by K. Mani Chandy and Jayadev Misra for their book Parallel Program Design: A Foundation. It is a theoretical language, which tries to focus on what, instead of where, when or how. The language has no flow control, the statements in the program run in a random order, until none of the statements causes change if run. This allows for programs that run indefinitely (auto-pilot or power plant safety system) as well as programs that would normally terminate (which here converge to a fixed point).
Contents
Description
All statements are assignments, and are separated by #
. A statement can consist of multiple assignments, of the form a,b,c := x,y,z
, or a := x || b := y || c := z
. You can also have a quantified statement list, <# x,y : expression :: statement>
, where x and y are chosen randomly among the values that satisfy expression. A quantified assignment is similar. In <|| x,y : expression :: statement >
, statement is executed simultaneously for all pairs of x
and y
that satisfy expression.
Bubble sort
Bubble sort the array by comparing adjacent numbers, and swapping them if they are in the wrong order. Using k
is always chosen randomly from k
manually.
Rank-sort
You can sort in
Floyd–Warshall algorithm
Using the Floyd–Warshall algorithm all pairs shortest path algorithm, we include intermediate nodes iteratively, and get
We can do this even faster. The following programs computes all pairs shortest path in
After round D[i,j]
contains the length of the shortest path from