esolang

Grok

Befunge as a Vim user would write it. hjkl steer, i starts typing and a backtick escapes.

AarMil42, 2021 · Turing complete: unknown · ●●○ moderate · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: Hello, Waffles!

The idea

AarMil42 made Grok in 2021, after Befunge, ><> and the Vim editor. The program is a grid, the wordbox, and the pointer moves through it, wrapping around at the edges. The letters are chosen so that someone who knows Vim can guess them. h j k l move left, down, up and right, x deletes, y yanks and p puts.

Read the story

A capital letter works on the register instead of the stack, which Grok calls the Document. The register holds one value. Text goes in through insert mode, i, which collects every character the pointer passes until it meets a backtick.

The machine

CommandDoes
h j k lMove left, down, up, right
{ }Pop; turn left or right if it was 0
i ... ` | Push the text in reverse, so its first character is on top, or one number if it is all digits
IPut one character or one number in the register
` | Outside insert mode, skip the next cell
x XDrop the top, empty the register
y YCopy the nth value, or the top, to the register
p PMove or copy the register to the Document
dPop n, then drop n values
w zPop and print as a character or a number; W Z print the register
:Read a line of input the way insert mode reads text
+ - * / % > = !Arithmetic, compare and not
0 to 9Push a digit
qStop

An empty Document reads as 0. The programs need that, as their loops stop when ! meets an empty Document and pushes 1.

Example

The cat and truth machine.

The cat and truth machine.

Expected: 0

The cat reads the whole line, first character on top. The loop copies the top to the register with Y, drops it with ! and turns down on the 0 that ! leaves. On the second row it goes left, puts the character back with p, prints it with w and climbs up with k into the loop again. On 1 the truth machine prints 1 for ever.

The Hello world uses the same loop. The specification shows its output as Hello, world!, but the program has no comma in it.

Expected: Hello world!
Expected: 4242

Patterns it teaches

Further

Two-dimensional languages

Stack-based

Write your own in Run Convert a program from Grok

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run grok -e ':lY!}q
 kwph' --input 'Hello, Waffles!'
shib manual grok

Source

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

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

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