FP (programming language): Difference between revisions

Content deleted Content added
Danakil (talk | contribs)
No edit summary
Danakil (talk | contribs)
No edit summary
Line 4:
 
The '''values''' that FP programs map into one another comprise a [[set]] which is [[closed]] under '''sequence formation''':
 
''if'' '''x'''<sub>1</sub>,...,'''x'''<sub>n</sub> are '''values''', then the '''sequence''' &ltlang;'''x'''<sub>1</sub>,...,'''x'''<sub>n</sub>>&rang; is also a '''value'''
 
These values can be built from any set of atoms: booleans, integers, reals, characters, etc.
Line 10 ⟶ 11:
FP programs are ''functions'' '''f''' that each map a single ''value'' '''x''' into another:
 
'''f''':'''x''' represents the '''value''' that results from applying the '''function''' '''f''' 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'''). One such operation is '''constant''', which transforms a value '''x''' into the constant-valued function '''x&#x304;''' where:
 
'''constant''' '''x&#x304;''' where '''x&#x304;''':'''y''' = '''x'''
 
for all values '''y''' (except the '''undefined''' value, '''&#8869;''', which all functions map into itself, due to their being [[strict function|strict]], map into itself). Next there are the three principal functionals of FP:
 
'''composition''' '''f'''&#x&#176;'''g''' where '''f'''&#x&#176;'''g''':'''x''' = '''f''':('''g''':'''x''')
 
'''construction''' ['''f'''<sub>1</sub>,...'''f'''<sub>n</sub>] where ['''f'''<sub>1</sub>,...'''f'''<sub>n</sub>]:'''x''' = '''<'''&lang; '''f'''<sub>1</sub>:'''x''',...,'''f'''<sub>n</sub>:'''x''' '''>'''&rang;
 
'''condition''' ('''h''' &rArr; '''f''';'''g''') where ('''h''' &rArr; '''f''';'''g'''):'''x''' = '''f''':'''x''' if '''h''':'''x''' = '''T'''
and ('''h''' &rArr; '''f''';'''g'''):'''x''' = '''g''':'''x''' if '''h''':'''x''' = '''F'''
and ('''h''' &rArr; '''f''';'''g'''):'''x''' = '''&#8869;''' otherwise