Efficient high-level iteration with accumulators
- 1 April 1989
- journal article
- Published by Association for Computing Machinery (ACM) in ACM Transactions on Programming Languages and Systems
- Vol. 11 (2) , 194-211
- https://doi.org/10.1145/63264.63401
Abstract
Accumulators are proposed as a new type of high-level iteration construct for imperative languages. Accumulators are user-programmed mechanisms for successively combining a sequence of values into a single result value. The accumulated result can either be a simple numeric value such as the sum of a series or a data structure such as a list. Accumulators naturally complement constructs that allow iteration through user-programmed sequences of values such as the iterators of CLU and the generators of Alphard. A practical design for high-level iteration is illustrated by way of an extension to Modula-2 called Modula Plus. The extension incorporates both a redesigned mechanism for iterators as well as the accumulator design. Several applications are illustrated including both numeric and data structure accumulation. It is shown that the design supports efficient iteration both because it is amenable to implementation via in-line coding and because it allows high-level iteration concepts to be implemented as encapsulations of efficient low-level manipulations.Keywords
This publication has 4 references indexed in Scilit:
- OperatorsACM Transactions on Programming Languages and Systems, 1979
- Can programming be liberated from the von Neumann style?Communications of the ACM, 1978
- Abstraction mechanisms in CLUCommunications of the ACM, 1977
- Abstraction and verification in AlphardCommunications of the ACM, 1977