ZALIBY
ZÁLIBY is a simple programming language created as part of a programming competition run by students at Charles University. An implementation can be found here
Overview
ZÁLIBY is a stack-based language. The stack can contain an unlimited number of integers in the range 0 to 32767.
Typing a sequence of numbers causes it to be pushed to the stack. To push two separate numbers next to each other, separate them with a space.
Commands
a is the first value popped, b is the second. Commands popping two values always operate on b first, so 2 1 -
is 1
Instruction | Description |
---|---|
+ |
Pops two values, pushes b + a |
- |
Pops two values, pushes b - a |
* |
Pops two values, pushes b * a |
/ |
Pops two values, pushes b / a |
= |
Pops two values, pushes 1 if b = a, otherwise 0 |
< |
Pops two values, pushes 1 if b < a, otherwise 0 |
; |
Pops one value, pushes a twice |
. |
Pops one value, prints (value of) a |
Conditionals
Conditionals take the format ? actions_if_true : actions_if_false !
. When the ?
is reached, if the top of the stack is nonzero the first set of actions will be taken, otherwise the second set. After the relevant actions have run, execution continues from the !
Loops
A while loop takes the format [ test @ actions ]
. First, the "test" will be executed, then, if the top of the stack is nonzero, the "actions" will be executed and the loop will be repeated. If the test results in the top of the stack being zero, execution will continue from the ]
Examples
Print numbers from 10 to 100 in steps of 10:
10 [; 110 < @ ; . 10+]