FP trivia

FP trivia is a pointfree programming languagePointfree - HaskellWiki. Retrieved on 5. Jan. 2021Point-free Program Calculation by Manuel Alcino Pereira da Cunha inspired by FP of John Backus, APL, Smalltalk and Lisp. It is intended to remedy the problematic fact that FP"Can programming be liberated from the von Neumann style?: A functional style and its algebra of programs" Communications of the ACM. 21 (8): 613. is viewed as free of variables,Closed applicative languages 1971 - 1976 ff in John W. Backus (Publications)Why did John Backus' function-level programming paradigm (...) never catch on?Obfuscation - HaskellWiki. Retrieved on 5. Jan. 2021 which is also true in terms of lambda variables, but not in terms of the instance variables that are used by FP trivia.Progopedia Example with instance variables 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".Richard Bird and Oege de Moor: Algebra of Programming. Prentice Hall Europe, 1997.The Algebra of Programming on Medium
== 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 	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.J. Gibert 1987 Functional Programming with Combinators
== 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
== External links ==
* Website
* Download
* Libraries in FP trivia
== References ==
Category:Programming techniques Category:Functional paradigm Category:Object-oriented paradigm Category:Languages