Renumbering

From Esolang
Jump to navigation Jump to search

Renumbering is an esoteric programming language created by User:DoggyDogWhirl. It was created around the idea of re-assigning values to integers.

Overview

Instead of integer literals, Renumbering uses variables whose names are integers, and which are initialized to that integer's value. Negative integers are preceded with a _ (e.g. _1 is initialized to -1). The operations +-*/%^ are used on two variables, and re-assign the first variable to the result of the expression (compound assignment operators). = directly sets the first variable to the value of the second.

Operation Description
A = B Assignment: Sets A to the value of B.
A [+-*/%^] B Compound Assignment: Sets A to the result of the operation between the values of A and B.
I A Input: Sets A to the value inputted.
O A Output: Outputs the value of A. Floors decimals and raises an error if negative.
C A Character Output: Outputs the value of A as a character. Floors decimals and raises an error if negative.
G A Goto: Execution jumps to the command numbered the value of A (1-indexed).

Floors decimals. Does not jump if less than or equal to 0. Program ends if index is too high.

Relevant xkcd.

Example programs

2

Outputs 2 as a number.

O2

Outputs the character "2".

C50

Hello, world!

C72 C101 C108 C108 C111 C44 C32 C119 C111 C114 C108 C100 C33

Truth-machine

I1 C1 3=1 3-48 3*2 G3

Cat program

I_1 C_1 3=2 3*_1 4=1 4+_1 3/4 G3

Fibonacci sequence

_1=2 2=1 1+0 0=2 O0 C10 G_1

Infinite counter

O0 C10 0+1 G1

Prime numbers

_1=1 _1+1 
 _2=1 _2+1
  _3=_2 _3-_1 _3+1 _3*19 G_3
  _4=_1 _4%_2 
  _5=_4 _4*6 _5*2 _5+1 _4/_5 _4+2 G_4
O_1 C10 G2

Implementation

Implementation in Python