We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Banana

From Esolang
Jump to navigation Jump to search

Banana is an esoteric programming language where the program defines constraints for a string, then the interpreter picks a random string that fits the constraints and executes it as an Appel program.

Overview

The program is a newline-separated list of statements.

Statements
Statement Meaning
:n The target string is of length n.
n=m The symbol at index n is equal to the symbol at index m.
~x Statement x is false.

Appel

Appel is a language based on string-rewriting. The first character in the program is defined as the delimiter. The rest of the program is a delimiter-separated list of string pairs, with the exception of the last element, which is defined as the global string. The interpreter iterates over each pair of the list, it searches for the leftmost occurence of the left part of the pair in the global string, then replaces it with the right part of the pair and outputs the global string. Upon reaching the last element, it goes back to the start of the list. The program halts when there are no applicable pairs.

Examples

Looping counter

:7
0=2
0=5
~0=1
1=3
1=4
1=6

The program should result in a string with this structure:

ABABBAB

Which defines the following replacement rules:

B -> BB

With this global string:

B

Output:

B
BB
BBB
BBBB
BBBBB
...

(NOTE: The exact character used might not be B.)

Truth machine

:13
0=2
0=3
0=5
0=10
~1=0
1=4
1=11
6=8
~6=0
~6=1
~12=0
~12=1
~12=6
7=9
7=i

where i is the input.

corresponds to the following program

,2,,2,1?1?,20