Peano

From Esolang
Jump to navigation Jump to search

Peano is an esolang invented by User:None1, inspired by Peano arithmetic.

Arithmetic Operators

Peano has only two built-in arithmetic operators: successor and precursor, unlike Peano arithmetic which has only one.

The precursor of a is represented by 'a, the successor of a is represented by a'.

Precursor and successor operators cancel out each other, for example 'a' returns a and a' returns 'a.

Numbers

The number system in Peano is positive integers (0 not included!), it is invalid to access the precursor of 1.

Comparison operators

Peano has only one comparison operator: ~ which checks if the value is 1, returns 1 if it is and 2 (1') if it isn't.

Brackets are allowed to prioritize operators.

Functions

Functions are like this:

!func(p1,p2,...)
con1:exp1
con2:exp2
con3:exp3
...
expn
;

If con1 is 1, return exp1, otherwise if con2 is 1, return exp2, ..., return expn.

I/O

Peano uses non-interactive input, it can only input number sequences. The inputs is stored in the variables i1,i2,...

Output can only be done in the global scope implicitly.

expr

prints the value of expr. Output format is implementation defined (e.g.: You can print 1' or 5 for the number five).

Examples

Add function

!add(a,b)
~a:b'
add('a,b)'
;

A+B Problem

!add(a,b)
~a:b'
add('a,b)'
;
add(i1,i2)