Defunc

Defunc is a function-based, minimalist esoteric programming language currently developed by User:Obvious. The language operates on functions that return integers. These functions can vary in input size. Its name comes from a portmanteau of "define" and "function"
==Predefined functions==
The language consists of 5 functions, which are as follows:
Function	Description
0 	Returns a 0
+a 	Returns a+1
?abcd 	If a>b, return c, otherwise return d
.a 	Writes a to the console, while returning it (Note: Defunc will output the actual integer and does not support ASCII)
, 	Requests user input in the form of an integer
Note that ?abcd will evaluate a, b, and only one out of c and d. This also includes writing to the console. ?0.a0b can therefore be used to write a and return b.
==Other functions==
Apart from the predefined functions, there are other functions as well. In a program you are able to define your own function, within the constraints of the programming language. To define a function, take a character that is not yet defined as a function or variable as the function name, then take any amount of characters that are not defined as a function for the variable names, and then give the function it should return. For example: >ab?abab defines a > function with variables a and b and outputs the greater.
Functions can refer to earlier functions, but also to themselves, to create a loop. You could for example write a sum function as Sabc?bcS+ab+ca, which increments a and the counter variable c, until c reaches b. Then it returns a, which by then had b increments applied to it. Note that this function is capable of subtracting as well as the function would return a+b-c if b is greater than c and would return a otherwise.
==Other Syntax==
Anything must return exactly one argument. Iaa is valid, as Ia returns a, but Iaaa is not, as it would imply Ia returns aa, which are two arguments and not one. You should use a line break to separate the definitions/calculations.
Not everything has to be a definition. Executing a function has to be done as well.
==Turing Completeness==
This esoteric programming language has been proven Turing complete by the construction of a turing machine program interpreter within the programming language.
==Examples==
===Hello, world!===
 4a++++a
 Ba44444444a
 LBBB4440
 .+4444444.BB440
 ..L
 .+++L
 .+++44444BB.B0
 .+++.+++L
 .L
 .BBB40
 .+B0
Due to output restrictions this will only output the decimal form of the ASCII codes
===Cat===
 C?0.,0C
 C
The input is restricted to an integer
===Fibonacci sequence===
 Sabc?bcS+ab+ca
 Fab?0.a0FbSab0
 F0+0
===Factorial===
 Arci?ciA+rc+ir
 *ab?b0Aa*aA0b+000
 !a?a+0*a!A0a+0+0
 .!,
===Ackermann function===
 -ab?a+b-a+bb
 Aab?a0?b0A-a0Aa-b0A-a0+0+b
 .A,,
===Truth-machine===
 Ta?.a0Ta0
 T,
===Turing machine===
 Sabc?bcS+ab+ca
 Mabcd?bdMabSac0+dc
 Eabcd?bdEabMac00+dc
 Dabcd?acDabSbc0+dd
 Rab?babRS0abb
 Iabcd?adIaDbc00c+dRbc
 
 Aabcd?b0?RCIbad0c++00ASEdbWIbad0c0aEdbIbad00+bDCIbad0c++000dASEdbWIbad0c0aEdbIbad00S0b+0DCIbad0c++000dAMad00+bcd
 (a=tape, b=index, c=current state, d=amount of possible states)
 Cab [insert your own chain of '?'-statements here, must return direction+2*newstate, with 0=left and 1=right]
 Wab [insert your own chain of '?'-statements here, must return the value to be written]
 (both use a=value, b=current state)
==External resources==
* Official interpreter
Category:Languages
Category:Functional_paradigm
Category:2021
Category:Turing complete