esolang

Xigxag

A string of arrows. Each arrow copies the part of the string it points at into the next one.

Chris Pressey, 2001 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: <><> <><>

The idea

Chris Pressey designed Xigxag in 2001 and released it in 2007. A configuration is a string of < and >, and there is nothing else. In one step every symbol is read in turn. A < copies everything to its left into the next configuration, and a > copies everything to its right. The copies are joined left to right.

Read the story

Almost every string grows, and fast. Pressey proved that all but a finite number of starting strings grow exponentially. A search of every string up to 7 symbols found five that come back, and each of them comes back after a single step. They are the empty string, <<<, >>>, <><> and <<<>>>.

The machine

SymbolCopies into the next string
<everything to its left
>everything to its right

The program is the first configuration, and every other character is ignored. The specification has no output and no end, so this implementation prints each configuration on its own line, the program first. It stops after printing one that came before. A number in the input stops it after that many steps.

Example

In <><> the first < copies nothing, the > copies <>, the second < copies <> and the last > copies nothing.
Expected: <<<>>> <<<>>>

In <><> the first < copies nothing, the > copies <>, the second < copies <> and the last > copies nothing. The result is <><> again.

Expected: >< <>

>< becomes <>, and <> becomes the empty string, which stays empty.

Expected: <<<< <<<<<< <<<<<<<<<<<<<<<

Four < give 0 + 1 + 2 + 3 = 6, then 15. The next steps have 105 and 5,460 symbols.

Patterns it teaches

Further

Also in Rewriting

Write your own in Run Convert a program from Xigxag

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: xigxag.

Command line

shib run xigxag -e '<<<'
shib manual xigxag

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/xigxag.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org