',,,'
Pronounced commata. A golfing stack language with symbols like ⫰ and 🀱, and no loops at all.
totallyhuman · Turing complete: no · ●●○ moderate · esolangs.org
Tested with 6 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
totallyhuman made ,,, as a stack language for code golf, written in Python. Most commands are single Unicode symbols such as ×, ÷, √ and ↻. The stack holds Python strings, whole numbers and floats. Every program ends by printing the top of the stack, so a Hello World is just a string with an opening quote: "Hello, World!.
Read the story
There is no loop and no conditional. The trick that remains: compute a 0 or a 1 and multiply by it.
The machine
Every number written in a program is a float, and so is anything that looks like a number when it is read: 6 7× prints 42.0. i turns a value into a whole number.
| Code | Does |
|---|---|
"text 'c | Push a string, push one character |
+ - × ÷ / % * | Add or join, subtract, multiply or repeat, divide, floor divide, modulo, power |
√ _ a ± | Square root, negate, absolute value, sign |
i f s c o B | To int, float, string; chr, ord, binary |
¬ ∧ ∨ | Not, and, or, as 0 or 1 |
< > = ≤ ≥ | Compare, giving 0 or 1 |
& \| ^ ~ « » | Bitwise |
⊢ ⊣ ⟛ 🀱 ⍷ | Drop n characters, keep n, every nth, index, count |
p P œ | Prime test, all divisors, odd test |
↓ ↑ : | Print and pop, pop, duplicate |
↔ ↻ ↺ • | Reverse, rotate both ways, fetch by index |
⫰ ⫯ Σ ⨳ | Smallest, largest, sum of the stack, product |
This implementation follows the Python interpreter at github.com/totallyhuman/commata, quirks included. A string runs to the last " in the program. ⇆ is meant to swap but puts the top back where it was. ⨳ pops the whole stack and pushes nothing. TIO passes arguments that start on the stack; this implementation passes each line of input as one.
Example
The second needs i: a string can only be repeated a whole number of times, and 3 alone is a float.
The second needs i: a string can only be repeated a whole number of times, and 3 alone is a float. The third is the conditional halving from the specification, with 10 as the input.
Patterns it teaches
Without loops ,,, is not Turing complete.
- Stack machines: every symbol works on the top of one stack.
- Code golf: one character per operation and an implicit print.
Without loops ,,, is not Turing complete.
See also
Golfing languages
Stack-based
Write your own in Run Convert a program from ',,,'
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: commata.
Command line
shib run commata -e '12P'shib manual commataSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/commata.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org