esolang

Monolog

Almost every line defines a variable. Arrows carry text from the right, through functions, into a name.

CMinusMinus · Turing complete: unknown · ●○○ easy · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: Hello, World!

The idea

CMinusMinus made Monolog, also written MONOLOG. Almost everything a program does is defining a variable. A line starts with a name and an arrow, and what follows is a chain read from the right. Strings and variables are joined onto the front of what has come so far, and a function in brackets works on it. There are no integers, only text. A * as the name defines nothing, so a line can just print.

The machine

PartDoes
x <- ... * <- ...Define x as the result; define nothing
"text" xPut the text or the variable in front
(out) (outln)Print it, without or with a line feed
(input)Replace it with a line of input
(reversed) (double) (len)Reverse it; join it to itself; give its length
(b64e) (b64d)Encode or decode it in Base64
(active)Store it as the special variable active
(cuts) (cute)Drop the first n characters, n being active; keep only the first n
(same) (notsame)Go on with the line only if it equals active; only if it does not
(pass)Empty it
(run)Run it as Monolog

This implementation leaves out what the specification does not explain and what reaches outside. (request) and (ping) need a network, and (os) runs a command of the operating system. The $MONOLOG settings are left out, among them program.repeat, which starts the program again at its end, and with them the loop functions (exit), (crepeat) and (creset). So is (*name). The specification explains it as adding the result to the variable, but its count to 69 uses it on a line that defines no variable.

Example

The second Hello, World keeps the text in a variable first.

The second Hello, World keeps the text in a variable first.

Expected: Hello, World!

The cat reads from the right. (out) prints the prompt, (input) replaces it with a line of input, and (outln) prints that.

Expected: Enter Text: cat

Variables. y <- y <- " World!" puts y in front of the text, so y becomes Hello World!.

Expected: !dlroW olleH

(same) and (notsame) are the only choices. When the argument is not active, the rest of the line to the left of (same) does not run.

Expected: same

Further

Also in Functional and concatenative

Write your own in Run Convert a program from Monolog

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run monolog -e 'X <- (outln) <- "foo"'
shib manual monolog

Source

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

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

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