Nandypants

From Esolang
Jump to: navigation, search

Nandypants is a dual-tape bitwise language that ended up, completely accidentally, being extremely similar to brainfuck. It was created by Nathan van Doorn.

There are two tapes, Tape a, and Tape b. These carry a bidirectionally unbounded number of cells, all bits initialized to 0. In this page, "a" shall refer to the bit pointed to in a, and "b" shall refer to the bit pointed to in b.


Commands

{               Moves the pointer of Tape a leftwards
}               Moves the pointer of Tape a rightwards
<               Moves the pointer of Tape b leftwards
>               Moves the pointer of Tape b rightwards
^               Stores a NAND b in a
v               Stores a NAND b in b
Any even number If this is the first occurence of that number, does nothing.
                Otherwise, if a NAND b equals 0, the program returns to the first occurrence of that number.
Any odd number  If this is the last occurrence of that number, does nothing.
                Otherwise, if a NAND b equals 1, the program advances to the last occurrence of that number.
\               Adds a to the output stream
/               sets b to the next bit from the input stream

Examples

Cat program

This is a "dirty" cat program, as, in addition to outputting the input, it also keeps a copy of it in both tapes. It does not handle EOF.

0}/>v>^<<^>^\}^0

Noryshorts

Noryshorts is a variation on Nandypants that uses NOR instead of NAND. NAND and NOR are both Universal Logic Gates, and so any of the sixteen binary logic gate can be synthesized using entirely NAND or NOR gates.

Turing Completeness

It is possible to translate any Boolfuck program into a Nandypants program, hence Nandypants is Turing Complete. Noryshorts probably is, too.

Boolfuck  Nandypants                    Noryshorts
+         ^                             >^<
,         >^>/^<<^                      ^>>/^<^<
;         \                             \
<         {                             {
>         }                             }
[         odd number even number        > odd number even number <
]         even number odd number        > even number odd number <

Note: this also needs a single "v" at the beginning of the program. The numbers in "[" should match the corresponding "]" but should otherwise be unique.