Klaus/Dense
Klaus/Dense is an esoteric programming language made by User:A, and is very similar with Klaus. It is created in order to allow creating very tiny and obfuscated programs. It was designed to compile to Klaus and has a very similar syntax. (It is unclear whether it can participate in real golfing contests, but it seems to be highly capable for it.)
Instructions
Instruction | Function |
---|---|
O | Outputs value |
I | Inputs value |
L | Loads value into register |
Specifics
Klaus/Dense programs are in the form of "tracks". A track is a subroutine consisting of 2 or less instructions. There can be many of them in one program. They are called tracks since they will be repeated indefinitely unless given a conditional return value. The ;
is used to separate statements on the same line, in order to eliminate the need for spaces. Spaces are allowed. A track has this syntax:
TrackName:Statements;Condition;BoolRINT.
Where the TrackName is the name of the track, statements are the statements used in this track, condition is the condition that the track will return an integer value. Bool can be either true or false, R: means "return". In this track, R: is used to return an INTeger value. The exclamation point ends the track. Take this as an example:
track1:Lq20;Oq;`=q20;1:R0.
We can break this down into parts.
track1
is the name of our track. It does not include anything in order to separate it from the track itself, and to improve obfuscation. A track name must always precede a track, or it will return an error.
Lq20;
is our use of the L command. It loads the integer value 20, into the register, "q". The L instruction has this syntax:
LRegisternameValue;
Where Registername is the name of our register (registers can be either one letter A-Z or a-z, nothing else), and value is the interpreter value placed in the register.
Oq;
is our use of the "O" instruction. This is where we print the value held in register "q". The instruction is followed by an exclamation mark.
`=q20;
is our use of the if statement. This is initialized by a `
symbol (if statements contained in other if statements are initialized by the ?
symbol). The condition is ended by an exclamation mark.
1:R0.
is the body of the if statement. It's initialized by the boolean, 1, which means true. On the other hand, the boolean, 0, means false, and is the equivalent to the else statement in other languages. This boolean is ended by a register name, which initializes the rest of the body. R, as said before, means return, and it returns the integer value 0. The entire track is ended with an exclamation point. This program prints the integer, 20.
Loops
Loops in this language are simple. Here is the syntax for a while loop.
~condition:statements,statements;
The Tilde initializes the loop, and is followed by a condition to check for. The statements are executed while the condition is true, and halted, when false. Here is the syntax of a for loop.
#varCondition,action,statements,statements;
Where var, is a value stored in a register temporarily (temporarily, since the register will be cleared once the loop is done. Followed by the condition to check for, and the action to take if true. This action can be the incrementation of the variable or its decrementation. Here is an example of a while and for loop
WhileLoop:La1;~↔a,1,Oa,a^;`=a2;1:R1. ForLoop:#Lb0<b,3,b^,Ob,b^;`=b3;1:R0.
The while loop should output 1, while the for loop should output 0,1, and 2. These examples feature some keywords and actions not covered before. These are the "less" key word and the incrementation and decrement signs. The less keyword checks if the first argument is less than the second. Similarly, the more keyword checks if the first argument is more than the second. The increment and decrement sign, "^" and "&", raises or lowers the value by 1. It must always be used next to a variable, and must be ended by a command terminator.
Character representation
Characters can be represented by the '
literal following the character constant. The '
literal can not match.
Hello World Program
HelloWorld:Lh2;O'H;O'e;O'l;O'l;O'o;O',;O' ;O'w;O'o;O'r;O'l;O'd;O'!;`=h,2;1:R69.
Computational Class
This language is a Bounded-storage machine, as it has limited memory due to its limited amount of registers to store values in.