Metabox

From Esolang
Jump to navigation Jump to search
Metabox
Designed by User:Batata
Appeared in 2021
Computational class Turing Complete
Reference implementation Unimplemented
File extension(s) .mtbx

Metabox is an esolang that consists of multiple boxes inside each other, where each one has a unique code that together create an algorithm. It was created by User:Batata.

Metabox uses ASCII-exclusive characters to function and, because of that, it's usability for writing programs is unknown.

Overview

Metabox uses different types of "tileable" ASCII characters, but it's functions are formatted in normal text, so it shouldn't be hard to understand them. Here are the tileable characters you use to create the boxes.

Normal boxes. Use them to, well, "contain" the code.
┌───┐
│   │
└───┘
┌─────────────┐
│ Sample Text │
└─────────────┘
Highlight boxes. Use them to contain an important part of the code (if you want to highlight something, of course).
╭───╮
│   │
╰───╯
╭─────────────╮
│ Sample Text │
╰─────────────╯
Comment boxes. Use them to contain a comment inside a box.
╔═══╗
║   ║
╚═══╝
╔═════════════╗
║ Sample Text ║
╚═════════════╝

Algorithm Order

The algorithm order is based on the size of the boxes; it goes from the smaller box, which is always the "start program" box, to the bigger box, which doesn't actually need to be the "end program" box. Of course, the smaller boxes are contained inside the bigger boxes. Here's an example program:

┌───────────────┐
│┌─────────────┐│
││start program││
│└─────────────┘│
│  end program  │
└───────────────┘

This program should do... nothing, actually. However, it shows the basic code parsing of the esolang. Notice how the start box is smaller than the end box, indicating the program should start in the start box and end in the end box. Here's another example, now using the print function:

┌──────────────────────────────┐
│┌────────────────────────────┐│
││┌─────────────┐             ││
│││start program│ print "Hi!" ││
││└─────────────┘             ││
│└────────────────────────────┘│
│          end program         │
└──────────────────────────────┘

As you can see, this program should simply print the output "Hi!". Again, it is possible to visualize the algorithm order: it starts in the start box, which is smaller than the print box, which is smaller than the end box. It is also important to notice you can write the code in the way you want and in the position you want inside a box.

Events

Creating an event inside a box is simple: you just write a code outside the, let's say, main box, and, when the code is finished, you just write the event next to the box. For example, here's a program that should print the word "Supercalifragilisticexpialidocious" five times in a row:

┌──────────────────────────────────────────────┐
│┌────────────────────────────────────────────┐│
││┌─────────────┐                             ││
│││start program│                             ││
││└─────────────┘                             ││
││                                            ││
││              loop 5 times                  ││
││┌──────────────────────────────────────────┐││
│││print "Supercalifragilisticexpialidocious"│││
││└──────────────────────────────────────────┘││
│└────────────────────────────────────────────┘│
│                 end program                  │
└──────────────────────────────────────────────┘

As shown above, the loop text appears right above the print box, which is separated from the rest of the program. Here's an odd example using an if-else event:

┌─────────────────┐
│┌───────────────┐│
││┌─────────────┐││
│││start program│││
││└─────────────┘││
││┌─────────────┐││
│││ if input =  │││
│││    "1"      │││
│││ ┌─────────┐ │││
│││ │print "1"│ │││
│││ └─────────┘ │││
│││             │││
│││    else     │││
│││ ┌─────────┐ │││
│││ │print "0"│ │││
│││ └─────────┘ │││
││└─────────────┘││
│└───────────────┘│
│   end program   │
└─────────────────┘

This example is a little confusing, but basically, both "if" and "else" are inside a box separated from the rest. The program works fine but it shows that event chains can be implemented.

Examples

Print "Hello, World!"

┌───────────────────────────────────────┐
│┌─────────────────────────────────────┐│
││┌─────────────┐                      ││
│││start program│ print "Hello, world!"││
││└─────────────┘                      ││
│└─────────────────────────────────────┘│
│              end program              │
└───────────────────────────────────────┘

Cat

┌──────────────────────────────┐
│┌────────────────────────────┐│
││┌─────────────┐             ││
│││start program│ print input ││
││└─────────────┘             ││
│└────────────────────────────┘│
│          end program         │
└──────────────────────────────┘

Truth-machine

┌────────────────────────────────┐
│        ┌─────────────┐         │
│        │start program│         │
│        └─────────────┘         │ 
│                                │
│ if input = 0     if input = 1  │
│┌───────────┐    ┌─────────────┐│ 
││┌─────────┐│    │ loop forever││
│││print "0"││    │ ┌─────────┐ ││       
││└─────────┘│    │ │print "1"│ ││
││end program│    │ └─────────┘ ││
│└───────────┘    └─────────────┘│
└────────────────────────────────┘

Print Fibonacci Sequence

