Logique
Logique is an esoteric programming language developed by Ettore Marmo in 2014. It is a low-level language based on simple binary logic where you can only use either NAND or NOR gates.
Syntax Overview
Function Definition
Using only one of these two gates one can define all the other logical functions! In logique you can easily test this:
NOT(x) = NAND(x, x) AND(x, y) = NOT(NAND(x, y))
and so on.
Datatypes
The only datatype in Logique are the two boolean values 0 and 1, they can be concatenated with the infix :
or simply by juxtaposition. For instance
0110110 == 0 : 1 : 1 : 0 : 1 : 1 : 0
You can also create functions that return a list of 0s and 1s
REVERSE(x, y) = NOT(x) : NOT(y)
Function Call
Every function can accept as arguments only single binary values, meaning that functions like NOT(x)
will only accept 0 or 1 and not any list of those. However functions with more than one argument can be called using a list of values.
NAND(1, 0) == NAND(10) FUNC(1, 1, 0, 0) == FUNC(1, 100) == FUNC(11, 00) == FUNC(110, 0) == FUNC(1100)
this comes quite in handy when simulating numeric operations.
I/O and Utilities
Logique comes with the command out
that prints whatever function is after it, and read(n)
that reads an input in binary form long n digits (n is written in base 10 though). For instance:
out NAND(read(2)) // Reads a 2-digit binary number
Also the function char(x)
reads an 8-digit binary input and outputs the corresponding character
(NOTE: not fully implemented yet!)
The command table
outputs the truth table for whatever function that comes after it.
table NAND // outputs: x y NAND(x, y) 0 0 1 0 1 1 1 0 1 1 1 0
File Formats and Modules
Logique accepts two types of file format: .nand
and .nor
, in the first you start with the predefined function NAND, in the other with NOR. With the command import
you can load all the function definitions and calls from another file, to avoid ambiguities the module imported must have the same file extension.