esolang

Rozpach

Functions and nothing else. Even a character is eight functions on a stack.

PoetLuchnik, 2022 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hi

The idea

PoetLuchnik made Rozpach in 2022 as a language with only functions. A program is a list of definitions, and there are two operations, push a function or an argument, and pop a function and call it. The name is Ukrainian for despair.

Read the story

There are no numbers or characters. A bit is a function of two arguments that keeps one of them, the first for 1 and the second for 0. The reference interpreter, TinyRozpach, reads and prints a character as eight such bits, high bit first.

The machine

A definition is a name, its arguments, a ., the body and a ;, all split by white space.

In a bodyDoes
an argument's namePush the value of that argument
a function's namePush that function
.Pop a function and call it

A call pops its arguments from the stack, the last one from the top, so S a b . b a ; swaps the top two. The run calls main. get pushes the eight bits of an input character and put pops eight and prints one. Popping an empty stack gives the bit 0.

Example

T keeps its first argument and F its second, so they are 1 and 0.

T keeps its first argument and F its second, so they are 1 and 0. 01001000 is 72, an H, and 01101001 is 105, an i. The specification spells its Hello World the same way, 13 characters of 8 bits.

Expected: 0

The truth machine passes loop the low bit of the input. loop prints 0011000 and that bit, which is the digit read. Then it calls the bit on loop and 1. A 1 keeps loop and the next . runs it again. A 0 keeps 1, which only drops a value, and the run ends.

The 99 bottles of beer counts down with digits that are functions of ten arguments and prints each number with two digits, 09 and 01 too. Its Triangle counts with four bits and prints lines of 16 stars down to 1. Its Increment counts from 0 to 255 in binary.

Patterns it teaches

Further

Stack-based

Write your own in Run Convert a program from Rozpach

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run rozpach -e 'main . get . loop . ;
loop a . 0 0 1 1 0 0 0 a put . a loop 1 a . . ;
0 a b . b ;
1 b . ;' --input '0'
shib manual rozpach

Source

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

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

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