esolang

Pointstack

Brainfuck with the tape folded into a stack of numbers.

catto.4, 2024 · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: Hello World

The idea

catto.4 made Pointstack in 2024. It keeps brainfuck's habit of one character per command and of building every number by counting up, but the memory is a stack. Instead of moving along a tape you push a 0 and count it up with ^, and two counts multiply into a character code.

Read the story

The specification gives a one-line C interpreter, and this implementation follows it. It differs from the specification's own table in three places. . prints the top without popping it, [ skips the loop when the top is already 0, and \ skips on any number but 0.

The machine

CharDoes
!Push 0
^ _Add 1 to the top; take 1 from it
+ - * /Combine the top two into one
. ,Print the top as a character; push a character of input
: $ ?Duplicate; swap; drop
= ~Replace the top two with 1 if they are equal, or not equal; else 0
[ ... ]Loop while the top is not 0
` \ | Skip the next character if the top is 0, or if it is not

The stack holds at most 10,000 numbers. A command that finds too few numbers does nothing.

Example

The Hello World.

The Hello World. Each line multiplies two counts into a character code, and the third line duplicates its l to print it twice.

The cat reads one character and prints it.

Expected: x

A countdown. The count starts at 5. Each pass adds 48, which is 6 times 8, to a copy of it, prints that digit, drops it and takes 1 from the count.

Expected: 54321

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from Pointstack

Implementation

JavaScript interpreter, source and command line

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

Command line

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

Source

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

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

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