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.

PNID

From Esolang
Jump to navigation Jump to search
PNID
Paradigm(s) imperative
Designed by Lealcy Tardelli Belegante
Appeared in 2017
Memory system tape-based
Dimensions one-dimensional
Computational class Turing complete
Major implementations C# Interpreter
Influenced by Brainfuck

PNID means "Previous, Next, Increment, Decrement" and is a superset of Brainfuck.

Language overview

As Brainfuck, PNID operates on an array of memory cells, also referred to as the tape, each initially set to zero. There is a pointer, initially pointing to the first memory cell. The commands are:

Command Description
p Move the pointer one cell to the left. if the pointer gets below zero, then it cycles to the last position of the memory
n Move the pointer one cell to the right. if the pointer gets above the available memory, then it becomes zero
i Increment the memory cell under the pointer
d Decrement the memory cell under the pointer
w Output the character signified by the cell at the pointer
r Input a character and store it in the cell at the pointer
() Repeat the code inside the parenthesis until the appointed value becomes zero
$ Read everything from the default input to the memory until it find a new line
'c Write the character c to the appointed cell
"" Write everything between the double quotes to the memory
; Write the numeric value of the appointed cell to the default output
^ Jump the pointer back to the first cell
j Jump the code to the position contained in the current cell
c Clear all the memory
% If the current cell has a value greater than zero, generates a random number between zero and that value, otherwise generates a number between zero and INT_MAX
\n Write the number n to the current cell

For compatibility with brainfuck, the commands <>+-[] are also accepted instead of pnid().

Interpreter

The Interpreter accept the following commands:

Command Description
h Show an informative help.
q Exit the interpreter

If the execution enters a loop or a deadlock, you can break out of it by pressing ESC.

Examples

Hello, World!

This program prints out the words Hello, World!:

"Hello, World!"^(.n)

Hello, name!

This program asks for your name, then greats you:

"What's your name? "^(wn)c^$n"Hello, "p(p)n(wn)^(wn)'!w

Coin toss

Every time you executes this program, it will give heads or tails:

i%^(n"heads"ppppp(wn))^d(c^"tails"^(wn))

Memory and wrapping

In the current implementation of the C# interpreter, the memory has UINT16_MAX cells, each of has (sizeof)int size.

Related languages

  • Brainfuck.
  • pbrain is a brainfuck extension that supports procedures.
  • cbrain is a derivative of pbrain as implemented in pbrain.c, adding integers and operators.
  • RUM stands for "bRainfUck iMproved." and adds procedures, strings and repetition.
  • Toadskin is a brainfuck variant that supports procedures, but uses a stack instead of a tape.
  • Brainfork adds a Y command to fork the current thread.
  • Fm edits a string on alphabet {0,1,...,m-1} (m >= 2).
  • FRAK assemble instructions to brainfuck code.
  • FukYorBrane and BF Joust pit two Brainfuck-like programs against each other, as in Core War (see Redcode).
  • Smallfuck operates only on bits and has no input- or output-commands.
  • Spoon uses a Huffman coded set of instructions corresponding to Brainfuck's commands.
  • BrainDuino BF port on Arduino HW platform (based on Atmel's ATMega). Extended by two special I/O operations and special overflow protection.
  • Puzzlang turns every program into an exercise in patience and logic puzzle skills. The lone X operator becomes any of brainfuck's instructions, depending on the surrounding characters.
  • Alarm Clock Radio throws away the instructions to decrement the memory pointer or memory value.
  • Portal and Portal 2 allows code-level pointer manipulation and theoretically implements the Wang-B Machine.
  • tbf is a language that can be compiled to Brainfuck. It includes variables, strings, macros and improved loops.
  • Grin adds more efficient arithmetic functions to Brainfuck.
  • tinyBF and its variant RISBF are brainfuck equivalents with only 4 opcodes.

Some other funny variants:

  • Ook! works exactly like brainfuck, except the syntax is in Orangutan.
  • Blub is the same for fish.
  • Matisse uses colors to merge brainfuck codes and program comments.
  • Brainloller has the same commands as brainfuck, except they're read from a png image.
  • COW is like Ook!, except with a bovine syntax.
  • Pi obfuscates Brainfuck instructions in random errors in pi digits.

Some languages inspired by brainfuck, but with more major differences:

  • Aura requires data to be stored in the code space.
  • PATH and SNUSP attempt to combine brainfuck with Befunge.
  • Wierd arose out of an earlier attempt to combine brainfuck with Befunge.

External resources