FP (programming language): Difference between revisions

Content deleted Content added
No edit summary
restructured to put things where they belong
Line 38:
to the '''value''' '''x'''
 
Functions are either primitive (i.e., provided with the FP environment) or are built from the primitives by '''program-forming operations''' (also called '''functionals''').

An example of one suchprimitive operationfunction is '''constant''', which transforms a value '''x''' into the constant-valued function '''x̄'''. Functions are [[strict function|strict]]:
'''f''':'''⊥''' = '''⊥'''
 
AnAnother example of a primitive function is the '''selector''' function family, denoted by '''1''','''2''',... where:
Some functions have a ''unit'' value, such as 0 for ''addition'' and 1 for ''multiplication''. The functional '''unit''' produces such a '''value''' when applied to a '''function f''' that has one:
'''1''':〈'''x'''<sub>1</sub>,...,'''x'''<sub>n</sub>〉 = '''x'''<sub>1</sub>
'''''i''''':〈'''x'''<sub>1</sub>,...,'''x'''<sub>n</sub>〉 = '''x'''<sub>i</sub> if 0 < '''''i''''' ≤ n
= ⊥ otherwise
 
==Functionals==
 
SomeIn contrast to primitive functions, functionals operate on other functions. For example, some functions have a ''unit'' value, such as 0 for ''addition'' and 1 for ''multiplication''. The functional '''unit''' produces such a '''value''' when applied to a '''function f''' that has one:
'''unit +''' = 0
'''unit &times;''' = 1
'''unit foo''' = ⊥
 
==Functionals==
These are the core functionals of FP:
 
'''constant''' '''x̄''' where '''x̄''':'''y''' = '''x'''
 
'''composition''' '''f'''°'''g''' where '''f'''°'''g''':'''x''' = '''f''':('''g''':'''x''')
Line 74 ⟶ 80:
'''f''' ≡ ''E'''''f'''
where ''E''''''f''' is an [[expression (programming)|expression]] built from primitives, other defined functions, and the function symbol '''f''' itself, using functionals.
 
An example of a primitive function is the '''selector''' function family, denoted by '''1''','''2''',... where:
'''1''':〈'''x'''<sub>1</sub>,...,'''x'''<sub>n</sub>〉 = '''x'''<sub>1</sub>
'''''i''''':〈'''x'''<sub>1</sub>,...,'''x'''<sub>n</sub>〉 = '''x'''<sub>i</sub> if 0 < '''''i''''' ≤ n
= ⊥ otherwise
 
==See also==