Partial Evaluation of the Euclidian Algorithm

  • Authors:
  • Olivier Danvy;Mayer Goldberg

  • Affiliations:
  • BRICS, Department of Computer Science, University of Aarhus, Ny Munkegade, Building 540, DK-8000 Aarhus C, Denmark. E-mail: danvy@brics.dk, mayer@brics.dk;BRICS, Department of Computer Science, University of Aarhus, Ny Munkegade, Building 540, DK-8000 Aarhus C, Denmark. E-mail: danvy@brics.dk, mayer@brics.dk

  • Venue:
  • Lisp and Symbolic Computation
  • Year:
  • 1997

Quantified Score

Hi-index 0.00

Visualization

Abstract

Some programs are easily amenable to partial evaluation because theircontrol flow clearly depends on one of their parameters. Specializingsuch programs with respect to this parameter eliminates theassociated interpretive overhead. Some other programs, however, donot exhibit this interpreter-like behavior. Each of them presents achallenge for partial evaluation. The Euclidian algorithm is one ofthem, and in this article, we make it amenable to partialevaluation.We observe that the number of iterations in theEuclidian algorithm is bounded by a number that can be computed giveneither of the two arguments. We thus rephrase this algorithm usingbounded recursion. The resulting program is better suited forautomatic unfolding and thus for partial evaluation. Itsspecialization is efficient.