Livefish

From Esolang
Jump to navigation Jump to search

Livefish is a slight modification of Deadfish made by User:Areallycoolusername.

Commands

The commands are the same as from Deadfish, except for o, which now inputs things rather than output them. h can still be used to halt the program.

Command Deadfish Livefish
i increments increments
d decrements decrements
s square square
o output input

In the reference interpreter, the input is not involved with the accumulator and functionally serves no purpose.

Implementations

Pascal

There is one reference interpreter for Livefish, and it's in Pascal. Here it is.

program Livefish (input,output);
uses crt;
var
coke : integer;
cook : char;
crak : string;
begin
repeat
coke := 0;
readln(cook);
if(cook='i')then
coke := coke + 1;
if(cook='d')then
coke := coke - 1;
if(cook='s')then
coke := sqr(coke);
if(cook='o')then
readln(crak);
if(coke=256)then
coke := 0;
if(coke<0)then
coke := 0;
until cook='h';
end.

However, two more interpreters are added for Livefish by A.

C

#include <stdio.h>
int main()
{
    int ac=0;
    char c;
    while(c!='h')
    {
        c=getchar();
        if(c=='i')ac++;
        else if(c=='d')ac--;
        else if(c=='s')ac*=ac;
        else if(c=='o')scanf("%d",&ac);
        if(ac==256||ac<0)ac=0;
    }
    return 0;
}

Lua

ac=0
while cmd~="h" do
    cmd=io.read()
    if cmd=="i" then ac=ac+1
    elseif cmd=="d" then ac=ac-1
    elseif cmd=="s" then ac=ac*ac
    elseif cmd=="o" then ac=math.floor(tonumber(io.read()) or 0) end
    if ac==256 or ac<0 then ac=0 end
end

Python

DockedChutoy also made a Python interpreter. This is it:

acc = 0
while True:
    prg = input(" >")
    for cmd in prg:
        if acc == 256 or acc <= 0: acc = 0
        if cmd == "i": acc += 1
        if cmd == "d": acc -= 1
        if cmd == "s": acc *= acc
        if cmd == "o": acc = input(" input>")

Hello World

The hello world program in Deadfish is still valid in Livefish, but this time it doesn't output anything, since Livefish doesn't have any output capabilities. So, it would be like:

input
iisiiiisiiiiiiiioiiiiiiiiiiiiiiiiiiiiiiiiiiiiioiiiiiiiooiiio
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddo
dddddddddddddddddddddsddoddddddddoiiioddddddoddddddddo
output

Computational Properties

Due to the lack of output capabilities, Livefish isn't Turing-complete as it can't do much of the things a Turing machine can.

A Turing-complete programming language does not require output capabilities. It is instead Turing-incomplete because it cannot execute an infinite loop, or perform any sort of conditional branching.