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.

NAND

From Esolang
Jump to navigation Jump to search
This article is not detailed enough and needs to be expanded. Please help us by adding some more information.

NAND is a logic gates-based esolang. Its goal is to create the most minimalistic yet powerful boolean logic-based language. Why NAND? Because it is possible to create all other logic gates using only it.

Commands

Command Description
ENE1N1 Connect element EN to element E1N1
aEN Flip input N (0 to 1, 1 to 0) or print output N
(N Jump past the matching ) if output N is 0
N) Jump back to the matching ( if output N is 1
Operator Description Possible values
E Element i o n
N Serial number of element Any non-negative integer

All symbols, except for iona()1234567890, are ignored and can be used as comments (so it makes sense to write all comments in the UPPERCASE). Dots outside of construction ENE1N1, numbers without ion() near them and brackets without numbers near them are ignored.

Every program has infinite inputs, outputs and NANDs, but they are only created when referred to in the code (e.g. in code ai0i1o0 input 1 will be created when connected to output 0) and deleted when unused (e.g. in code i0n0i1n0i2n0i0o0 input 0 is deleted when input 2 replaces it and reappears when connected to output 0).

Every element can be powered by only one element (NAND has two inputs each of which can be powered only by one element), but can power infinitely many other (NAND can power itself), so if you will try to connect input/NAND to NAND/output that is already powered by something, previous connection will be deleted.

Binary form

Since this language uses only 16 symbols, all of them can be represented by four bits.

Symbol Binary
0 0000
1 1000
2 0100
3 0010
4 0001
5 1100
6 1010
7 1001
8 0110
9 0101
i 0011
o 0111
n 1011
a 1101
( 1110
) 1111

After this, 1 can be added in the start of the converted program and the number can be translated into other number bases.

For example, this is full adder program in bases 2 (without 1 in the beginning) and 10:

00110000101100000011100010110000001100001011100010110000101110000011100010110100101100001011010010111000101100101011010010110010101100101011000100110100101100011011001010111100101100011011110010110001101110100011010010111010101111001011100110111010101110011011000110110110001101001011011010111001011100001011011001111000
2542228115714895053039659283972548987925626007752457995063325209452828102926193597870763672647288

Computational class

Single Boolean circuits are combinational logic models, but together they can form finite-state automatons, so this language is probably a FSA.

Examples

Prints output values of NAND truth table:

i0n0
i1n0
n0o0
p0
f0
p0
ai1
ao0
ai2
ao0
ai1
ao0

NOT:

i0n0
i0n0
n0o0

AND:

i0n0
i1n0
n0n1
n0n1
n1o0

OR:

i0n0
i0n0
i1n1
i1n1
n0n2
n1n2
n2o0

NOR:

i0n0
i0n0
i1n1
i1n1
n0n2
n1n2
n2n3
n2n3
n3o0

XOR:

i0n0i0n0
i1n1i1n1
i0n2i1n2
i0n3i1n3
n2n4n3n4
n4n5n4n5
n5o0

XNOR:

i0n0i0n0
i1n1i1n1
i0n2i1n2
i0n3i1n3
n2n4n3n4
n4o0

Full adder:

i0n0
i1n0
i0n1
n0n1
i1n2
n0n2
n1n3
n2n3
n3n4
i2n4
n3n5
n4n5
n4n6
i2n6
n5n7
n6n7
n4n8
i2n8
n7o0
n8o1

Print 8-bit ASCII values of Hello, World!:

ai1
i0o0i0o2i0o3i0o5i0o6i0o7i0o8i0o11i0o12i0o14i0o16i0o19i0o22i0o23i0o24i0o27i0o30i0o31
i0o32i0o35i0o40i0o41i0o43i0o46i0o47i0o48i0o49i0o51i0o52i0o53i0o54i0o55i0o56i0o60i0o64
i0o67i0o72i0o76i0o77i0o79i0o80i0o83i0o86i0o87i0o88i0o91i0o92i0o94i0o95i0o96i0o97i0o99i0o100i0o101i0o102
i1o1i1o4i1o9i1o10i1o13i1o15i1o17i1o18i1o20i1o21i1o25i1o26i1o28i1o29i1o33i1o34i1o36i1o37i1o38i1o39i1o42
i1o44i1o45i1o50i1o57i1o58i1o59i1o61i1o62i1o63i1o65i1o66i1o68i1o69i1o70i1o71i1o73i1o74i1o75i1o78i1o81i1o82i1o84i1o85i1o89i1o90i1o93i1o98i1o103
ao0ao1ao2ao3ao4ao5ao6ao7ao8ao9ao10ao11ao12ao13ao14ao15ao16ao17ao18ao19ao20ao21ao22ao23ao24ao25ao26ao27ao28ao29ao30ao31ao32ao33ao34ao35ao36ao37ao38ao39ao40ao41ao42
ao43ao44ao45ao46ao47ao48ao49ao50ao51ao52ao53ao54ao55ao56ao57ao58ao59ao60ao61ao62ao63ao64ao65ao66ao67ao68ao69ao70ao71ao72ao73ao74ao75ao76ao77ao78ao79ao80ao81ao82ao83ao84ao85ao86ao87ao88ao89ao90ao91ao92ao93ao94ao95ao96ao97ao98ao99ao100ao101ao102ao103