Hexar

From Esolang
Jump to navigation Jump to search

Hexar is an esoteric programming language which uses almost only hexadecimal numbers created by User:Enchant3d in September of 2019.

Language overview

Hexar runs on a tape and uses a cell pointer as in brainfuck, except that the tape is constrained to hexadecimal numbers ranging from 0 to 0x2710. Each hexadecimal number written in the language must be surrounded by parentheses, brackets, braces, or angle signs to represent the number's usage. Other characters are also used as actions. Commands are:

Characters Description
[] Move the pointer to the number between these two characters
() Set the pointed cell to the number between these two characters
{} If the pointed cell is nonzero, jump to the line number between these two characters, where 0 is the first line
<> If the pointed cell is greater than the cell to the left of it, jump to the line number between the two characters, where 0 is the first line
= Output the pointed cell in decimal
, Output the pointed cell in hexadecimal
: Output the pointed cell in Unicode
+ Increment the pointed cell
- Decrement the pointed cell
? Set the pointed cell to a decimal integer inputted from the user
! Set the pointed cell to a random number from 0 to it, inclusive
; Force end a line, useful for comments

Examples

Hello, world!

[0](48);                                       stores 0x48 in cell 0, Unicode 'H'.
[1](65);                                       stores 'e' in cell 1
[2](6C);                                       l
[3](6F);                                       o
[4](2C);                                       ,
[5](20);                                        
[6](77);                                       w
[7](72);                                       r
[8](64);                                       d
[9](21);                                       !
[A](A);                                        \n
[0]:[1]:[2]::[3]:[4]:[5]:[6]:[3]:[7]:[2]:[8]:[9]:[A]:; outputs Hello, world! from stored hexes

Addition

[0]?;        input the the first number in cell 0
[1]?;        input the second number in cell 1
[1]-[0]+[1]; decrement the cell 1 and increment the cell 0 and set the pointer to cell 1
{2};         goes to line 2 until cell 1 is not equal to 0
[0]=;        output cell 0 (sum)

Multiplication

[0]?;                                       //input the first number in cell 0 (factor 1)
[1]?;                                       //input the second number in cell 0 (factor 2)
[1]-[2]+[3]+[1];                            //decrement cell 1, increment cell 2, increment cell 3, set the pointer to cell 1
{2};                                        //goes to line 2 until cell 1 is not equal to 0
[3];                                        //set the pointer to cell 3
-[1]+[3];                                   //decrement cell 3, increment cell 1, set the pointer to cell 3 again
{5};                                        //goes to line 5 until cell 3 is not equal to 0
[0]-;                                       //decrement cell 0
{2};                                        //goes to line 2 until cell 0 is not equal to 0
[2]=;                                       //output cell 2 (product)

Less or more

[64] (6C);                                  //l
[65] (65);                                  //e
[66] (73);                                  //s
[67] (73);                                  //s
[68] (6D);                                  //m
[69] (6F);                                  //o
[6A] (72);                                  //r
[6B] (77);                                  //w
[6C] (69);                                  //i
[6D] (6E);                                  //n
[3] + [1] (14)! ;                           //add 1 to cell 3 select a random number between 0 and 20 to cell 1
[1]-[2]+[4]+[1];                            //decrement cell 1 and put the random number in cell 2 and 4
{B};                                        //goes to line B if cell 1 is not equal 0
[2] {11};                                   //select the pointer at cell 2 and go to line 11 (skip line to say less and more)
[64]:[65]:[66]:[67]:;                       //output "less"
[2] {11};                                   //select the pointer at cell 2 and go to line 11 (skip line to say more)
[68]:[69]:[6A]:[65]:;                       //output "more"
[3]-;                                       //decrement cell 3 (line to reset the input)
{11};                                       //goes to line 11 if cell 3 is not equal to 0
[0]?;                                       //input the number to guess
[0]-[3]+[0];                                //move the input from cell 0 to cell 3
{14};                                       //goes to line 14 if cell 0 is not equal to 0
[3] <E>;                                    //if input is greater than the number to guess, goes to line E
[4] <10>;                                   //if input is smaller than the number to guess, goes to line 10
[6B]:[6C]:[6D]:;                            //output win