User:CreeperBomb/Idea
Description
All operators have a default arity, which can be changed with placing a number of dots before it - one dot per extra input. Multiple dots can be shortened to ".#" for a numeric digit "#" (note: 0 means 10 dots, 1 means 11, and 2 means 12, for compactness). Also, if there is a number between dots, then the dots can themselves change their arity (e.g. .2.99+ is 99-ary addition). Instructions are placed before their inputs. The instructions are:
Symbol | Name/description | Default arity |
---|---|---|
+ |
Addition | 2 |
- |
Subtraction | 2 (higher arity = left-to-right) |
_ |
Negation | 1 |
* |
Multiplication | 2 |
/ |
Division | 2 (higher arity = left-to-right) |
d |
Reciprocal | 1 |
% |
Modulo | 2 (higher arity = left-to-right) |
? |
If greater than 0 then do second input | 2 (higher arity = more instructions in second input) |
! |
If greater than 0 then skip second input | 2 (higher arity = more instructions in second input) |
= |
Declaration of equality; if arity is placed on the left input, then it is a function. If other instructions, like + , are placed afterward & it isn't valid code, then =[instruction]ab… is interpreted as =a[instruction]ab… . Varibles/functions default to 0 when undeclared |
2 (higher arity = more instructions in second input) |
T |
Equality test; 1 if true and 0 if false | 2 (higher arity = all have to equal) |
F |
Inequality test; 1 if true and 0 if false | 2 (higher arity = all have to be unequal) |
G |
Greater than test; 1 if true and 0 if false | 2 (higher arity = all are in decreasing sequence) |
L |
Less than test; 1 if true and 0 if false | 2 (higher arity = all are in increasing seqence) |
g |
Greater than or equal to test; 1 if true and 0 if false | 2 (higher arity = all are in non-increasing sequence) |
~ |
Less than or equal to test; 1 if true and 0 if false | 2 (higher arity = all are in non-decreasing seqence) |
` |
1 minus | 1 (higher arity = 1 minus sum) |
O |
1 minus the products of 1 minus the inputs | 2 |
X |
Sum mod 2 | 2 |
, |
Function input; following integer literal identifies it. Earliest function input = 0th input | 1 (higher arity = concatenated integer literal is identifier) |
0 to 9 |
Interger literal (except after a dot or comma) | 0 (higher arity = literal equaling concatenation of the integer literals) |
P |
Prints with a newline at the end | 1 (higher arity = things seperated by spaces) |
p |
Prints without a newline at the end | 1 (higher arity = things not seperated) |
C |
Concatenates integers into integers, arrays into arrays, strings into strings arrays+integers into arrays, arrays+strings into arrays, and integers+strings into strings | 2 |
A |
Creates an array | 1 |
Q |
Asks and retrieves user input without waiting | 0 |
q |
Asks and retrieves user input while waiting | 0 |
j |
Goes to character in program equaling its input (earliest character = 0th character). If it sees an array, it chooses one of the members at random | 0 (higher arity = chooses at random) |
^ |
Exponentiation | 2 (higher arity = power tower) |
( |
Treats as one instruction | 2 |
\ …) |
Makes the instruction after the \ have whatever arity needed to reach everything between it and the ) |
1 |
[ |
Nothing (by itself) | 0 |
] |
Go to matching [ (note that this is only done if run, so it can be skipped by ? ) |
0 |
> |
Push onto the stack | 1 (higher arity = push, left-to-right) |
< |
Pop top off stack | 0 (higher arity = pop off elements labled from top to bottom, left-to-right; e.g. ..<01 pops the top and the element under the one under the top)
|
: |
Return the top of the stack | 0 (higher arity = return elements labled from top to bottom) |
; |
Return and pop the top of the stack | 0 (higher arity = return elements labled from top to bottom, popping simultaneously) |
u |
Converts from integer to unicode character (note that all characters are simply length-1 strings) | 1 (higher arity = converts all as multiple seperate characters) |
U |
Converts from integer to unicode character (note that all characters are simply length-1 strings) | 1 (higher arity = converts all into one string) |
' |
Turns intruction into character literal | 1 (higher arity = converts all as multiple seperate characters) |
" |
Turns intruction into character literal | 1 (higher arity = converts all into one string) |
R |
Reverses stack order | 0 (higher arity = rotates elements of stack downward) |
r |
Reverses stack order | 0 (higher arity = rotates elements of stack upward) |
@ |
Synonym for .2 |
1 |
# |
Synonym for .3 |
1 |
$ |
Synonym for .4 |
1 |
Y |
Fork program, one per arity. Nullary = halts | 0 |
& |
For an array and a number, equals the numberth element of the array, 0-indexing. For an array and an array, equals an array of each indexing of the second's elements (i.e. &[a,b,c…][x,y,z…] gives [&[a,b,c…]x, &[a,b,c…]y, &[a,b,c…]z, …]) | 2
(higher arity = left-to-right) |
F |
Iterates across each value in the first input (array), with the loop variable identified by the second input, running the third input | 3 (higher arity = more intructions to run) |
{ |
Unary: create array from 1 to input. Binary: create array from first input to second input. Ternary: create array from first input to second input, going up by the third input each time, possibly going down | 1 |
a |
Converts strings into arrays of characters and numbers into arrays of just that number. Does nothing to arrays | 1 (higher arity = concatenate) |
n |
Converts strings to numbers, also considering basic math, and "descends down" arrays when doing this. Does nothing to numbers | 1 (higher arity = array of converted numbers) |
s |
Converts numbers to strings and arrays of strings to one string. Does nothing to strings | 1 (higher arity = array of converted strings) |
l |
Length of string or array | 1 |
Named variables/functions with different arities but identical names are considered the same. Everything is case-sensitive. If an operation isn't defined, it returns null, which is written as N
. We also have implicit printing/returning, which in the printing case acts like p
.
Also an imbalnce of [
s and ]
s can be sorted out by inserting them before or after the code, such that no [
-]
pairs are added that don't contribute to balancing. E.g., ][
is balanced as [][]
, but can't be balanced as [[][]]
.
Example programs
Cat
q
Truth machine
>q$?:[:]0
Hello world
!"Hello world)
Fibbinacci
.>11[>+.:01:]
Arithmetic mean
>"E[=+w1>q!T:"E]<[=+v;!T:"E]/v-w1
, where inputting "E" ends the input stream (probably not smallest possible)
Geometric mean
>"E[=+w1>q!T:"E]<[=*v;!T:"E]^vd-w1
, where inputting "E" ends the input stream (probably not smallest possible)
Factorial
=o1F{qi=*oio
Infinite loop
]
Print null
F
, +
, etc.
This also means that N
is a quine, though arguably a cheating quine.
Ceiling function for nonegative inputs
>q=+v1?-v:]