Hárdfish

From Esolang
Jump to navigation Jump to search

Hárdfish is an esolang invented by User:None1, inspired by Hardfish.

Almost all the specifications are the same, except two:

  1. r concatenates the rest of code to the code, then is removed from the code.
  2. Two consecutive same characters are allowed.

Examples

Infinite loop

The 2i+2 exponetial function, representing the length of the rrr program every time an instruction is executed
rr

The following program's source code gets longer exponetially for each instruction:

rrr

In fact, the program's length becomes 2i+2 characters long when i instructions are executed.

Due to the fact that this esolang can implement an infinite loop and a program that grows forever, implementing this esolang means that the implementing language is not total, and has infinite memory.

Interpreter

Python

code=input()
x=0
while code:
    c=code[0]
    code=code[1:]
    if c=='i':
        x+=1
    if c=='o':
        print(x)
    if c=='r':
        code+=code
    if c=='c':
        x=(3*x+1 if x%2 else x>>1)
    if c=='q':
        x=(2*x+1 if x%3 else x//3)
    if x in (-1,256):
        x=0

See also