UltimateBinary

From Esolang
Jump to navigation Jump to search
UltimateBinary
Designed by User:Sanya
Appeared in 2023
Computational class Unknown
Reference implementation Implemented
Influenced by Binary Brainfuck, Brainfuck
File extension(s) .ub.ubbf

UltimateBinary is a joke language, Brainfuck derivative created in by User:Sanya. The programm writed in it can seem like a random collection of ones and zeros. The commands in UltimateBinary can be long like 10000000 for input or short like 1 for next cell. For interpreter commands are zeros separated by 1. But to convert programm from Brainfuck to UltimateBinary you need to change > to 1, < to 10, etc.

Commands

Commands Equivalents
Brainfuck UltimateBinary Description
> 1 Move to the right cell
< 10 Move to the left cell
+ 100 Increment current memory block value by 1.
- 1000 Decrement current memory block value by 1.
[ 10000 Start loop
] 100000 Go to start loop if current cell value isn't 0
. 1000000 Print current cell value as an ASCII char.
, 10000000 Read charachter and write its ASCII-code into current cell.

Interpreter

Java

import java.util.*;


public class q {
    public static void main(String[] args) {
        Integer[] array = new Integer[30000];
        Scanner scanner = new Scanner(System.in);
        List<Integer> loop = new Stack<Integer>();
        String input = //String for compile;
        String[] arr = input.replace(" ","").replace("\r\n","")
                .split("1");
        int pos =0;
        for (int i=0;i<array.length;i++) array[i]=0;
        for (int i=0;i<arr.length;i++){
            switch (arr[i]){
                case "" -> pos++;
                case "0" -> pos--;
                case "00" -> array[pos]++;
                case "000" -> array[pos]--;
                case "0000" -> ((Stack<Integer>) loop).push(i);
                case "00000" -> {
                    if(array[pos]!=0)i=loop.get(loop.size()-1);
                }
                case "000000" -> System.out.print(Character.toChars(array[pos]));
                case "0000000" -> array[pos]=(int)scanner.next().charAt(0);
            }
        }
    }

}