┌─────────────────────────────────────────────────┐
│┌───────────────────────────────────────────────┐│
││┌─────────────────────────────────────────────┐││
│││┌─────────────────────────────┐              │││
││││┌─────────────┐ set variable │ set variable │││
│││││start program│ "a" to -1    │ "b" to 1     │││
││││└─────────────┘              │              │││
│││└─────────────────────────────┘              │││
││└─────────────────────────────────────────────┘││
││             set variable "c" to 1             ││
│└───────────────────────────────────────────────┘│
│                                                 │
│                                                 │
│            loop forever                         │
│┌─────────────────────────────────────┐          │
││┌───────────────────────────────────┐│          │
│││┌─────────────────────────────────┐││          │
││││┌─────────────────┐              │││          │
│││││set variable "c" │              │││          │
│││││to variable "a" +│ print        │││          │
│││││variable "b"     │ variable "c" │││          │
││││└─────────────────┘              │││          │
│││└─────────────────────────────────┘││          │
│││  set variable "a" to variable "b" ││          │
││└───────────────────────────────────┘│          │
││   set variable "b" to variable "c"  │          │
│└─────────────────────────────────────┘          │
└─────────────────────────────────────────────────┘

Factorial Calculator

┌────────────────────────────────────────┐
│┌──────────────────────────────────────┐│
││┌────────────────────────────────────┐││
│││┌───────────────────────────────┐   │││
││││┌─────────────────────────────┐│   │││
│││││┌─────────────┐ set variable ││   │││
││││││start program│ "a" to input ││   │││
│││││└─────────────┘              ││   │││
││││└─────────────────────────────┘│   │││
││││ set variable "b" to input - 1 │   │││
│││└───────────────────────────────┘   │││
│││                                    │││
│││       loop (input - 1) times       │││
│││┌──────────────────────────────────┐│││
││││┌────────────────┐                ││││
│││││set variable "a"│ set variable   ││││
│││││to variable "a" │ "b" to variable││││
│││││* variable "b"  │ "b" - 1        ││││
││││└────────────────┘                ││││
│││└──────────────────────────────────┘│││
││└────────────────────────────────────┘││
││          print variable "a"          ││
│└──────────────────────────────────────┘│
│             end program                │
└────────────────────────────────────────┘

99 Bottles Of Beer

┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│
││┌─────────────────────────────────────────────────────────────────────────────────┐                                      ││
│││┌─────────────────────────────┐                                                  │                                      ││
││││┌─────────────┐ set variable │                                                  │                                      ││
│││││start program│ "a" to 99    │                                                  │                                      ││
││││└─────────────┘              │                                                  │                                      ││
│││└─────────────────────────────┘                                                  │ print "1 bottle of beer on the wall, ││
│││                                                                                 │ 1 bottle of beer.                    ││
│││                                  loop 98 times                                  │ Take one down, pass it around,       ││
│││┌───────────────────────────────────────────────────────────────────────────────┐│ No bottles of beer on the wall."     ││
││││┌─────────────────────────────────────────────────────────────────────────────┐││                                      ││
│││││┌───────────────────────────────────────────────────────────────────────────┐│││                                      ││
││││││┌────────────────────────────────────────┐ print variable "a" & " bottles  ││││                                      ││
│││││││print variable "a" & " bottles of beer  │ of beer.                        ││││                                      ││
│││││││on the wall,"                           │ Take one down, pass it around," ││││                                      ││
││││││└────────────────────────────────────────┘                                 ││││                                      ││
│││││└───────────────────────────────────────────────────────────────────────────┘│││                                      ││
│││││                    set variable "a" to variable "a" - 1                     │││                                      ││
││││└─────────────────────────────────────────────────────────────────────────────┘││                                      ││
││││               print variable "a" & " bottles of beer on the wall."            ││                                      ││
│││└───────────────────────────────────────────────────────────────────────────────┘│                                      ││
││└─────────────────────────────────────────────────────────────────────────────────┘                                      ││
│└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│
│                                                     end program                                                           │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

FizzBuzz

┌────────────────────────────────────────┐
│┌─────────────────────────────┐         │
││┌─────────────┐ set variable │         │
│││start program│ "a" to 1     │         │
││└─────────────┘              │         │
│└─────────────────────────────┘         │
│                                        │
│                                        │
│                                        │
│             loop forever               │
│┌──────────────────────────────────────┐│                                  
││┌────────────────────────────────────┐││
│││set variable "a" to variable "a" + 1│││
││└────────────────────────────────────┘││
││  ┌────────────────────────────────┐  ││
││  │  if (variable "a" mod 15) = 0  │  ││
││  │       ┌────────────────┐       │  ││
││  │       │print "FizzBuzz"│       │  ││
││  │       └────────────────┘       │  ││
││  │                                │  ││
││  │             else               │  ││
││  │┌──────────────────────────────┐│  ││
││  ││ if (variable "a" mod 3) = 0  ││  ││
││  ││        ┌────────────┐        ││  ││
││  ││        │print "Fizz"│        ││  ││
││  ││        └────────────┘        ││  ││
││  ││                              ││  ││
││  ││            else              ││  ││
││  ││┌────────────────────────────┐││  ││
││  │││if (variable "a" mod 5) = 0 │││  ││
││  │││       ┌────────────┐       │││  ││
││  │││       │print "Buzz"│       │││  ││
││  │││       └────────────┘       │││  ││
││  │││                            │││  ││
││  │││           else             │││  ││
││  │││    ┌──────────────────┐    │││  ││
││  │││    │print variable "a"│    │││  ││ 
││  │││    └──────────────────┘    │││  ││
││  ││└────────────────────────────┘││  ││
││  │└──────────────────────────────┘│  ││ 
││  └────────────────────────────────┘  ││ 
│└──────────────────────────────────────┘│ 
└────────────────────────────────────────┘ 

