tq

From Esolang
Jump to navigation Jump to search

tq is a language invented by User:A in 2019, but it wasn't yet in shape until 2020. The language idea was based on Jo King's Raku Quine. It was created so that you can index the list while you are defining your list!

Etymology

It was named as tq, because the quine in tq is like this:

etq'etq'

The name is an acronym, standing for "tail quote".

Syntax

A program in the language is a list without a separator, although a separator would indeed be neccecary if two items are ambiguous without separation. An example program is:

'Hello, World!'1

Look, there isn't any separator between the string and the number. In this program you defined a list:

['Hello, World!',1]

And then every item is outputted implicitly at the end without a separator.

Hello, World!1

Pretty easy, huh?

Tutorial

tq is an infix language. That means the operators go between the operands. Here is an example:

1+1," ",2-2

This outputs 2 0. In fact tq supports a lot of operators: +-*/%&|=>, all of which you have met before in other languages. The thing that needs to be noted is that the = does not mean assignment; it means equality comparison.

Most of tq's operators are mathematical: _ means negation, ! means factorial (NOT logical NOT).

Operator reference

Instruction Action
. Index inside the array. E.g. .4 indexes the 4th item in the array. Note that indexing starts at 1.
q "quote" the string, similar to Python's repr().
e "Evaluate" the string under tq syntax.
f "Find" the first occurence of the string in the main list, returns -1 if failed.
~ Reverse the list given as operand.

Implementation