ABCD

From Esolang
Jump to navigation Jump to search

ABCD is an esoteric programming language made by user:Billlam. It's unusable for programming and it's totally Turing incomplete.

Every program has one and only one cell to do anything with.

Basic Commands

Cmd Description
A Cell = Cell + 1
B Cell = Cell - 1
C Input to cell
D Output cell

Examples

For readability, the programs are padded to 64-character rows.

Cat program

There's no loop instruction here, to write a CAT program you must write something like this:

CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD
CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD
CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD
CDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCDCD
...

Output Example

It's too hard to write a program that outputs a loooooong string (The coding will drive you crazy.) so the example just output FUCK to the console.

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAADAAAAAAAAAAAAAAADBBBBBBBBBBBBBBBBBBDAAAAAAAAD

Hello, World!

Unless you know how to autogenerate programs, that is.

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAADDAAADBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBDBBBBBBBB
BBBBDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAA
AAAAAAAAAAAAAAAAAAAAADAAADBBBBBBDBBBBBBBBDBBBBBBBBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBDBBBBBBBBBBBBBBBBBB
BBBBBD

Interpreter

Here is an interpreter written in C#. The program is the first line of input. If you pass the -g parameter followed by a string, it will generate a program to output that string.

using System;
using System.Linq;

class ABCD
{
    static void Main(string[] args)
    {
        char c = '\0';
        if (args.Length > 1 && args[0] == "-g")
        {
            string gen = String.Join(" ", args.Skip(1));
            for (int i = 0; i < gen.Length; i++)
            {
                if (gen[i] > c)
                    Console.Write(new String('A', (int)(gen[i] - c)));
                else
                    Console.Write(new String('B', (int)(c - gen[i])));
                c = gen[i];
                Console.Write('D');
            }
            return;
        }
        string prog = Console.ReadLine();
        for (int i = 0; i < prog.Length; i++)
            switch (prog[i])
            {
                case 'A':
                    c++;
                    break;
                case 'B':
                    c--;
                    break;
                case 'C':
                    c = (char)Console.Read();
                    break;
                case 'D':
                    Console.Write(c);
                    break;
            }
    }
}

See also