)0,1(

From Esolang
Jump to navigation Jump to search
[0,1]
Paradigm(s) imperative
Designed by User:Rphii
Appeared in 2021
Memory system Cell-based
Dimensions one-dimensional
Computational class Unknown
Major implementations Author's
Influenced by brainfuck
File extension(s) .01

[0,1] or )0,1( is an esoteric programming language created by User:rphii in 2021.

Motivation

  • Concept of infinity within fixed bounds.
  • brainfuck-ish but different.
  • Interrelation.

Memory

There is a theoretical infinitely addressible memory space from index 0 to 1, both 0 and 1 inclusive. Note that in this language it is possible for the index to be any real number, hence the name for this language.

Variables

At each memory index there is a variable whose value ranges from 0 to 1, both 0 and 1 inclusive. This also applies to the indexes that access the values (i and j).

Abbreviations

For making explanations easier we'll use some abbreviations.

Abbr. Description
i Index 0 (main)
j Index 1 (secondary)
q 10^q
jq j multiplied by q
@i or @j Value at i or at j within memory

j, q & jq

Below we take a closer look at j, q and jq.

j q jq
1 0 1*10^0 = 1*1 = 1
1 1 1*10^1 = 1*10 = 10
1 2 1*10^2 = 1*100 = 100
1 -1 1*10^(-1) = 1*0.1 = 0.1

etc.

Commands

There are 11 commands.

Command Description
+ Increment q
- Decrement q
~ Swap @i and @j
' Swap i and @i
" Swap j and @j
= Apply rotation @i with magnitude of jq
: Apply rotation @i with magnitude of -jq
[ If no overflow/underflow occured on last rotation jump past matching ]
] If overflow/underflow occured on last rotation jump back to matching [
. Output character of the rounded reciprocal @i
, Input character and store reciprocal value @i

Command: .

Say that we have a value of 0.0139 stored @i. The . command first creates the reciprocal value of @i, in this case 1/0.0139 = 71.9424. This value then gets rounded to 72 and printed as a character, which, according to an ASCII table, corresponds to an H.

Command: ,

Say that the user enters an H. The , command first creates the reciprocal of the ASCII value, in this case 1/72 = 0.013888... and stores it @i

Illegal operations

If any of the following illegal operations is triggered, the program should stop or else the universe will explode into countless pieces. Stop exploding universes, that's not cool.

  • Be careful with outputting a 0 or you'll maybe anger some mathematicians... Just kidding. It is not allowed to (input nor) output a 0 (note that Ascii 0 with the value 48 can be printed, just not plain old 0).

Initialization

It is mandatory that each language specifies if initialization takes effect and how. In [0,1] everything is defined by the table below.

Variable Initialized Value
i 0
j 1
q 0
@i i (each memory index initializes its own memory index as a value)

Limits

Variable Number set Range
i real numbers 0...1
j real numbers 0...1
q whole numbers -∞...∞
@i real numbers 0...1

Overflowing / Underflowing

  • The = command rotates @i with magnitude jq. (Simply put it adds a value onto another value, but this way it may be easier to imagine)
  • The : command does the same, but subtracts instead.
  • The specification within limits tells us that any number should not be smaller than 0 nor larger than 1.

Conclusion: A number could overflow or underflow. If this happens, a number whould be A) larger than 1 or B) smaller than 0.

  • In the case of A) the number automatically gets 1 subtracted until it is smaller than or equal to 1.
  • In the case of B) the number automatically gets 1 added, until it is greater than or equal to 0.

The overflow information is stored until another number is rotated.

Execution

[0,1] is similarly executed like brainfuck, character for character. Any non-command character is simply ignored.

Examples

Truth machine

--==-=-::~,.++++":=[.]

Hello World

On GitHub there is a slightly commented out version.

--=-====-:.+::::.-::::::..:::.:::::+====+=.=-:.+::.-::-:::::.::.=====.=======.++==.

Implementation

Interpreter written in C (GitHub)