Neutrino
A golfing language of chains. Each function takes the value so far, as in Jelly, but in the old DOS code page.
Turing complete: unknown · ●●● hard
Tested with 9 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
The reference script names its author as HyperNeutrino and says it borrows from Jelly and from Enlist, an earlier language of the same author that Neutrino was meant to replace. A program is a row of functions with no stack and no variables. A nilad gives a value, and each monad or dyad after it works on the value so far. R+/ is the sum from 1 to n; R makes the range, / turns the + before it into a fold.
Read the story
The code page is the 256 characters of the IBM PC, smileys and box drawing included, so ÷ is a division, √ a square root and └ a floor. Most letters were never filled in. They are nilads that give 0, and the script still marks them TODO.
The machine
Numbers are exact. The script hands every number to sympy, so 7÷2 is 7/2, not 3.5.
| Code | Does |
|---|---|
12 - .5 3. 2î3 | Numbers; - alone is -1, 3. is 3.5, 2î3 is 2000 |
"text' 'c | A list of characters, one character |
1,2,3 [1,[2]] | Lists |
+ _ * ÷ : % ⁿ | Add, subtract, multiply, divide, divide whole, remainder, power |
R Σ § F ↑ | Range from 1, sum, reverse, flatten, sort |
/ \ ○ @ | Fold from the left or right, table, swap the arguments |
☺ ☻ | The first and second argument |
At the end the value is printed. A list of characters comes out as text, and True as 1.
Example
A string starts with " and ends with ', which is why the first line needs the shell's quote juggling.
A string starts with " and ends with ', which is why the first line needs the shell's quote juggling. + between a list and a number adds the number to each item.
The reference reads its arguments from the command line; each line of the input is one argument. This implementation is a subset. Python's eval, randomness and sympy's symbolic results stop the run with a reason.
Patterns it teaches
- Code golf: chains need no variables, and a one-byte operator such as
/turns any function into a loop.
Try this
- Print the product of the numbers 1 to 6.
- Print the squares of 1 to 10 as a list.
- Hard: print the average of a list given as the argument.
Further
- The reference interpreter, github.com/alexander-liao/neutrino, one Python 3 script with
builtins.md - Related: Jelly
See also
Also in Golfing
Write your own in Run Convert a program from Neutrino
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: neutrino.
Command line
shib run neutrino -e 'R' --input '5'shib manual neutrinoSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/neutrino.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language