NestFuck

From Esolang
Jump to navigation Jump to search

NestFuck is a language that uses pairs of nested brackets to execute brainfuck instructions. It uses 3 characters as follows:

Character Function
( Increase nest level
) Decrease nest level
. Execute instruction

Any character other than these is ignored and considered a comment Each nest level 0-7 maps to a brainfuck instruction:

Brainfuck command Nest level Description
> 0 Move pointer to the right
< 1 Move pointer to the left
+ 2 Increment the memory cell under the pointer
- 3 Decrement the memory cell under the pointer
. 4 Output the character signified by the cell under the pointer
, 5 Input a character and store it in the cell under the pointer
[ 6 Jump past the matching ]/7 if the memory cell under the pointer is 0
] 7 Jump back to the matching [/6 if the memory cell under the pointer is nonzero


Brackets must be balanced in the program. There are two ways of programming in NestFuck. Simple is where you close all brackets after every command, e.g. ((.................)) ((((.)))). Compact is where you only open and close brackets as necessary, making the program a lot smaller, but very difficult to write and read, e.g. ((.................((.))))

Examples

Hello World!:

Simple:

   ((..... ...))((((((.)))))).((....))((((((.)))))).((..)).((...)).((...)).((.))(....) (((.)))(((((((.))))))).((.)).((.)).(((.)))..((.))((((((.)))))) (.) (((((((.)))))))(.)(((.)))(((((((.)))))))..((((.)))).(((...)))((((.))))((.......))((((..))))((...))((((.))))..((((.))))(.)(((.)))((((.))))(.)((((.))))((...))((((.))))(((.....)))(((.)))((((.))))(((........)))((((.))))..((.))((((.)))).((..))((((.))))

Compact:

   ((........((((.)))))).((....((((.)))))).((..)).((...)).((...)).((.)....((.((((.))))))).((.)).((.)).(((.)))..((.((((.))))).((((((.)))))).((.((((.)))))))..((((.)))).(((...(.)).......((..))...((.))))..((((.))).((.(.))).(((.))...((.)......(.)........(.))))..((.((.)))).((.((.))))

As you can see, compact is horrible to read.

Interpreters

An interpreter can be found in the GitHub repository for NestFuck, along with extended information