esolang

Bored

The only value is the list. A number is how long a list is, and a string is a list of numbers.

VilgotanL, 2022 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 6 known programs · Test method

Run it

Expected: Hello, world!

The idea

VilgotanL made Bored in 2022 while bored, and the specification warns that some decisions may be questionable. There is one data type, the list. The integer 5 is any list of length 5, so integers cannot go below zero, and "hello" + 2 is 7. A string is a list of character codes, and print writes each item as the character whose code is the item's length.

Read the story

The keywords keep their odd capitals on purpose. Input is inPut and a printed line is printLn, because the author was bored.

The machine

StatementDoes
name = exprSet a global variable
print expr printLn exprPrint a list as characters; printLn adds a line break
while(expr) { ... }Repeat while the value has a length other than 0
if(expr) { ... }Run once if it does
sleep ms exprWait; here it waits for nothing
ExpressionGives
12 "text" [1, 2]A number, a string, a list
inPutA line of input as a string
a join bThe two lists one after the other
+ - % < == ! && ||Integers, from the lengths
num2str(n) geti(l, i) seti(l, i, v)Digits of n, item i of l, set item i of l

The specification has not written down its syntax yet, so this implementation reads it from the six examples. It says functions can be defined but never shows how, so only the three built-in ones run.

Example

The truth machine takes the first character of a line.
Expected: Hi!
Expected: 7

The truth machine takes the first character of a line. On 0 it skips the loop and prints 0; on 1 it prints 1 forever.

Expected: 0

The quine keeps its own text after the list as character codes. It prints the list with num2str, then the codes as characters.

Patterns it teaches

  • Encoding tricks: numbers written as the lengths of lists.
  • Quine: a list of codes that prints itself and then the program around it.

Further

Also in Jokes

Write your own in Run Convert a program from Bored

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run bored -e 'printLn "Hello, world!"'
shib manual bored

Source

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

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

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