Turi

From Esolang
Jump to navigation Jump to search

Turi is a simple, useless programming language with one-symbol commands, mostly based on messing around with program flow. It's definitely Turing-complete, due to the t command. The language is designed to be as frustratingly annoying to implement as possible.

There are two accumulators: one accumulates floating-point quaternions and the other Unicode strings (treated as lists of codepoints, encoding is implementation-dependent). The numeric accumulator is initialized with 0 and the string accumulator with the empty string. The numeric accumulator is "A" for short and the string accumulator "S". [String] in the table below is a placeholder for any arbitrary string. You can guess what [Digit] is unless you are User:LyricLy.

At the end of a source file, execution direction is reversed, as if "zI" was used, but without zeroing A.

If an invalid command/symbol is executed, it should be interpreted as the nearest valid command ("nearest" by difference in codepoint value).

Source code is always encoded in UTF-8, because UTF-16 is bad and uncool.

Turi commands
Command What it does
h Prints "Hello, world!" with trailing newline.
d Deletes the Turi source file.

If in a nested interpretation session deletes the outermost source file. If running from stdin deletes the interpreter. If the program has been compiled somehow and the source is not available for deletion, delete the program instead. If any of these is not possible due to, for example, permissions, instead delete a random accessible file.

i Interpret Turi source code from stdin.
t Be Turing-complete (the precise method is implementation-dependent).
w Set S to the contents of a URI contained in S.
[Digit] Add the digit's value to A.
p Print A's real value (rounded down if not an integer) as a Unicode character.
z Set A to 0 in all 4 parts.
s Ignore the next x chars of program, where x is the current accumulator value.
|[String]| Set S to the string literal in the brackets.
P Print S without trailing newline.
<[String]> Append the string in the brackets to S.
r Set A's real value to a random integer. The integer must be very random.
u Make one randomly-selected command into a no-op.
c Multiply A by i.
f Repaces stdin with a stream from the filename contained in S. Whenever EOF is reached read the file backwards.
n Negates A.
I If A is zero in its real, i, j and k parts, reverse the direction of source code interpretation.
E Exit Turi.
R Read a line from input and append it to S. The newline is not appended.
# Tweet S, broken up into multiple tweets if necessary.
© Add all of the program's source code to the data being executed, after (or before, if execution is reversed) this symbol. If running from stdin, use the interpreter's source code instead.
ψ Branch Three Ways. Spawns three threads (or equivalent), one of which executes forwards, one backwards and one "downwards" (going downwards in lines, fixed at the horizontal position of the ψ being executed). These extra "threads" obey the standard reflection-at-program-edge rules.
Y Branch Two Ways. Like ψ (Branch Three Ways) but without the downwards component.
Hyperdimensional Translocate.

Moves the point of execution forwards and backwards within the current line being executed R spaces, where R is the real part of A. Moves upwards and downwards I spaces, where I is the imaginary part of A. Moves "aup" and "awn" J units, where J is the J part of A. "aup" and "awn" mean moving through all files in the current directory, in alphabetical order - for example, in a directory containing "aaaaaa", "bbbbbbbbbbb" and "ccc" moving 1 unit aup from bbbbbbbbbbb would move the point of execution to aaaaaa. T The K part of A is taken as how far to translocate, in parallel universes or something. The exact method of relocating the execution point to computers in these parallel universes is implementation-defined. If this is not possible, this will instead involve using the set of files available on other computers running the same Turi interpreter.

Quaternion Shift: moves A's real part into I, I into J, J into K and K into the real part.
Does absolutely nothing (noop).
Begin running Hexagony instead.
Kill the most recently spawned thread.
§ Calculate the SHA256 digest of the program as a raw bytestring. Lossily convert it to UTF-8, discarding invalid parts. Interpret the resulting string as Turi source code like i does.
Æ Create a new VM/container/isolated execution environment. Run the rest of the program in this environment.
? Run the sed command stored in S on the currently executing source code. Replace the currently executing source code with the result.

TuriExtended

TuriExtended is an extension to the Turi language containing useful primitives for solving previously unsolvable computing and mathematics problems.

TuriExtended commands
Command What it does
If running the program without this command would cause an infinite loop, halt execution with an error.
If P=NP then enter infinite loop.
Execute infinite loop in finite time.
Execute next command R seconds after program execution begins, where R is the real part of A and can be negative.

Example Programs

Hello, world! program:

h

almost-cat:

[]R<
>P[]

Infinite cat program:

zzzzψψ<
    ψψ
     <
   >YR<
>P||<>z[1]lzl
    >

Break the universe:

⛁r→r→r→rψ
  ⛁r→r→r→rψ
    ⛁r→r→r→rψ
      ⛁r→r→r→rψ

Fork bomb:

Y

F# interpreter:

|@fsibot |R#96n⛁

octopus cat:

YR<
>P[]ψ