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 '''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:▼
'''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==▼
▲
'''unit +''' = 0
'''unit ×''' = 1
'''unit foo''' = ⊥
▲==Functionals==
These are the core functionals of FP:
'''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==
|