User:Kiken/Construction Site/Descriptions/Current
This page is a draft for my esolang, Current. This page is a draft for my esolang, Current.
Current is a two-dimensional esoteric programming language created by User:kiken based around electric currents.
Overview and syntax
Current consists of wires, which are represented with the characters —
and
(Bends in the wire are represented with !
/
and \
. These wires can carry electric voltages from 0 ~ 257 volts, any higher and the voltage will be automatically reduced to 257 volts. If the wires do not form a circuit, then program halts.
A cross-over wire is written like this:
+
A split is like this:
^—
or:
v—
or:
|>
or:
<|
A turn:
—\ |
Or:
| —/
etc.
A turn can merge into a wire, like:
————— ——/
Other syntactic elements in Current include:
- Battery (provides a voltage of 100 volts
| | | |___| |
or
___ — — ———
- Resistor
Does nothing if the voltage specified if greater than the wire's voltage.
—| voltage |—
- Capacitor
—( max voltage )—
- Transistor
Input is left, middle is control, right is output
||| | | |___|
- Integrated Circuit
Up to two inputs, one output. The box can be any size depending on the amount of code stored in it. The circuit can then be executed using the circuit name.
Here is an example with one input:
|_________ circuit name [ ] [ code ] [____|_____] |
With two:
||_______ circuit name [ ] [ code ] [____|____] |
How to execute with one input:
________ —| name |— ————————
With two inputs:
__________ —| name |— —|__________|
- Transformer
—[ voltage ]—
_ —|_|— |_|— |_|— |_|— |_|— |_|— |_|— |_|—
- Output
_ —|_|—
Addition (Todo)
Addition in Current is something hard to do, as there is no logic gates. So, we have to implement some ourselves.
Step one (creating the half-adder)
We need to create a half-adder to add bits, to make our lives easier later. We can do this by feeding the two inputs into an XOR gate and an AND gate. We can do this with:
in bit 1 ———v—————XOR—— output | /——/ \———+——\ in bit 2 ———————^—AND—— carry
But remember, logic gates aren't implemented either.
Logic gates
We need for an XOR and AND gate. For that, we need a NAND gate. For the NAND, we need a NOT too. The NOT gate can easily be implemented like this:
input ———————\ /——— output | | /———|||——^——source of voltage | | | | |___| \——————————source of voltage
And here is the AND gate:
input 2 ————————\ input ————\ | /———— output | | | | | | /————|||———|||———^—— source of voltage | | | | | | |___| |___| | \————— source of voltage
Now we can merge the two into an NAND and put it in an integrated circuit:
||_____________________________________________________ NAND [|| ] [\+—————————————\ ] [ \———————\ | /———————————————————————————\ ] [ | | | | ] [ | | | | ] [ /————|||———|||———/ | ] [ | | | | | | ] [ | |___| |___| | ] [ | | ] [ | | ] [ |/———————————————————————————————————————————/ ] [ |\———————\ /——————————\ ] [ | | | | ] [ | /———|||——^———————\ | ] [ | | | | | | ] [ | | |___| | | ] [ | | ___ | | ] [ | \—————————— ———/ | ] [ | / ——— | ] [ \———————————/ | ] [___________________________|____________________________] |
With the NAND gate, we can now create an XOR gate to use in the half-adder.
||________________________________________________________________________ XOR [|| [||> ______ [||/—————————————————————————| NAND |—— [||| /———————|______| [||| ______ | [\+^v—| NAND |————v——+— [ | \—|______| \——+——\ [ | | | [ | ______ | | [ >——v—| NAND |——————/ | ______ [ | \—|______| \————| NAND |— [ | /————|______| [ | | [ \—————————————————————/ [ [__Reading from STDIN (Todo)
In Current, reading from STDIN is quite complicated. The Input gets input as a single char and outputs it in eight bits, where any voltage under 1 is a 0. There is obviously no implementation of any sort of string handling nor bit handling, so we'll have to implement one ourselves.The first step: byte handling
We want forLogic gates
OR gate
— —