Evaluating binary operators on a list of values
It is usually a straight forward exercise to apply a binary operator to a list of values. For example, all common associative (mathematical) operations, like plus and times can be extended this way. A slightly more complex example known to many in CS is the computation of the carry bit in a carry look-ahead adder.
A consideration which is trival in most cases, is the value of the operation applied to the empty list. In some cases however, a look in the underlying maths can be helpfull to ensure the correctness of the chosen solution.
As a starting point of our consideration we use the observation that we get the same result if we split the list of values in several lists and apply the operation recursivley, first to each list and then to the list consisting of the resulting values, respectivly. A neccessary condition is therefore, that the result of the operater applied to the empty list should not modify the resulting value. Hence, the value of the operator applied to the empty list depends on the operation and is usually called the identity or neutral element w.r.t. the operation (and the set).
That is an application of the operater to the empty list should give the the boolean value **true** in the case of the And-operater and the boolean value **false** in the case of the Or-operator. Similar, if we consider the return on a portfolio, the neutral element on our earnings should be 1.
Date: 2011-02-11 Fr
HTML generated by org-mode 7.4 in emacs 22