User:Lobstopus/Neurode
This language was inspired by Befunge, RUBE and Wierd.
Concepts
There exists a board of NI size. In (inside) the board are "cells", which usually are operations and usually occupy a single cell. On (above) this board exist signals, which have signed integer values. Each execution step, each signal is fed from one operation into another, acting as input for that operation. Operations can have many inputs and many outputs; some operations can also link to other operations. The default behaviour for outputting to an occupied cell is to wait until it is free. Two operations which are not ^>v< cannot be adjacent; however, there are special "marker" characters (such as |) which can. The program halts when there are no signals, or when a @ is triggered.
Quick command reference
INSERT TABLE HERE
Basic structure
Here is a simple program:
i>{4}>v p>ao i>{7}>^
Here is what each operation does:
- On program start, each i produces a signal with a value of 1.
- The arrows (>^<v) move signals around.
- {} hold numbers; when triggered, it produces a signal with the contents of the {} as its value.
- p merges signals by adding their values; if only one signal reaches it, it is simply passed across.
- On input, o prints the ASCII character represented by the signal's value. The a marks the o, causing it to print integers. This also destroys the signal, ending the program.
Thus, this program prints "11".
Here is the most intuitive Hello World program:
i>{H}a>o i>{e}a>>o i>{l}a>>>o i>{l}a>>>>o i>{o}a>>>>>o i>{,}a>>>>>>o i>{ }a>>>>>>>o i>{w}a>>>>>>>>o i>{o}a>>>>>>>>>o i>{r}a>>>>>>>>>>o i>{l}a>>>>>>>>>>>o i>{d}a>>>>>>>>>>>>o i>{!}a>>>>>>>>>>>>>o i>{10}>>>>>>>>>>>>>>>o
It can be seen that the "a" marker can also be applied to a {}; this modifies its behaviour so that when triggered, it enters a loop of producing signals for each character inside it.
More complex structure
The above Hello World program would be written better as:
i>>>>>>>>>>>>>>>>>v v<a{Hello, world!}< >o
Producing signals for each character in the {} ultimately works similarly to the stack-based operations of Befunge. However, it is difficult to decide when to print the newline, as the time to print it depends on the length of the string. One way to solve this is to print a newline when the character being printed is the last character ("!" = 33):
i>>>>>>>>>>>>>>>>>v v<a{Hello, world!}< x>o v >>>>>>>>>v v<<<{33}< s-s ^ ^ v v ^ i v x>^ v v v n v v >p< v l>f>{10}>o
This program introduces several new operations:
- s is the synchronising operation: it connects to another s (with - or |) and passes inputs to outputs simultaneously.
- n flips the sign of a signal's value (x = -x)
- l logically negates a signal's value (x = {1: x = 0; 0}).
- f (Filter) destroys a signal if its value is 0.
This program also contains a Breeder construct, to output [33]s on demand (when a Synchronise is triggered).
Now that we can make a Hello World program, let us attempt to construct a Cat program. Here is one:
i>v<<<<x<< v v ^ >,>f>#>^ v a o
This, again, introduces new operations:
- # and x allow the crossing and splitting of signals, respectively.
- When triggered, , gets a value from the user and creates a new signal with that value.
This version loops until EOF = 0 is inputted by the user, at which the signal is deleted by the Filter.
Useful program parts
Test if two values are equal
>s>n>v | p>l> >s>>>^
Outputs the logical value of (lower input - upper input = 0).
Add a value to a signal
>>>>>>>s>p>> | ^ i>{1}>>s>x ^ v ^<<<
Simply replace the {1} with a different value and change the spacing.
Natural number breeder
v< v^ >{ ,}a>o i>x>s>v ^ | p>x>ao i>{0}>s>^ v ^<<<<
This is composed of an accumulator (starting at 0) and a 1-breeder.
Destroy a signal if it has a particular value
v< i>{25}>x>v v^ ^v s>n>v i>{25}>x>s>v ^< | v | p>v >>>>>>>>>s>v p>f>>>>>>>>>s>^ >> >>^
Notice that there are two n-breeders. 'If the other breeder's output was simply copied forward, the Sync would limit the number of 0s that could ever be received.
Find the minimum of two values
For this, I will introduce two new operations:
- m is like p, but with multiplication.
- c (Cut-off) sets negative values to 0.
Then we can do this:
i>{37}>x>>>>>>>>>>s>v v | m>v v >l>l>s>^ >s>v n>p>v ^ | p>ao ^ c>x>l>s>v >s>^ ^ | m>>^ i>{42}>>>x>>>>>>>s>^
Here's how this works:
- -(37) + 42 is calculated. (5)
- If it's negative, it's set to 0. (5)
- If it's greater than 1, it's set to 1. (1)
- 37 is multiplied by it, and 42 is multiplied by its inverse. (37*1=37;42*0=0)
- These are then added together. (37+0=37)
Bottles of Beer program
Here is an example of how not to output text:
i>{99}>>v ^ x>ao ^ v ^ x>{ ,llaw eht no reeb fo selttob }a>o ^ v ^ x>ao ^ v ^ x>{.reeb fo selttob }a>o ^ v ^ x>{10}>o ^ v ^ x>{ ,dnuor ti ssap ,nwod eno ekaT} ^ v ^ v v<n< ^ s-s ^ ^ v v i ^ >p< ^ v ^ v< ^ x>ao ^ v ^ x>{.llaw eht no reeb fo selttob }a>o ^ v ^ x>f>@ ^ v ^ x>>{10}>o ^ v ^ ^<x>^
Since the output isn't synced, this actually prints an illegible mess which begins:
99 b9o9ttlbeost tolfe sb eoefr boene9 r8t.he wbaoltlt
Here is a version which is better, but still not optimal:
i>{99}>>>x>>>x>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>x>>>x>>>>>>>>>>>>>>>>>>>>>>>v ^ v v v v v ^ >ao >{ ,llaw eht no reeb fo selttob }a>o >ao >{.reeb fo selttob }a>o x>{10}>o ^ v ^ v<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ^ >x>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>s>>>v >>x>>>x>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>v ^ v | p>^ v v v ^ >{ ,dnuor ti ssap ,nwod eno ekaT}a>o i>n>s>x>^ >ao >{.llaw eht no reeb fo selttob }a>o v ^ ^ v v ^ 99 Bottles of Beer program ^<<< Th!s space for rent o<{10}<<<< @<f v ^ ^ ^ ^ v ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<x<x<<<x<<
Other things of mention
- How should comments work, if at all?
- How pointful or pointless would it be to create a bitwise version? How equivalent would it be?
- How would a version with different signal data types (other that integer) work?
- How can one store a signal and release it on demand?
- What about that BF interpreter?