Digitial

From Esolang
Jump to navigation Jump to search

Digital is an esolang created by User:ThatAH. It is similar in some ways to Unary but is intended to be more practical. Digital only uses ten instructions, the numbers of the base-10 system, where it derives it's name from.

Name

The creator of Digital knows that the correct adjective would be "numerical" but he decided to do some wordplay and go with Digital anyways.

Specification

To write Digital code, take any Python program and convert it into Unicode representations, e.g. "a" would be 97. Take that number and turn it into a number of ones since zero is reserved for delimiting in Digital. Which after you do delimit, keep doing it until you form your entire string, e.g. "print()" would be a sequence of 112, 114, 105, 110, 116, 40, and 41 ones. This will then get executed as Python code by the interpreter.

Other numbers (2-9) will equal the same amount of ones as them, so 5 for example would equal 11111, but 16 would not equal 16 ones. It would equal 7 ones (1 and 6). This means instead of putting 112 ones literally, one can put 14 eights to achieve it much more concisely.

While Python has been used as an illustrative example here, any X language can replace Python and would still be valid as a Digital variant. A variant could transpile to Perl code for example.

Examples

All of these were generated by a little Python program I hacked up. As you can see from the following examples Digital is much more useful than Unary with a "Hello world!" taking just 501 bytes instead of the billions and trillions of characters that Unary requires.

Program which adds two and two (217 bytes):

8888888888888806666666666666666666077777777777777705555555555555555555555044444444444444444444444444444088888055555555550111111111111111111111111111111111111111111105555555555011111111111111111111111111111111111111111

"Hello, world!" program (501 bytes):

888888888888880666666666666666666607777777777777770555555555555555555555504444444444444444444444444444408888802222222222222222209999999901111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111109999999999990999999999999033333333333333333333333333333333333330444444444440888807777777777777777703333333333333333333333333333333333333066666666666666666660999999999999055555555555555555555033333333333022222222222222222011111111111111111111111111111111111111111

Random number guessing game (543 bytes, surprisingly smaller than I expected):

777777777777777011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110888888888888880333333333333333333333333333333333333306666666666666666666044444444444444444444444444444088880666666666666666666601111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111055555555555555555555550555555555555555555550333333333333333333333333333333333333301111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111

(It might not be clear here or implied against but you can do a combination of different numbers. 12345 also works for 15 zeros.)

Implementations

A 229-byte Python interpreter which transpiles to Python wrote by me is as follows:

code = "".join(["0"*int(y) if y != "0" else "d" for y in "".join([x for x in input() if x in ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")])]).split("d")
x = []
for i in code: x += chr(len(i))
x = "".join([y for y in x])
eval(x)

Fair to say, Digital is quite easy to implement.

See also

Unary