Partial functions
partial function
Now, look at the function defined by the formula
. If the input and output domains are both , again this function is well-defined.
However, what if we assume that the input and output domains are both ?
This time, we have a problem when is odd. For example, is not an integer, so our function is not defined for all of its input values.
It is a partial function, a concept that subsumes the notion of a function but is more general.
Chapter 2: Relations, Functions, Partial Functions, Jean Gallier.
The following applications of partial functions cannot be defined:
quot 1 0rem 1 0div 1 0mod 1 0log 0head []tail []
Another example is the -body problem: which has no general solution for > 2.
Due to the vagaries of the reality in which programs exist in, I/O is fundamentally partial. For reasons ranging from death to disconnection to disinterest, a user may not provide a timely and suitable response when prompted by a program!
Data obtained from other programs or input devices can also be partial. For example, a remote program or sensor may send values which cannot be processed by the receiving program - as far as the remote sensor or program is concerned, that is entirely the receiver's problem!
Ooh, mommy, mommy, what I have now doesn't work in this extremely unlikely circumstance, so I'll just throw it away and write something completely new.
A more common solution is to let the receiver fail and be restarted.