NTFJ

From Esolang
Jump to navigation Jump to search
NTFJ
Paradigm(s) imperative
Designed by Conor O'Brien
Appeared in 2016
Memory system stack-based
Computational class Unknown computational class
Major implementations Original, C implementation, Online interpreter
File extension(s) .ntfj

NTFJ is a minimalist language created by User:Conor O'Brien. It originally had four commands: NAND, TRUE, FALSE, JUMP. These were the basis for its name. The language operates on a stack by manipulating bits and integers.

NTFJ has 13 commands:

Command Name Explanation
| NAND Pops two values A and B and pushes A NAND B; if A and B are both bits, it pushes 1-(A&B); otherwise, it pushes 255-(A&B).
~ FALSE Pushes 0 to the stack.
# TRUE Pushes 1 to the stack.
^ JUMP Pops n, jumps to the nth command.
@ BYTE Pops eight values V1...V8 and pushes the number V1*(2^7) + ... + V8*(2^0) OR, if V1 > 1, pushes the bits in that number.
( PEEK If the top value of the stack is 0, jumps to the next ).
) ENDPEEK Closes a ( command.
$ DROP Drops the top value of the stack.
: DUP Duplicates the top value of the stack
/ LENGTH Pushes the number of items in the stack.
{ ROTATE Pops N; shifts the stack and pushes it to the front N times.
} REV ROTATE Pops N; pops from the stack and unshifts it N times.
` DEBUG Displays the program's state.

The normal logical operators are representable in NTFJ:

  • Logical negation is :|: (A NAND A) = NOT (A AND A) = NOT A.
  • Logical conjunction (and) is |:|: NOT (A NAND B) = NOT NOT (A AND B) = A AND B.
  • Logical disjunction (or) is :|#}:|#{|. #} and #{ simply poke around the stack and focus on B and A respectively. (NOT A) NAND (NOT B) = NOT ((NOT A) AND (NOT B)) = A OR B.

Computation class

It is thought that NTFJ is Turing Complete, as it bears a remarkable resemblance to Etre.

Minification

One can begin to remove some commands from NTFJ. The following commands are superfluous ` *.

# is equivalent to ~~|, or 0 NAND 0.

$ is equivalent to ~|:||, which converts the top of the stack into 1, then negates it into 0, then NAND's the resulting value. A NAND 1 = A, so the top value is ignored.

Thus, the following 9 commands are left:

| ~ ^ @ ( ) : { }

@ is needed to jump, and : is needed to produce more values on the stack.