Print Collatz Sequence from input

┌───────────────────────────────────┐
│┌─────────────────────────────────┐│
││┌───────────────────────────────┐││
│││┌─────────────────────────────┐│││
││││┌─────────────┐ set variable ││││
│││││start program│ "a" to       ││││
││││└─────────────┘ input        ││││
│││└─────────────────────────────┘│││
│││                               │││
│││ loop until variable           │││
│││      "a" = 1                  │││
│││┌────────────────────┐         │││
││││┌──────────────────┐│         │││
│││││print variable "a"││         │││
││││└──────────────────┘│         │││
││││                    │         │││
││││   if variable "a"  │         │││
││││      mod 2 = 0     │         │││
││││ ┌────────────────┐ │         │││
││││ │set variable "a"│ │         │││
││││ │to variable     │ │         │││
││││ │"a" / 2         │ │         │││
││││ └────────────────┘ │         │││
││││                    │         │││
││││        else        │         │││
││││ ┌────────────────┐ │         │││
││││ │set variable "a"│ │         │││
││││ │to variable "a" │ │         │││
││││ │* 3 + 1         │ │         │││
││││ └────────────────┘ │         │││
│││└────────────────────┘         │││
││└───────────────────────────────┘││
││        print variable "a"       ││
│└─────────────────────────────────┘│
│            end program            │
└───────────────────────────────────┘

Deadfish Interpreter

┌────────────────────────────────────────────────────────────────────────────┐
│┌──────────────────────────────────────────────────────────────────────────┐│
││┌─────────────────────────────────┐                                       ││
│││┌───────────────────────────────┐│                                       ││
││││┌─────────────────────────────┐││                                       ││
│││││┌─────────────┐ set variable │││    ╔═════════════════════════════╗    ││
││││││start program│ "a" to 0     │││    ║ Warning: This interpreter   ║    ││
│││││└─────────────┘              │││    ║ may or may not have missing ║    ││
││││└─────────────────────────────┘││    ║ features because I'm dumb.  ║    ││
││││     set variable "b" to 0     ││    ╚═════════════════════════════╝    ││
│││└───────────────────────────────┘│                                       ││
│││       print ">> " & input       │                                       ││
││└─────────────────────────────────┘                                       ││
││                                                                          ││
││                                                                          ││
││                      loop (length of input) times                        ││
││┌────────────────────────────────────────────────────────────────────────┐││
│││if character (variable                                                  │││
│││  "a") of input = o                                                     │││
│││ ┌──────────────────┐                                                   │││
│││ │print variable "b"│                                                   │││
│││ └──────────────────┘                                                   │││
│││┌──────────────────────────────────────────────────────────────────────┐│││
││││┌────────────────────────────────────────────────────┐                ││││
│││││   if character (variable "a") of input = s         │                ││││
│││││┌───────────────────────────────────────────────┐   │                ││││
││││││set variable "b" to variable "b" * variable "b"│   │                ││││
│││││└───────────────────────────────────────────────┘   │                ││││
│││││┌──────────────────────────────────────────────────┐│                ││││
││││││ if variable "b" = -1                             ││ if variable "b"││││
││││││┌─────────────────────┐                           ││     = 256      ││││
│││││││set variable "b" to 0│                           ││ ┌────────────┐ ││││
││││││└─────────────────────┘                           ││ │set variable│ ││││
││││││┌────────────────────────────────────────────────┐││ │ "b" to 0   │ ││││
│││││││┌──────────────────────┐                        │││ └────────────┘ ││││
││││││││if character (variable│ if character (variable │││                ││││
││││││││  "a") of input = i   │   "a") of input = d    │││                ││││
││││││││  ┌───────────────┐   │    ┌───────────────┐   │││                ││││
││││││││  │set variable   │   │    │set variable   │   │││                ││││
││││││││  │"b" to variable│   │    │"b" to variable│   │││                ││││
││││││││  │"b" + 1        │   │    │"b - 1         │   │││                ││││
││││││││  └───────────────┘   │    └───────────────┘   │││                ││││
│││││││└──────────────────────┘                        │││                ││││
││││││└────────────────────────────────────────────────┘││                ││││
│││││└──────────────────────────────────────────────────┘│                ││││
││││└────────────────────────────────────────────────────┘                ││││
│││└──────────────────────────────────────────────────────────────────────┘│││
││└────────────────────────────────────────────────────────────────────────┘││
│└──────────────────────────────────────────────────────────────────────────┘│
│                                end program                                 │
└────────────────────────────────────────────────────────────────────────────┘