TriTape

From Esolang
Jump to navigation Jump to search

TriTape is an esolang by User:Joaozin003 where each cell in the tape stores a trit (base-3 digit).

Storage

As said in the intro, there is a tape (note: infinite only to the right!) that stores one trit in each cell.

There is also an accumulator which stores one trit. This accumulator is independent from the tape, but operations can be performed on the two.

Instructions

Here is a table of instructions:

I | Meaning
^ | Increment the accumulator, wrapping around.
v | Decrement the accumulator, wrapping around.
> | Move the tape pointer right.
< | Move the tape pointer left. If the current cell is the first, instead copy the value of the accumulator into it.
= | Copy the value of the current cell into the accumulator.
0 | Zero the current cell out.
+ | Add the value of the accumulator into the current cell, wrapping around. *Table later
, | Take a trit from input and copy it into the current cell.
. | Output the current cell's trit.
[ | Jump past the matching ] if the accumulator is 0.
] | Jump back to the matching [.
{ | Jump past the matching } if the accumulator is not 0.
} | Jump back to the matching {.

Table for the + instruction:

 C012
A
0 012
1 120
2 201

A stands for accumulator, C stands for current cell.

Examples

Truth Machine

,=[.].

Note: It also outputs "22222222222222222..." if fed a 2.

The following implementation, on the other hand, always prints “1” for a non-zero input:

,=[[^]^<.].

Cat program

This numeric cat program repeats until an input of zero (0) is committed:

,=[.,=]

Repeated Printing

The program below prints the digit one (1) five times using a loop:

^<v>>>>>{^+.<v=}

Turing-completeness

A subset of TriTape is equivalent to Boolfuck, described in this table, assuming that no 2s are input:

BoolFuck | TriTape
+        | =^+
,        | ,
;        | .
<        | =<
>        | >
[        | =[
]        | =]

And because BoolFuck is Turing-complete, TriTape is also Turing-complete.

Interpreter

  • Common Lisp implementation of the TriTape programming language.