esolang

Stack-gpt

A stack of numbers, one command a line, and a page that asks you not to waste your time.

2024 · Turing complete: no · ●○○ easy · esolangs.org

Tested with 2 known programs · Test method

Run it

Expected: hello world!

The idea

The specification says ChatGPT 4o mini made Stack-gpt in 2024, and that the specification itself was generated too. It is a plain stack language with labels, a goto and one conditional jump. The specification says in bold that it is not Turing complete.

Read the story

The table on the specification leaves a lot open. Its two programs settle three things. if looks at the top without popping it, printc pops what it prints, and len counts the number it is about to push, so on an empty stack it pushes 1. Both programs print a pushed text by looping until len gives 1.

The machine

CommandDoes
push 5 push "text"Push a number, or each character of the text in turn
pop dupe lenDrop the top, copy it, push the length plus 1
+ - * / % ^ & |Pop b, pop a, push a op b
negativeTurn a negative top into 0
print printcPop and print a number with a line feed, or a character
inputRead a line and push the code of each character
name: goto nameA label and a jump to it
if 1 nameJump when the top is 1
dieHalt

Text is pushed first character first, so push "olleh" leaves h on top. Numbers are doubles and / divides exactly.

Example

The hello world program pushes the text backwards and pops it one character at a time.

The hello world program pushes the text backwards and pops it one character at a time.

The truth machine prints the prompt 1or0> the same way, then reads a line. On 0 it prints 0 and halts; on 1 it prints 1 forever.

Expected: 1or0>0

Further

Ideas it shows

Generated by AI

Stack-based

Write your own in Run Convert a program from Stack-gpt

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: stack-gpt.

Command line

shib run stack-gpt -e 'push "!dlrow"
push 32 
push "olleh"
start:
len
if 1 end
pop 
printc
goto start
end:
die'
shib manual stack-gpt

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/stack-gpt.js

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

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