FP (programming language): Difference between revisions

Content deleted Content added
Danakil (talk | contribs)
Danakil (talk | contribs)
added more functionals, corrected typos, reorganized
Line 7:
if '''x'''<sub>1</sub>,...,'''x'''<sub>n</sub> are '''values''', then the '''sequence''' &lang;'''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. '''&#8869;''' is the '''undefined''' value, or '''bottom'''. Sequences are ''bottom-preserving'':
 
&lang;'''x'''<sub>1</sub>,...,'''&#8869;''',...,'''x'''<sub>n</sub>&rang; = '''&#8869;'''
 
FP programs are ''functions'' '''f''' that each map a single ''value'' '''x''' into another:
Line 13 ⟶ 15:
'''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'''). An example of one such operation is '''constant''', which transforms a value '''x''' into the constant-valued function '''x&#x304;'''. '''&#8869;'''Functions are [[strict function|strict]]: is the '''undefined''' value, which all functions map into itself, due to their [[strict function|strict]] nature.
and '''x&#x304;f''':'''&#8869;''' = '''&#8869;'''
 
==Functionals==
Line 19 ⟶ 22:
 
'''constant''' '''x&#x304;''' where '''x&#x304;''':'''y''' = '''x'''
and '''x&#x304;''':'''&#8869;''' = '''&#8869;'''
 
'''composition''' '''f'''&#x&#176;'''g''' where '''f'''&#x&#176;'''g''':'''x''' = '''f''':('''g''':'''x''')