esolang

Jellyfish

A two-dimensional language inspired by J, where every function finds its arguments by looking south and east.

Turing complete: yes · ●●● hard

Tested with 6 known programs · Hello World on Try It Online: identical except the line end · Test method

Run it

Expected: Hello, World!

The idea

The name joins Jelly, a golfing language inspired by J, and Fish, a two-dimensional language. A program is a grid. Each function on it takes its arguments from the nearest item below it and the nearest item to its right, skipping blank cells. With both it is binary, with one it is unary. Only the item in the top left corner is evaluated, together with everything it needs.

Read the story

Nothing is printed by default. The functions p and P print their argument and pass it on, so they usually sit in the corner.

The machine

CodeDoes
12 'c "text"A number, a character, a string (a list of characters)
i IAn input line read as a value, as text
p PPrint as a value, print as a matrix
+ - * %Add, subtract, multiply, divide; alone, abs, negate, sign, reciprocal
rThe range from 0
# , ;Length, join, pair
< >Compare; alone, decrement, increment, head, tail
B V E S XBlock or turn the search for arguments

Arithmetic works on every element of a list. The left argument is the one from the south, so - and % compute the east value minus or divided by the south value.

Example

r5 is the range 0 to 4.
Expected: [0 1 2 3 4]
Expected: 0 1 2 3 4
Expected: 8

r5 is the range 0 to 4. p prints it as a value, in brackets; P prints it as a row. In the last program + has a 3 to its east and a 5 to its south, so it adds them, and p prints the sum.

This implementation is a subset, after the Python interpreter in the iatorm/jellyfish repository, which TIO runs. It has values, input, the search for arguments and the common functions. The operators, which build new functions from functions, and the rarer functions stop the run with the reason.

Patterns it teaches

Try this

  1. Print the sum of 12 and 30.
  2. Read a number and print its square.
  3. Hard: print the length of an input line.

Further

Also in Golfing

Write your own in Run Convert a program from Jellyfish

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run jellyfish -e 'pr5'
shib manual jellyfish

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/jellyfish.js

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