Confusion

Confusion is a registries-based language created by Alessandro Morina. The structure of code is pretty similar to a c-like language, but as an esoteric programming language should be, there are some rules that can confuse you.

History
The language was born in April 2016, due to a challenge among my classmates.

Overview
The structure of the code has been designed in the following way so the programmers may create various and complete programs, but not as easily as with a true programming language.

Accessing to the registries
Registries are where the values are stored. They are all double type and there are 1000000 (a million) registries avaiable. To access a registry you have to refer at it's F(index). F(index) {    if(isEven(index)) return index * 2; else return index * 3; } So if you want to access the registry[1] you have to use the index 3 = F(1).

Before writing the real code, an explanation is needed to show how values works.

How values works
(There are only double type value in Confusion) That is pretty simple, there is another function to apply when you want to assign a direct value; you have to add to the value it's half. value = value / 2 * 3; or value = value + value / 2;

Assign values to registries
There are many ways to assign values to a registry:
 * Direct value;
 * Copy from another registry;
 * Numeric or Char input;

Direct value to registry
4 = (150); That assigns the value 100 to the registry 2.

Registry to registry
4 = 9; That assigns the value stored in the registry 3 in to the registry 2.

Assign on cascade
->(R, V1, V2, ..., Vn); It is very simple: it starts to assign from the register R (registry[x] where x -> F(x) = R) the value V1 (remember how values works!) and then registry[x+1] = V2 and so on.

Direct value and registry to pointed registry
4 = (150); 0 = (1.5); [4] = 0; The first and the second lines are known, the last one needs an explanation: as you know, stored in the registry 2, there is 100, so [4] = 0 -> 100 = 0, and so what is x where F(x) = 100? F(x) = 100 -> x = 50. Obviusly you could have wrote: 4 = (150); [4] = (1.5); To achive the same result -> registry[50] is equal to 1. (0 is the only value that is not affected at all by registry access function and values assign function).

You can not use a pointed registry to assign a value: 0 = [4];  //you can't do that!

Operator
It is possible to use the 5 most known operators (+, -, *, /, %), in that way: op(R, A, B); Where R, A and B are registries (obviusly you have to apply the registry access function to each of them) and R is where the value that pops up from the operation between A and B will be stored. But things are not as they seem... Because:

Comparison operator
It is practically identical to the Operator way: compop(R, A, B); But in R there will be stored 1 if the condition applied is true, 0 otherwise. And again, things are not what they seem:

If statement
Looks like that: ?(R); // code here... ?; Between parenthesis there is a registry, and the only thing you need to know is how the condition works: it is false when the value in R is 0 and the value after 10 registry is equal to x where F(x) = R. Example: R = 4
 * is false when registry[2] == 0 && registry[12] == 2;
 * true otherwise

Cycle
The only cycle existing in Confusion is a pre-conditional while. :>(4)    // code here... <; It cycles until the condition is false, and works exaclty the same as the If statement condition.

Input and Output
The input values are not affected by the value assign function. i(R); It is used to input a char into R; n(R); It is used to input a number into R; o(R); It is used to output a char from R; on(R); It is used to output a number from R;

End of program
dne_eht; It is used to terminate the execution.

Hello World!
->(0, 108, 151.5, 162, 166.5); ->(8, 130.5, 171, 150, 48); o(0); o(3); o(4); o(4); o(9); o(21); o(8); o(9); o(15); o(4); o(12); 16=(49.5); o(16); It outputs "Hello World!".

CAT
i(0); o(0); Outputs the char corresponding to the button you pressed.

Simple cycle
0=(1.5); 3=(1.5); :>(3)  on(0); *(0, 0, 3); <; Outputs numbers from 0 to infinity.

Simple sum
0=(3); 3=(7.5); *(9, 0, 3); on(9); Outputs 7.0;

Truth-machine
n(0); 3=(0); 4=(1.5); 39=(4.5); <=(9, 0, 3); ?(9)  on(0); dne_eht; ?; <=(9, 0, 4); ?(9)  :>(4)     on(0); <; ?;

Factorial
n(3); 33=(1.5); 0=(1.5); :>(3)  -(0, 0, 3);   /(3, 33, 3); <; on(0);

The first problem of Project Euler
24=(1498.5); 33=(1.5); 44=(18); 3=(4.5); 4=(7.5); 9=(0); 200=(0); 20=(0); :>(24)  +(0, 24, 3);   <=(0, 0, 9);   ?(0)     *(200, 200, 24);     0=4;   ?;   <(0, 0, 4);   ?(0)     +(0, 24, 4);     <=(0, 0, 9);     ?(0)       *(200, 200, 24);     ?;   ?;   /(24, 33, 24); <; on(200);

Implementations
DOWNLOAD -  Confusion IDE (Windows only)