esolang

LS Basic

A small BASIC that reads only the sum of each word's letters, so any word of the right score will do.

Simplemaker, 2020 · Turing complete: yes · ●●○ moderate · esolangs.org

Tested with 5 known programs · Test method

Run it

Expected: 42

The idea

Simplemaker wrote LS Basic, short for Letter-Sum Basic, in 2020. Every word is worth the sum of its letters, from a = 1 up to z = 26. print scores 77 and so does nurse, so the two are the same command. Variables and labels are scores as well. apple and disco both score 50 and name one variable.

Read the story

A plain program reads like BASIC, and the same program can be rewritten as a string of unrelated words. The cat, Input Apple Print Apple, becomes Smaller disco muses diner.

The machine

WordsScoresDoes
print v77Writes v in decimal
printchar v107Writes the character with code v
input v80Reads a whole number into v
let v equal ... done37, 56, 38Works out the words between in reverse Polish
lbl l goto l26, 57Marks a place; jumps to it
if a c b l15Jumps to l when a c b holds
end23Halts

The test c in if is lesser 78, equal 56 or greater 74. The operators in let are plus 68, minus 76, times 66, divide 53 and mod 32. The only constants are the variables zero, one and ten, which start as 0, 1 and 10. Line breaks mean nothing.

Example

The cat, plain and hidden.

The cat, plain and hidden.

Expected: 42

Arithmetic is reverse Polish between let and done. Two is one one plus, and four is two two times.

Expected: 4

The truth machine in its hidden form. alb scores 15 like if, term 56 like equal, and unaided 58 like loop. On 0 it jumps to the label vigil, which scores 59 like null, and prints zero.

Expected: 0

The Hello World makes base 70, as ten times eight minus ten, and steps from there to each letter. It prints HI WORLD!.

Patterns it teaches

  • Camouflage: a program can hide as a list of everyday words.
  • Encoding tricks: many words share a score, so every name has many spellings.

Further

Also in Camouflage

Write your own in Run Convert a program from LS Basic

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: ls-basic.

Command line

shib run ls-basic -e 'Input Apple
Print Apple' --input '42'
shib manual ls-basic

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/ls-basic.js

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

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