esolang

4ME

One word a line on a stack, and a second stack to park things on.

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

Tested with 3 known programs · Test method

Run it

Expected: Hello, world!

The idea

Ractangle made 4ME in 2024. A program is a list of short commands, one a line, that push, pop and print values on a stack. A second stack holds values out of the way. There are no loops and no jumps, so a program runs from top to bottom once.

Read the story

The specification describes three versions. The first, Normal 4ME, is the one implemented. A rewrite with variables and echo{...} was started and a second rewrite was dropped, and both are left out.

The machine

CommandDoes
P;Must open the file
out{text}Print the text
add{v}Push v
is / nsPush a line of input / a line of input as a number
pop / getDrop the top / print it and drop it
+ - * /Work on the top two, the lower one first
duplicateCopy the top
store / unstoreMove the top to the second stack / back

A file without P; on its first line stops with code S1245, and an empty line stops with S1456. Outputs follow each other with nothing in between.

Example

The A+B Problem program reads two numbers, adds them and prints the sum.

The A+B Problem program reads two numbers, adds them and prints the sum.

Expected: 5

6 is squared, parked on the second stack while 1 is pushed, and brought back, so the top two are 1 and 36.

Expected: -35

Patterns it teaches

Further

Queue-based

Write your own in Run Convert a program from 4ME

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run 4me -e 'P;
is
get' --input 'meow'
shib manual 4me

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/4me.js

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

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