Union(/ˈʌnjən/) is a unique concentrative language that is based on queues, not stacks or deques(which can simulate stacks) invented by User:A. It is mainly influenced by the union find algorithm(which involves trees). The restriction on queues have increased its difficulty of programming. It is hard to evaluate an expression that does what the user wants. It was presumably the first esoteric programming language that is based on trees.
Commands (just like any other concentrative language)
front: Push the front of the queue to the back of the queue x or y: This pushes x or y onto the queue depending on what is specified. x y union: Pop 2 values from the queue, and add x as y's father in a tree. x find: Find the father of x and push that value onto the queue x y setfather: Clear all of x fathers and set y as x father in a tree. x swap: Swap x with x's father inside a tree. x if y end: Pop x from the queue. If x is nonzero, execute y inside an if statement(where y is a list of instructions) x loop y end: Pop x. If x is nonzero, execute y inside a while loop(where y is a list of instructions) until the front item becomes 0. (Of course, after y is executed) x y equal: Push 1 onto the queue is x and y are equal; otherwise, push 0. add, sub, mul, div: Do the corresponding mathematical operations.
3 2 div 1 front sub
Exchange two values inside a tree (make sure you know the values )
Swap 1 and 2 under a same father.
1 swap 2 swap 1 swap
1 loop 1 end
1 4 setfather 1 loop if end 4 find 1 add 4 setfather 1 end
Hello, world! program doing no output
This creates numbers and makes them fathers of themselves (which is similar to outputting them). However, trees cannot repeat, so this does not print the right string...
72 72 union 101 101 union 108 108 union 111 111 union 44 44 union 32 32 union 87 87 union 114 114 union 100 100 union 33 33 union 10 10 union
Union find algorithm
This puts the result into the father of 9999.
The first line is input; the second line is the process.
1 2 union 1 3 union 2 4 union 5 4 union 1 loop 5 find setfather 9999 5 find 5 equal 0 1 sub mul 1 add end
Its computational class is still in question, due to the special syntax.