Terse
A command, a gap and the arguments, as in assembly, but with strings, arrays and functions.
2013 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Terse is a small interpreted language from 2013. Each line is a command followed by its arguments, and nothing has a declared type. A value is a number, a string or an array, and how it is used decides what it is. There is no if. A comparison is itself the start of a block, which runs when the comparison holds and ends at end. There is no loop statement either. loop calls a function once for each element of an array.
Read the story
The specification describes more than it pins down. It asks for a tab after the command and then uses spaces in every example, and two of its examples print other text than it says. So this implementation is a subset, and its manual names each choice.
The machine
| Line | Does |
|---|---|
out a b ... | Print the values one after the other |
decl &x | Declare the global x |
@x v $x v | Set a global or a local; several values make an array |
func f &p ... end | Define f, whose parameters are locals |
lt gt le ge eq a b ... end | Run the block when the comparison holds |
loop f array | Call f with each element |
add a b push | Sum into a result; push the result on the stack |
A value is a number, a "string", #n for the array 0 to n-1, @x or $x, in for a line of input or pop for the top of the stack. v:i is element i of an array, and <> after a value adds a line feed. Arrays print as [1, 4, 3].
This implementation leaves out the objects, obj, -> and ~, and all arithmetic but add, as the specification lists no other.
Example
Several values make an array, and #5 is the array 0 to 4.
Several values make an array, and #5 is the array 0 to 4. loop passes each element to the function.
The age program. in reads a line, and each comparison runs its block up to end. The specification uses the bare word age for the global, so a bare word is read as a variable when one has that name.
The greet function is said to print "Hello, Tim!", but its line out "Hello " $name "!" has no comma, and this implementation prints "Hello Tim!".
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from Terse
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: terse.
Command line
shib run terse -e ' out "Hello world!"'shib manual terseSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/terse.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org