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"
The language consists of 5 functions, which are as follows:
||Returns a 0|
||If a>b, return c, otherwise return d|
||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|
?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.
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
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.
Anything must return exactly one argument.
Iaa is valid, as
Iaaa is not, as it would imply
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.
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
The input is restricted to an integer
Sabc?bcS+ab+ca Fab?0.a0FbSab0 F0+0
Arci?ciA+rc+ir *ab?b0Aa*aA0b+000 !a?a+0*a!A0a+0+0 .!,
-ab?a+b-a+bb Aab?a0?b0A-a0Aa-b0A-a0+0+b .A,,