Consider the following situation. I define a function to handle a list of elements in a typical way of performing an operation on a head and calling a function on the rest of the list. But under a certain condition of the element (being negative, being a special symbol, ...), before continuing, I change the sign to the rest of the list. Like this:
f [] = []
f (x : xs)
| x >= 0 = g x : f xs
| otherwise = h x : f (opposite xs)
opposite [] = []
opposite (y : ys) = negate y : opposite ys
Like opposite (opposite xs) = xs
, I turn to the situation of excessive opposite operations, accumulating opposite . opposite . opposite ...
.
This happens with other operations instead opposite
, such that composition with itself is an identity, for example reverse
.
, ///? ( ). :
opposite . opposite = id -- or, opposite (opposite y) = y
( () ).