Content deleted Content added
m lowercase |
m BOT - Unicodifying |
||
Line 5:
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'''
These values can be built from any set of atoms: booleans, integers, reals, characters, etc.:
'''boolean''' : {'''T''', '''F'''}
'''integer''' : {0,1,2,...,
'''character''' : {'a','b','c',...}
'''symbol''' : {'''x''','''y''',...}
'''
FP programs are ''functions'' '''f''' that each map a single ''value'' '''x''' into another:
Line 21:
'''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 '''
'''f''':'''
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 ×''' = 1
'''unit foo''' =
==Functionals==
These are the core functionals of FP:
'''constant''' '''
'''composition''' '''f'''
'''construction''' ['''f'''<sub>1</sub>,...'''f'''<sub>n</sub>] where ['''f'''<sub>1</sub>,...'''f'''<sub>n</sub>]:'''x''' =
'''condition''' ('''h'''
= '''g''':'''x''' if '''h''':'''x''' = '''F'''
= '''
'''apply-to-all''' ''
'''insert-right''' /'''f''' where /'''f''':
and /'''f''':
and /'''f''':
'''insert-left''' \'''f''' where \'''f''':
and \'''f''':
and \'''f''':
==Equational functions==
In addition to being constructed from primitives by functionals, a function may be defined recursively by an equation, the simplest kind being:
'''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''':
'''''i''''':
=
==See also==
|