π
Every command is an emoji, called like a function, with its arguments between a slash and a backslash.
Kloodi Β· Turing complete: yes Β· βββ easy Β· esolangs.org
Tested with 2 known programs Β· Test method
Run it
The idea
Kloodi wrote π and its interpreter in Python. A program reads like nested function calls in which each function name is one emoji and each argument sits in / and \. Arguments can be calls themselves, so π/β\ prints what β reads.
Read the story
There are ten emoji and one loop. Values are strings and numbers. A string is true when it is not empty and a number when it is greater than 0, so a negative number is false.
The machine
| Emoji | Does |
|---|---|
π/v\ | Print v |
β | Read a line of input as a string |
π³ | Halt |
π©/name\/v\ | Store v in a variable |
π¨/name\ | Read a variable |
β β β β /a\/b\ | Add, subtract, multiply, divide |
π/n\ | Jump to line n |
{code}expr | Run code while expr is true |
A variable's name is a value too, so the empty string "" is a fine name. This implementation does what Python would where the specification is silent. π ends with a line feed, β gives a decimal such as 3.5 or 2.0, and lines count from 1.
Example
The truth machine, π©/""\/β\{π/1\}π¨/""\π/0\, stores the input under the name "", prints 1 while it isβ¦
The truth machine, π©/""\/β\{π/1\}π¨/""\π/0\, stores the input under the name "", prints 1 while it is true and then prints 0. The specification says it prints 0 once on 0. But β returns a string, and the string "0" is not empty, so it is true. Run by the specification's own rules, it prints 1 forever on 0 as well, and this implementation does that.
A countdown keeps n in a variable and subtracts 1 inside the loop.
Further
Ideas it shows
See also
Also in Jokes
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: u1f440.
Command line
shib run u1f440 -e 'π/β\' --input 'cat'shib manual u1f440Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/u1f440.js
Docs: Kernel instructions Β· The .shib format Β· Command line Β· Adding a language
Source esolangs.org (CC0) Β· Edit on esolangs.org