Minimized BF
Minimized BF is brainfuck with only 4 commands +>[]
, created by User:None1. Despite the fact that it has only 4 commands, it's still very powerful and almost Turing complete.
Memory
This esolang runs on a circular tape with 256 8-bit cells, overflow and underflow wraps around.
Commands
Minimized BF doesn't need the - command because 255 + commands is equivalent to one - command. It doesn't need the < command, because 255 > commands is equivalent to one < command.
I/O
Unlike brainfuck, this esolang has no commands for I/O, but it still has I/O. Before a program runs, the input is read from a file and into the tape clockwise as a C-Style string, starting from the pointer. After the program terminates, the tape starting from pointer's initial position clockwise as a C-Style string is written into the output file.
Example Programs
Hello World (unoptimized)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> ++++++++++++++++++++++++++++++++> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++> +++++++++++++++++++++++++++++++++>
Cat Program
Truth Machine
See the page Ruck for a Truth Machine in Minimized BF.
Implementations
The following Python script is an interpreter.
tape = [0] for i in range(0, 256): tape.append(0) pointer = 0 prgm = input('>mBF ') init = input('>i ') for i in range(0, len(init)): tape[i] = ord(init[i]) # Executes the program loop_table = {} loop_stack = [] for ip, inst in enumerate(prgm): if inst == "[": loop_stack.append(ip) elif inst == "]": loop_beginning_index = loop_stack.pop() loop_table[loop_beginning_index] = ip loop_table[ip] = loop_beginning_index inst = 0 while inst < len(prgm): if prgm[inst] == "+": tape[pointer] += 1 tape[pointer] %= 256 elif prgm[inst] == ">": pointer += 1 pointer %= 256 elif prgm[inst] == "[": if not tape[pointer]: inst = loop_table[inst] elif prgm[inst] == "]": if tape[pointer]: inst = loop_table[inst] else: pass inst += 1 pointer = 0 while tape[pointer]: print(chr(tape[pointer]), end="") pointer += 1