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.
πππππππππ
πππππππππ (read aloud: "three watermelons, three bananas, three pineapples"; informally Triple Salad) is an esoteric programming language written with exactly three symbols: π, π and π. Every instruction is a triplet of fruits: the first two fruits choose a verb, the third fruit chooses one of three stacks ("baskets") to act on.
Overview
Fruits are read as ternary digits: π = 0, π = 1, π = 2. All other characters are comments. The fruits are grouped into triplets from the start of the program, so the total number of fruits must be a multiple of 3.
A triplet abc means: verb number = 3Β·a + b (one of 9 verbs), basket = c.
Memory
There are three baskets, named after their fruit: A = π, B = π, C = π. Each basket is an unbounded stack of unbounded signed integers with an infinite supply of zeros underneath. The "top" of an empty basket is 0.
The baskets are arranged in a ring: π β π β π β π. next(X) is the following basket in the ring, prev(X) is the preceding one.
Instructions
X is the basket given by the third fruit of the triplet.
| Verb | Name | Effect | Triplets (X = A / B / C) |
|---|---|---|---|
| ππ | INC | top(X) += 1 | πππ / πππ / πππ |
| ππ | DEC | top(X) -= 1 | πππ / πππ / πππ |
| ππ | OUT | Print the Unicode character whose code point is top(X) (invalid values print U+FFFD). Does not pop. | πππ / πππ / πππ |
| ππ | OPEN | If top(X) = 0, jump past the matching CLOSE. | πππ / πππ / πππ |
| ππ | IN | Read one Unicode character and replace top(X) with its code point (0 on EOF). | πππ / πππ / πππ |
| ππ | CLOSE | If top(X) β 0, jump back to the instruction right after the matching OPEN. | πππ / πππ / πππ |
| ππ | MOVEβ | Pop X and push the value onto next(X). | πππ / πππ / πππ |
| ππ | MOVEβ | Pop X and push the value onto prev(X). | πππ / πππ / πππ |
| ππ | COPY | Push a copy of top(X) onto next(X). | πππ / πππ / πππ |
Mnemonic: π handles numbers (and "spits seeds", i.e. output), π bends the control flow and bites input, π moves things between baskets.
Notes
- OPEN and CLOSE are matched like brackets. An unmatched one is a syntax error.
- The baskets named by an OPEN and its CLOSE need not be the same. Since CLOSE jumps to just after OPEN, the OPEN test is only performed when the loop is entered.
- Popping an empty basket yields 0 (no error). INC, DEC and IN on an empty basket first create a zero.
- Integers never wrap around.
The name
The name is itself a valid program: πππ is INC A, πππ is IN B, πππ is COPY C (onto A). It has no visible output.
Computational class
The language is Turing complete by a direct translation from Brainfuck. The tape is stored in two baskets: the current cell is top(A), cells to the left lie beneath it in A, and cells to the right are in B (nearest on top). Basket C is left over as free scratch space.
| Brainfuck | πππ | Brainfuck | πππ |
|---|---|---|---|
+ |
πππ | [ |
πππ |
- |
πππ | ] |
πππ |
. |
πππ | > |
πππ |
, |
πππ | < |
πππ |
(Cells do not wrap, so Brainfuck programs that rely on 8-bit wrap-around need adapting.)
Examples
Hello, World!
Mechanical translation of the well-known Brainfuck program (prints "Hello World!" and a newline). Line breaks are only for readability.
ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππππππππππππππππππππ ππππππ
Cat
Copies input to output (until EOF or a NUL character).
πππ # IN A πππ # OPEN A πππ # OUT A πππ # IN A πππ # CLOSE A
Reverse
Reverses its input, using basket B as a stack.
πππ # IN A read first character πππ # OPEN A while it is not 0: πππ # MOVEβ A push it onto B πππ # IN A read the next character πππ # CLOSE A πππ # OPEN B while top(B) is not 0: πππ # OUT B print it πππ # MOVEβ B pop it (into C) πππ # CLOSE B
For example, the input abc ΠΡΠΈΠ²Π΅Ρ produces ΡΠ΅Π²ΠΈΡΠ cba.
Implementation
A reference interpreter in Python 3 (run as python3 fruit.py program.txt):
import sys
FRUITS = {"π": 0, "π": 1, "π": 2}
def parse(src):
f = [FRUITS[c] for c in src if c in FRUITS]
if len(f) % 3:
raise SyntaxError("fruit count is not a multiple of 3")
prog = [(f[i] * 3 + f[i + 1], f[i + 2]) for i in range(0, len(f), 3)]
jump, stack = {}, []
for i, (verb, _) in enumerate(prog):
if verb == 3:
stack.append(i)
elif verb == 5:
if not stack:
raise SyntaxError("unmatched close")
j = stack.pop()
jump[i], jump[j] = j, i
if stack:
raise SyntaxError("unmatched open")
return prog, jump
def run(src, stdin=sys.stdin, stdout=sys.stdout):
prog, jump = parse(src)
basket = ([], [], [])
def top(x):
return basket[x][-1] if basket[x] else 0
def put(x, v):
if basket[x]:
basket[x][-1] = v
else:
basket[x].append(v)
def pop(x):
return basket[x].pop() if basket[x] else 0
pc = 0
while pc < len(prog):
verb, x = prog[pc]
if verb == 0:
put(x, top(x) + 1)
elif verb == 1:
put(x, top(x) - 1)
elif verb == 2:
v = top(x)
ok = 0 <= v <= 0x10FFFF and not 0xD800 <= v <= 0xDFFF
stdout.write(chr(v) if ok else "\uFFFD")
elif verb == 3:
if top(x) == 0:
pc = jump[pc]
elif verb == 4:
c = stdin.read(1)
put(x, ord(c) if c else 0)
elif verb == 5:
if top(x) != 0:
pc = jump[pc]
elif verb == 6:
basket[(x + 1) % 3].append(pop(x))
elif verb == 7:
basket[(x - 1) % 3].append(pop(x))
elif verb == 8:
basket[(x + 1) % 3].append(top(x))
pc += 1
if __name__ == "__main__":
run(open(sys.argv[1], encoding="utf-8").read())