# Recursor

Recursor is a recursion based (loosely) functional programming language created by Ettore Marmo.

## Overview

In this language you can define quickly and clearly recursive functions:

```f(x) = f(x-1) + f(x-2); [1,1]
```

is a valid example. The array after the function body defines the seeds of the function and is to be read like so:

```f(0) = 1
f(1) = 1
```

The seeds can also be strings, arrays or floats.

Obviously nested functions are valid statements:

```H(n) = n-H(H(H(n-1))); 
```

While f(x) behaves like you would expect, returning the xth term of the function,

```f(*x)
```

returns an array of all the values of the function ranging from 0 to x (inclusive).

## Conditionals

This language is also capable of if/else statements with a syntax similar to that of the ternary operator. Keep in mind that these statements can only be defined inside a function.

```F(x) = x % 2 == 0 | x > 30 ?
x - F(x-1)
;     F(x-1) + x
; 
```

The symbol between the two conditions is one of the three logical operators implemented:

```& : and   | : or   || : xor
```

Of course the conditionals can also be nested.

## Output

There are two options if you want to print something on the screen:

```@1,2,"A"
```

prints its arguments with a trailing newline.

```@@"Hello", "\", "World"
```

prints everything on the same line, note that because the interpreter is dumb you have to write "\" for the space character.

The print functions can be used also inside the body of a function.

## Suffixes

There is a bunch of already implemented functions that can be appended after a token, separated with `:`. g = [1,2,3] : function()

For arrays only:

Function Definition
sort() returns the array sorted
join(x) returns a string containing the array element joined with x

For strings/char only:

Function Definition
split(x) returns an array of the string split at every x
up() returns the string with uppercase characters
down() returns the string with downcase characters
ord() returns the ordinal associated to the char

For ints/floats only:

Function Definition
chr() returns the character associated to the int
abs() returns the absolute value of the number
odd() returns true if the integer is odd
gcd(x) returns the greatest common divisor between the number and x
lcm(x) returns the lowest common multiple between the number and x
zero() returns true if the number is zero

For arrays and strings:

Function Definition
[x] returns the xth element of the array/string
[x,y] returns the sliced array from the xth index to the yth
len() returns the length of the array/string
:x appends x to the array/string
rev() reverses the array/string
count(x) counts every occurrence of x
del(x) delete every occurrence of x
null returns true if the array/string is empty

An example:

```f(x) = f(x-1) + f(x-2) ; [1,1]
@f(*10):[3,6]:rev():join(",")
```

and it correctly outputs

```34,21,13,8,5,3
```

coming soon

coming soon

coming soon