|Computational class||Category:Turing complete|
ƎↃИAЯT is a an esoteric programming language. The only allowed type is integer of unlimited size and the only operation is addition.
Source code has one or more function definitions. Each function definition has name, formal arguments and the resulting expression.
add(x, y): x + y
It is a function that adds two integers. All integers are non-negative (the smallest integer is
Function overloading is also allowed. The following is a function that decrements a number:
dec(x + 1): x dec(0): 0
Explanation: there are two overloaded function definitions. When called with an argument that is something plus
1, then return that something, which is effectively the argument decremented by
1. When called with
0 it returns
We can also implement subtraction:
sub(x + 1, y + 1): sub(x, y) sub(x + 1, 0): x + 1 sub(0, y): 0
Here are some examples of illegal code:
// ERROR: Missing implementation for func(0) func(x + 1): x // ERROR: Call to func(1) would be ambiguous func(x + 1): x func(1): 1 func(0): 0 // ERROR: Invalid formal argument func(x + y): x
The provided interpreter requires function
main to be present and calls
main with the input number, which is obtained by converting the input string to byte array and concatenating all the bytes to form a big integer. Output format is the same.
Add two digits
main(x): sub(shr(x, 8) + sub(x, shl(shr(x, 8), 8)), 48) sub(x + 1, y + 1): sub(x, y) sub(x + 1, 0): x + 1 sub(0, y): 0 shl(x, y + 1): shl(shl(x, y)) shl(x, 0): x shl(x): x + x shr(x, y + 1): shr(shr(x, y)) shr(x, 0): x shr(x + 2): shr(x) + 1 shr(1): 0 shr(0): 0
Works only if the sum is smaller than