Wikitables

From Esolang
Jump to navigation Jump to search

Wikitables is a visual esolang invented by User:None1. It was drafted in January 2024, but forgotten until the time it was created in June 2024. It uses wikitext-like syntax.

Syntax

A Wikitables program consists of some rows, each row consists of some tables, in the following syntax description, (tableij) denotes the j-th table at the i-row. Its syntax must be like this:

(table11)
(table12)
...
<br>
(table21)
(table22)
...
<br>
...

Note that unlike wikitext, the syntax of Wikitables is very strict, so the line feeds and all the <br>'s (including the one at the end of program) are mandatory. The language is also case-sensitive.

A Wikitable program with 2 rows with 2 tables in each row may look like this:

(table11)
(table12)
<br>
(table21)
(table22)
<br>

Table syntax

The syntax for each table is just like the wiki table syntax, but much stricter. It must be like this:

{| class="wikitable"
| Example || Example || Example || ...
|-
| Example || Example || Example || ...
|-
| Example || Example || Example || ...
...
|}

All the spaces and line feeds are mandatory.

P.S.: Empty lines in the program and spaces at the start and end of each line is are removed from the code, so they will not affect the code's validity.

Threads

Wikitables uses a list of fake threads, a thread has a position and a direction and a data (a signed unbounded integer). Every time, all threads are traversed in random order: their commands are executed, then threads that are destroyed are removed from list, finally all threads are moved one step in their positions. Two operations are considered simutaneous if they occur in the same time.

Directions

Wikitables uses some HTML entities as directions.

Valid directions
In Wikitables Displayed in HTML Direction
&uarr; up
&darr; down
&larr; left
&rarr; right

Commands

Each table represents a command, there are 2 types of commands: keyword and calculator.

Keywords

A table with only one cel is a keyword. If it contains only a direction, it signifies a thread starts here with data set to 0 and direction set to the direction given. If it is empty, the threads that go here will be destroyed. If it has only a period in the cell, then it prints the data of the thread going to it. Otherwise, the content of the cell is printed when a thread hits it.

Calculators

There are two types of calculators: unary calculators and binary calculators.

Cells

A cell is a representation used by calculators, a cell can be like this (notes are for clarification and are not allowed in code):

(a) [Note: (b) is not given]
(a), [Note: the same as (a)]
,(b) [Note: (a) is not given]
(a),(b)

(a) can be:

  • An integer: Make the data of resulting thread the integer.
  • Not given (unary calculators only): Make the data of resulting thread the data of the original thread.
  • h (binary calculators only): Make the data of resulting thread the data of the horizontal thread.
  • v (binary calculators only): Make the data of resulting thread the data of the vertical thread.

(b) can be:

  • A direction: Make the direction of resulting thread the direction.
  • Not given (unary calculators only): Make the direction of resulting thread the direction of the original thread.
  • h (binary calculators only): Make the direction of resulting thread the direction of the horizontal thread.
  • v (binary calculators only): Make the direction of resulting thread the direction of the vertical thread.

Unary calculators

A unary calculator is a table with exactly 2 columns. The first column contains integers, the second contains cells. When a thread hits it, it searches in the first column from top to bottom for a number the same as its data. If it does not find any, it will do nothing, otherwise, it will modify the data and direction according to the cell at that row, for example, this is a NOT gate unary calculator:

{| class="wikitable"
| 0 || 1
|-
| 1 || 0
|}
0 1
1 0

Binary calculators

A binary calculator is a table with more than 1 rows and more than 1 columns, the top-left corner can only be a string starting with : (to denote that this is a binary calculator, not a unary calculator), which is the only place where comments can be put in Wikitables.

A binary calculator only works if exactly one thread with horizontal direction (left/right) and exactly one with vertical direction (up/down) hit it simutaneously, otherwise it is a NOP.

When a binary calculator works, it searches the row with the value of the horizontal thread in the first column (unlike unary calculators, the first row and the first column except the top-left corner can be empty have integers, empty means that it can match any values), then searches column with the value of the vertical thread in the first row, if one of them is not found, it is a NOP, otherwise it destroys the two threads and creates a thread according to the cell at the found row and column. For example, the following is an AND gate:

{| class="wikitable"
| :AND gate || 0 || 1
|-
| 0 || 0,h || 0,h
|-
| 1 || 0,h || 1,h
|}
:AND gate 0 1
0 0,h 0,h
1 0,h 1,h

The following makes the horizontal thread go up and destroys the vertical thread if a vertical thread hits the calculator simutaneously, otherwise NOP:

{| class="wikitable"
| :Activator || 
|-
|  || h,↑
|}
:Activator
h,↑

This can be used for thread communication, by letting the first thread sending a third thread when the second thread hits the calculator.

Examples

Hello World

{| class="wikitable"
| →
|}
{| class="wikitable"
| Hello World!
|}
{| class="wikitable"
| 
|}
<br>
Hello World!