From Esolang
Jump to: navigation, search

Elog is a stackbased language that can be used to model logical circuits.


An Elog program takes a bitstring as input (for example "10101") and can output another bitstring. You can use a single character for a variable. The first variable that appears in the program gets bound to the first input bit, the second variable gets bound to the second input bit and so on.


The commands at the moment:
' NOT gate
& AND gate
| OR gate
^ XOR gate

. dup top stack item
0 push 0
1 push 1
: pop bit and assign to next variable
; end program and print all variables (or 0 and 1) after ;


The following program will take 4 input bits and will output 1 bit, 1 if the number is a prime else 0. Notice how at the end of the program the result bit is assigned to z (:z) and how z is the only variable after ;. Als notice how a, b, c and d are the first variables used, this will ensure that a, b, c and d will be bound to the right input bits.


The following program will take 3 input bits and will multiply it by 2.


This simulates a 2 bit multiplexer, notice how the 3 variables appear before the actual program, this to ensure the proper input bits are bound to the proper variables.

abs as'&bs&|:z;z


Java interpreter
C# interpreter