PureBrainz

From Esolang
Jump to navigation Jump to search

PureBrainz was inspired by brainfuck and tries to keep the basis, the spirit, while implementing proper tools to make programs. These tools include variables (anchor-points) in the memory-tape, multiple kinds of loops, that can either be hard-coded or depend on a memory cell, as well as functions that can take in pointer positions as arguments, and ternary operations (if/else), and finally, modules, which means you can create a package manager, and have libraries! You can too, import raw data from files.

Here is another explanation by the creator (hoping it doesn't break the rules of the wiki)

Commands

Programming Concept brainfuck syntax PureBrainz Standard Syntax
Increment + +
Decrement - -
Output . .
Input , ,
Move to the left < <
Move to the right > >
While loop [...] [...]
Repeat an action N times (hardcoded) ... ... ... ... ... 5(...)
Repeat an action N times (variable) +++++[...-] $counter_variable(...)
Repeat an action i times (where i is the loop_index) Keep count manually of the index %(...)
If cell != 0 [... break out somehow] ? {...}
If cell == 0 temp0[-]+temp1[-]>[<...x>->]<< ! {...}
Declare a Variable (set an Anchor) - Need to implement gliders etc. #variable_name
Overwrite a Variable (reset an Anchor) A true headache #variable_name
Go to an Anchor (Variable) +[->+]- (extremely limited) @variable_name
Declare a function Impossible #fun(*arg1*arg2*arg3){...}
Call a function Impossible :fun(*arg1*arg2*arg3)
Use current pointer as argument Impossible *here
Import a module Impossible |~ModuleName|
Import raw data from a file Impossible "|~ModuleName|"
Hardcode a string ++...>++++...>... "Hello World !"
Empty a cell [-] [-] or $(-) (better practise)
Addition (not destroying input) Need to copy cells to not destroy the input values @c $(-) $a(+) $b(+) or use ~Math Module

Modules

Multiple modules are also available to deal with different data types and problems, such as ~List, ~Math, ~Memory, ~Utils, ~Matrix, ~String, etc.

Example Programs

Print Function

This print function stops when it hits a -1, the conventional end of any data structure.

It is included in ~Util

#print(*s){ *s +[-.>+]- }

Print (the memory values, not the char)

#print(*s){ *s +[-48(+).48(-)>+]- }

Print, with a space in between (for another separator, replace 32 with the ord of the character you want)

#print(*s*tmp){ *tmp 32(+) *s +[-.#i*tmp.@i>+]- *tmp $(-) }

Fibonacci sequence

0(+)>1(+)> 23( #c<#b<#a @c $a(+) $b(+) > )

Powers of 2

|~Math| #base 2(+) @12 #index + @0 >< 11(#i @index+ @i > :pow(*base*index*here*11))

Make PureBrainz Better !

To get access to a python interpreter, or more info to create your own, please contact me ! Sinjoro (talk) 12:46, 14 April 2020 (UTC)

External resources