On Barron and Strachey's cartesian product function

  • Authors:
  • Olivier Danvy;Michael Spivey

  • Affiliations:
  • University of Aarhus, Aarhus, Denmark;University of Oxford, Oxford, England UK

  • Venue:
  • ICFP '07 Proceedings of the 12th ACM SIGPLAN international conference on Functional programming
  • Year:
  • 2007

Quantified Score

Hi-index 0.00

Visualization

Abstract

Over forty years ago, David Barron and Christopher Strachey published a startlingly elegant program for the Cartesian product of a list of lists, expressing it with a three nested occurrences of the function we now call foldr. This program is remarkable for its time because of its masterful display of higher-order functions and lexical scope, and we put it forward as possibly the first ever functional pearl. We first characterize it as the result of a sequence of program transformations, and then apply similar transformations to a program for the classical power set example. We also show that using a higher-order representation of lists allows a definition of the Cartesian product function where foldr is nested only twice.