CARfish

From Esolang
Jump to navigation Jump to search

CARfish(Complex Alternate Representation deadFISH) is an esolang invented by User:A that tries to make experiences of Deadfish worse. (It has the same four commands, though.)

CARfish started out from two separate languages: Map(Alternate Deadfish command representation) and ANTS(Alternate Number Typing System). Note that programs in CARfish should be written in ANTS, not Map.

Map documentation

Map is an alternate representation of Deadfish commands. Commands can be presented by numbers.

The numbers in Map do only one thing: Set the is-command flag to true. This results in Map executing the commands according to this scheme:

As long as i≠0,
If i mod 4=0: execute i
Otherwise if i mod 4=1: execute d
Othereise if i mod 4=2: execute s
Otherwise if I mod 4=3: execute o

It automatically maps down to 0 if the accumulator is -1 or 256.

This is a simple program in Map that outputs 16:

4 8 10 14 15

Implementation of Map

#include <stdio.h>
int main(int argc, char *argv[])
{
	int ac=0;
	int max=0;
	char c, code[99999];
	short book[99999];
	FILE *f=fopen(argv[1],"r");
	for(int i=0;(c=fgetc(f))!=EOF;i++)
		code[i]=c;
	int ans;
	for(int i=0;code[i]!='\0';i++)
	{
		if(code[i]>='0'&&code[i]<='9')
		{
			ans*=10;
			ans+=code[i]-48;
		}else
		{
			max=max>ans?max:ans;
			book[ans]=1;
			ans=0;
		}
	}
	max=max>ans?max:ans;
	book[ans]=1;
	for(int i=0;i<=max;i++)
	{
		if(book[i]==1)
		{
			if(ac==256||ac==-1)ac=0;
			if(i%4==0)
				ac++;
			else if(i%4==1)
				ac--;
			else if(i%4==2)
				ac*=ac;
			else if(i%4==3)
				printf("%d\n",ac);
		}
	}
	return 0;
}

ANTS documentation

ANTS is an alternate representation of Map programs. There are just 4 commands:

i: switch the current function
o, d, and s: Type a specified character

The function mapping is like this:

Function 1(F1 afterwards): o:0, d:1, s:2
F2: 3, 4, 5
F3: 6, 7, 8
F4: 9, 0, (space)

Here is a simple program that prints 5:

idiisiiiisisidoiiiisidsiiiisidiis

Compiler from ANTS to plain text

#include <stdio.h>
char o='0',d='1',s='2';
int status=0;
char code[99999],c;
void map()
{
	if(status==0)
	{
		o='3';d='4';s='5';
	}
	else if(status==1)
	{
		o='6';d='7';s='8';
	}
	else if(status==2)
	{
		o='9';d='0';s=' ';
	}
	else if(status==3)
	{
		o='0';d='1';s='2';
	}
	status++;
	if(status==5)
		status=0;
}
int main(int argc, char*v[])
{
	FILE *f=fopen(v[1],"r");
	for(int i=0;(c=fgetc(f))!=EOF;i++)
		code[i]=c;
	for(int i=0;code[i]!='\0';i++)
	{
		if(code[i]=='i')map();
		else if(code[i]=='d')printf("%c",d);
		else if(code[i]=='s')printf("%c",s);
		else if(code[i]=='o')printf("%c",o);
	}
	return 0;
}