FP trivia

FP trivia is a pointfree programming language[1][2] inspired by FP of John Backus, APL, Smalltalk and Lisp. It is intended to remedy the problematic fact that FP[3] is viewed as free of variables,[4][5][6] which is also true in terms of lambda variables, but not in terms of the instance variables that are used by FP trivia.[7] The main data type is therefore a table that the instance variables can access. It should not be forgotten that one motivation for creating FP was the use of an "Algebra of Programming".[8][9]

Syntax

A table is a linear arrangement of key–value pairs similar to a linked list.

```   ( value0 key0 value1 key1 value2 key2 ... ... valuen keyn )
```

An instance variable can then access a certain key and pick out the associated value.

```   #key1 : (value0 key0 value1 key1 value2 key2 ... ... valuen keyn)
--> value1
```

In the original FP by John Backus, it was only possible to access values in a sequence using numbers as selectors. This is still possible via integer numbers on the values in the table.

```   [2] : (value0 key0 value1 key1 value2 key2 ... ... valuen keyn)
--> value2
```

So you can define a function that adds three numbers.

```   triadd == (#a + #b + #c) <- a;b;c;
```
```   triadd ° 10,20,30,
--> 60
```

Algebra of Programming

The programs are in the arithmetic expression tree structure mentioned above and can be changed using algebraic rules. (A right-associativity must be observed)

```   f == id * id
g == id + 1
```
```   p == (2*id) * (f + g)
== (2*id*f) + (2*id*g)
== (2*id*g) + (2*id*f)
== (g*id*2) + (f*id*2)    // etc
```

Program Combinators are used in Infix Notation

Combinator Form
Constant 'x = x = x
Application f : x = f(x) = r
Composition (f o g) : x = f(g(x)) = r
Construction (f1 , f2 , ... , fn ,) : x = (f1:x) , (f2:x) , ... , (fn:x) , = (r1 ; r2 ; ... ; rn ;)
Condition (f -> g | h) : x = if (f:x) then (g:x) else (h:x) = r
While-Loop (f ->* g) : x = while (f:x) do new x = (g:x) = r
Apply-to-All (f aa) : (x1 ; x2 ; ... ; xn ;) = (f:x1) , (f:x2) , ... (f:xn) , = (r1 ; r2 ; ... ; rn ;)
Insertr (f \) : (x1 ; x2 ; ... ; xn ;) = f:(x1 ; f:(x2 ; f:(... ; f:(xn-1 ; xn ;) ;) ;) ;) = r
Eval-Eval (f ee g) : x = (f:x) , (g:x) , = (r1 ; r2 ;)
Apply (f app g) : x = apply(f(x),g(x)) = r

New infix combinators can be built with the functions term and arg and the existing functions and combinators.[10]

Instance variables with type test predicates

In order to achieve better type security for the instance variables, there is the option of type testing with predicates.

```   triadd == (#a + float°(#b + round°#c)) <- a isreal b isint c isnum
```
```   triadd ° 10,'[20],30,
--> 60
```
```   triadd ° 10,20,30,
--> Exception... Typemismatch
```