InDec
Add one, take one away, and loop while a number is 0. 0 is true.
Ettore Marmo, 2013 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Ettore Marmo made InDec in 2013, with an interpreter in Python 3.3 that translates a program into Python. Every alphanumeric word is a variable that starts at 0, and the only things a program can do to one are add 1 and take 1 away. There is no assignment and no arithmetic. A loop runs while its variable is 0, so 0 is true and every other number is false, and () breaks out of it.
Read the story
Functions are suffixes. fn @ x,y,z { ... } defines one, and it always returns its first parameter. Written after variables, a,b,c fn sets a to fn(a,b,c). The specification builds zero, one, addition, multiplication, a factorial and an AND gate this way.
The machine
| Write | Does |
|---|---|
a++ a-- | Add 1, take 1 |
a { ... } | Loop while a is 0 |
() | Leave the loop |
fn @ x,y { ... } | Define a suffix that returns x |
a,b fn | Set a to fn(a,b) |
a,b . | Print a and b side by side, then a line feed |
a& a? | Print as a character, or as True or False |
., | Print without the line feed |
// ... // | A comment |
A line break or ; ends a statement. The specification leaves open when the operations on a loop's own line run; they run once, before the loop starts.
Example
The zero function in its short form.
The zero function in its short form. If N is already 0 it sets c and stops; otherwise it takes 1 from N until N is 0.
Addition the same way, moving Y into X one at a time.
Read this way, the multiplication gives X times Y + 1, its factorial of 3 gives 24, and its AND gate gives true for two false inputs. Only the output examples, zero, one and addition are checked against the specification. Its Hello World imports a module called Operations for add32 and the like, which is not in the specification, so this implementation leaves import out.
Patterns it teaches
- Counter machines: numbers changed one step at a time and tested for 0.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from InDec
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: indec.
Command line
shib run indec -e 'zero @ N {c;N{c++()}c{N--{c++()}}}
one @ N {N zero ++} //Set N to 1//
a ++ ++ ++ ++ ++
a .
a zero .
a one .'shib manual indecSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/indec.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org