Segreq

From Esolang
Jump to navigation Jump to search

Segreq (SEcond GRade EQuation) is a language created in 2020 by User:Hanzlu.

The language operates on a row of cells and a stack. The commands in the language are second grade polynomials.

Interpreter exists in Python here [1].

Commands are written as second grade polynomials of the form ax^2+bx+c where a, b and c are numbers and + characters can be either + or -. Second grade polynomials represent a number which is the solutions of ax^2+bx+c = 0 added together. For example the solutions of the equation 1x^2+0x-1 = 0 are x=-1 and x=1. Thus, if 1x^2+0x-1 is used as a command it will represent the number (-1+1=0) 0. Notice that even if b = 0 in the latest polynomial it must be written out. Each polynomial's last character is a comma (,) to separate them, even the last polynomial has a comma.

In order to have arguments for operations, the a value in a polynomial ax^2+bx+c is used as argument. For example, when a cell is set to be equal to a number, a will be the number the cell becomes equal to. Whenever the top value of the stack is used it is popped from the stack. If statement cannot be nested and there are no else statements.

In order to limit the use of the same polynomial over and over again, certain commands are represented by different numbers (polynomials) at different hours. Code written between 7 and 8 AM will not work the same between 1 and 2 PM. The current hour is in fact used as a seed to randomize 20 numbers, since there are 20 valid operations in Segreq. For example, the random numbers when he clock is between 14:00 - 14:59 are: (-19, 18, -14, -18, -13, -9, 4, -10, 11, 3, -8, -11, 5, 14, -17, 8, -7, -5, 15, -12). The command output a character is always represented by the second number in that list, so when the hour is 14, the output command happens to be represented by the number 18. So, in order to output a character when the hour is 14, the polynomials solutions must add up to 18.

Here is a list of the command in their order from 1-20:

Command Explanation
1 Sets the cell equal to a.
2 Outputs the cell as an ASCII character.
3 Moves the pointer to the left.
4 Moves the pointer to the right.
5 Pushes the value in the cell onto the stack.
6 Pops the top value of the stack into the cell.
7 Lets the user input a number into the cell.
8 Cell is increased by the top value of the stack.
9 Cell is decreased by the top value of the stack.
10 Cell is multiplied by the top value of the stack.
11 Cell is divided and floored by the top value of the stack.
12 Cell is modulus by the top value of the stack.
13 Cell is raised to the power of the top value of the stack.
14 If cell is not equal to the value of the top stack, the code reader jumps to the next ;
15 If cell is larger than the value of the top stack, the code reader jumps to the next ;
16 If cell is less than the value of the top stack, the code reader jump to the next ;
17 Pointer is moved to cell <a> (a as argument).
18 Jumps to polynomial number <a> (a as argument).
19 Cell is set equal to a random number between 0 and <a> (a as argument)
20 Program is halted.

CAT

1x^2-4x+0, 1x^2-18x+0, 1x^2+5x+0,