esolang

Cascade

A tree-shaped language. Every cell is a function of the three cells below it.

GuyJoKing · Turing complete: unknown · ●●● hard

Tested with 3 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: 42

The idea

Nothing moves in Cascade. A program is evaluated from each @, and a cell's value comes from the cells under it, down-left, straight down and down-right. + is worth its left plus its right, # prints the value below it, and so on. The grid wraps at every edge, so the only way back up is to fall off the bottom, which is how a program loops.

The machine

Letters and digits are variables, each a stack that starts out as its own character code, or for a digit its value. Numbers are unbounded integers. The implementation follows the Raku interpreter in the repository GuyJoKing/Cascade, which is what TIO runs.

CellIs worth
@ \| / \The cell below; down-left; down-right
!The cell two below
^Left, then right
? _ $Right if below is above 0, else left; 0 if left is 0, else right; either at random
+ - * : %Left op right, with floor division
( ) ~Below minus 1, plus 1; 1 if below is 0
= < >1 or 0
, & ;A character in; a number in; 1 at the end of input
. #Print below as a character; as a number
"Print the characters below it down to the next "
[ ]Pop the variable below; push right onto the variable down-left
' { }The code of the character below; read and write the grid

Example

In the first program # prints what * is worth, and * multiplies the 6 down-left of it by the 7 down-right.
Expected: x

In the first program # prints what * is worth, and * multiplies the 6 down-left of it by the 7 down-right.

Patterns it teaches

Further

Also in Spatial (2D and up)

Write your own in Run Convert a program from Cascade

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run cascade -e '.
,' --input 'x'
shib manual cascade

Source

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

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