Addit

From Esolang
Jump to navigation Jump to search
Addit
Paradigm(s) imperative
Designed by Qawtykit
Appeared in 2024
Memory system infinite navigable grid
Dimensions one-dimensional
Computational class Turing complete
Reference implementation Unimplemented
File extension(s) no standard ending

Addit is a language where data is stored in an infinite grid of crumbs (quaternary digits).

Specifications

The crumb grid has two pointers A and B. All crumbs are initialized to 1. The program starts with A selected. Pointer A stars at (0,0) (the center) and pointer B starts at (1,0). The pointers can be at the same position. Oh yeah, the cells wrap too, and whitespace is ignored.

Commands

The cells each pointer is looking at will be referred to as cell A and cell B.

Command Description
> Move the selected pointer right in the crumb grid
< Move the selected pointer left in the crumb grid
^ Move the selected pointer up in the crumb grid
v Move the selected pointer down in the crumb grid
+(arrow) Add cell A and cell B and set the cell at the selected pointer to the result. The following arrow tells the program where to put a second crumb if necessary.
- like the add command, but it's subtraction (cell A - cell B) and there is no argument.
S Switch the selected pointer
`(arrow)(2 to 4) Print the character corresponding to the cell at the selected pointer and the (2 to 4) crumbs in direction (arrow)
label x define label x
go x If the cell at the selected pointer is 1, jump to label x.
(...) Everything within the parentheses is ignored (comment)
I(arrow) Take one character from input and put it's ascii value in direction (arrow) from cell at selected pointer

Examples

Hello World

+> < - >> - <<< `>3 (print H)
> S ^ S +> +> > - > +> <<< `>3 (print e)
>> +> +> > - <<< `>3 `>3 (print ll)
>>>> - << `>2 (print o)
< P>2 (print ,)
> - < `>2 (print space)
- > +> > - <<< `>3 (print W)
> +> > +< +> << `>3 (print o)
> +< > +v > - <<< `>3 (print r)
> - > - > +> +^ <<< `>3 (print l)
>> - - << `>3 (print d)
>> - > +v << `>2 (print !) 

Truth-machine

I< << +> +> go pre_one (take input and checks if it's 1)
- - >> P<2 (print 0)
go terminate (end the program by jumping to label at last line)
label pre_one
- - >> (return cell to original value and go to start of number)
label oneloop
P<2 (print 1)
go oneloop (the go will always run on a 3)
label terminate

Thankfully, both 1 and 0 start with 3 in quaternary.

Computational class

Addit has unbounded memory, conditional looping, and ways of altering data. If the cell under pointer B is set to one, and assuming addition and subtraction store to A, then they are equivalent to incrementation and decrementation assuming the position of A never coincides with B. This can be guaranteed by only using the movement commands for corresponding to a line which does not intersect B, e.g. if up and down correspond to y-movement, and B is at x=1,y=any, and A is at x=0,y=any, then if up and down are issued to the A pointer, they will never coincide. Boolfuck programs can be implemented in Addit by replacing all flips with a check to see if the cell pointed to is already one, setting it to zero if so (with decrement), otherwise setting to one (with increment). The behavior of Boolfuck's conditionals should be inverted so that the pre-initialized ones in Addit's grid are treated as zeros.