esolang

Swordfish

A smaller ><>. Whatever the pointer swims past that is not a command sticks to the var.

Numeri, 2013 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello, World!

The idea

Numeri made Swordfish in 2013, loosely after ><>. The specification says the official reason for the name is that it cuts away the parts of ><> that are not needed. A pointer moves over a grid of equal lines and wraps at the edges. There is one stack, one var and one register.

Read the story

Text needs no quotes. Every character that is not a command is added to the var as the pointer passes it, so Hello in the code puts Hello in the var and # prints it. A digit builds a number instead, the var times 10 plus the digit. A letter that is also a command, such as d or v, needs a : in front to count as a plain character.

The machine

CharDoes
> < ^ vPoint the pointer right, left, up or down
/ \Mirror it
| _Turn it back when it moves sideways, or when it moves up and down
;Halt
: ! ,Take the next character as plain; skip the next command; do nothing
~ @Push the var and clear it; pop into the var
[ ]Pop into the register; push the register
+ - *Add, subtract or multiply the popped top into the var
D dMake the var top / var, or var / top
=Pop, then push 1 if it equals the var and 0 if not
{ }Pop, then skip the next command if that was false, or if it was true
# ? %Print the var; read a number into it; clear it
$Sleep, which does nothing

A cleared var turns into a number with a digit and into text with anything else. False is 0, the cleared var and empty text.

Example

The Hello, World! spells the text on its way round three lines.

The Hello, World! spells the text on its way round three lines. The first \ sends the pointer down to W, the / below sends it left along orl, :d and :!, and the last two mirrors bring it up and right onto # and ;.

Expected: Hello, World!

The truth machine compares the input with 1. On 0 the { skips the v, so the pointer runs on to print 0 and halt. On 1 it goes down into a loop that prints 1 forever.

Expected: 0

The triangular numbers program keeps the step in the register and the sum on the stack. They print 1, 3, 6, 10, 15 and so on with nothing between them, and never stop.

Patterns it teaches

Further

Two-dimensional languages

Write your own in Run Convert a program from Swordfish

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run swordfish -e 'Hello:, Worl:d:!#;'
shib manual swordfish

Source

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

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

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