LogicGates

From Esolang
Jump to navigation Jump to search

LogicGates is an esolang invented by User:None1.

Memory

It uses a bit accmulator, an unbounded bit tape and a pointer. All bits are initially 0.

Commands

  • </>: Move the pointer to the left/right.
  • [CODE]: While accmulator isn't 0, do CODE.
  • Logic gates represented by uppercase and lowercase letters.
Gate (0,0) (0,1) (1,0) (1,1)
A    0     0     0     0
B    0     0     0     1
C    0     0     1     0
D    0     0     1     1
E    0     1     0     0
F    0     1     0     1
G    0     1     1     0
H    0     1     1     1
J    1     0     0     0
K    1     0     0     1
L    1     0     1     0
M    1     0     1     1
N    1     1     0     0
P    1     1     0     1
Q    1     1     1     0
R    1     1     1     1

The first operand is the accumulator and the second is the current cell. Uppercase letters store result in the accmulator, but their corresponding lowercase letters store in the current cell.

  • . (optional): Output bit in the accumulator.
  • , (optional): Input a bit and store in the accumulator.
  • (STUFF) (optional): Comment, can be nested.
  • Other commands are ignored.

Examples

Bit Inversion

,N.

Bit A+B

,d,G.

Unary XKCD Random Number

R....

Binary XKCD Random Number

R.A..

Looping counter

R[[>F]r[.<F]R]

Prints:

10110111011110...

Basic logic gates

AND: B/b
OR: H/h
XOR: G/g
NOT (accumulator): N/n
NOT (current cell): L/l
NAND: Q/q
NOR: J/j

Computational class

All commands in boolfuck are available in LogicGates, except for +, which can be implemented using the logic gates, so this esolang is Turing complete.