esolang

Lossia

Every command starts with an l, so a program can be drawn as the Loss meme.

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

Tested with 2 known programs · Test method

Run it

Expected: 0

The idea

Tetrapyronia made Lossia in 2021. It is a small stack language whose eleven commands are each written as l and one more character. Spaces may go anywhere, even inside a command, and the first pair on a line that is not a command turns the rest of the line into a comment. Between the two rules a program can be shaped into the four panels of Loss, |, ||, || and |_, made of l, I and spaces.

Read the story

The interpreter it links reads each line two characters at a time and drops spaces first.

The machine

One stack of whole numbers with no limit.

CommandDoes
ll liPrint the top as a number or a character, and a line break
lLPush a number read from a line of input
lsPop two, push the lower minus the top
l-Push -1
l[ lxDuplicate; swap
l=Skip the next command if the top two are equal
l. l,Pop; if below 1, or above 1, skip past the next l_ and the command after it
l_Go back to just after the last l. or l,

A loop tests its number once on the way in, so l_ repeats it until something else jumps out.

Example

The truth machine.

The truth machine. The first line reads the input and oss starts a comment; the second prints it and IIIIll is a comment.

On 0 the l. jumps past the end and the run stops after one 0. On 1 it falls into the loop and prints 1 forever.

Expected: 42

There is no adding, so this one subtracts -1.

Patterns it teaches

  • Stack machines: one stack, and only subtraction to do arithmetic with.
  • Camouflage: the comment rule lets the code hide inside a picture.

Further

Stack-based

Write your own in Run Convert a program from Lossia

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run lossia -e 'l- l- Push 2 -1s to the stack'
shib manual lossia

Source

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

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

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