A shortcut fusion approach to accumulations
In functional programming it is common to write programs as compositions of other simpler functions. This makes it possible to take advantage of the well-known benefits of modular programming. However, in many cases, the resulting programs have efficiency problems caused by the generation of data structures that are solely used for communication between the functions that take part in the compositions. Many of those intermediate structures can be eliminated by an appropriate combination of the codes of the involved functions using a technique called program fusion. In this work, we propose a program fusion technique for accumulations, which are recursive functions that use additional parameters, called accumulators, for keeping intermediate results. Accumulations are known to be difficult to be fused because of the presence of the accumulators and the fact that results are usually computed in those parameters. Our technique is based on a shortcut fusion approach which turns out to be effective in the case of accumulations. We present benchmarks that illustrate the impact of shortcut fusion on accumulations. (C) 2012 Elsevier B.V. All rights reserved.
shortcut fusion accumulations functional programming