esolang

"Gol><>"

><> with loops, a halt that prints the stack, and fewer bytes for everything.

Sp3000 · Turing complete: yes · ●●○ moderate

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

Run it

Expected: Hello, World!

The idea

Sp3000 made Gol><> as "the slightly golfier version of ><>". The fish still swims through a grid of one-character instructions and bounces off mirrors, but the letters that ><> left unused now do work. H prints the whole stack as text and stops, so Hello World is a reversed string and one more character. F opens a counted loop and | closes it, so a loop no longer needs a second row of arrows.

Read the story

Some ><> habits change meaning. | is the end of a block, not a mirror, and _ is an error. A string is read in a single step. Popping an empty stack gives 0 instead of an error.

The machine

A grid with one row per line and no padding, a stack of big integers and floats, and a tape of further stacks. The IP starts at the top left going right and never stops by itself.

OpDoes
> < ^ v / \ #Turn and mirror, as in ><>
"..." S"..."Push a string; print it at once
F...\| W...\| Q...\|Loop n times, loop while, if
L B CLoop counter, break, continue
RRepeat the next instruction n times
i IRead a character (-1 at the end), a number
o n NPrint a character, a number, a number and a newline
H h ;Print the stack as text and halt, print a number and halt, halt
M P z mMinus one, plus one, not, -1

Example

The second program reads 5 and loops five times, printing the counter L each time.
Expected: 0 1 2 3 4
Expected: 3628800
Expected: cat

The second program reads 5 and loops five times, printing the counter L each time. The third multiplies 1 by the counter plus one, ten times, which is 10 factorial. The last is cat; E skips the ; until the input is spent.

This implementation is a subset. It stops with a reason on x and on the switched instructions for logarithms, trigonometry and random numbers, rather than guess.

Patterns it teaches

Try this

  1. Print the numbers 1 to 10 with F.
  2. Read a line and print it reversed.
  3. Hard: print the first ten Fibonacci numbers.

Further

Also in Golfing

Write your own in Run Convert a program from "Gol><>"

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run golfish -e 'iE;o' --input 'cat'
shib manual golfish

Source

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

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