Anyfix notation

From Esolang
Jump to: navigation, search

Anyfix notation is a powerful mix of prefix, infix, and postfix notation that requires a well-implemented evaluator. There is a memory stack or queue and an operator queue. When a literal value is encountered, it is pushed onto the memory stack or queue. When an operator is encountered, two things can happen. If there are enough values in memory for the operator, then the operator is applied. Otherwise, the operator is stored in the queue. When new values are pushed into the memory, all operators are checked and if any of them can be applied, then the first one that can be applied is applied, and this updates again.


All of these will add `1` and `2`:

 + 1 2
 1 + 2
 1 2 +

The following code (where `@` is some unary/monadic operator) evaluates to `+(@(1), 2)`:

 + @ 1 2