Countdown: A case study in origami programming

  • Authors:
  • Richard Bird;Shin-Cheng Mu

  • Affiliations:
  • Programming Research Group, Oxford University, Wolfson Building, Parks Road, Oxford OX1 3QD, UK;Department of Information Engineering, University of Tokyo, 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-8656, Japan

  • Venue:
  • Journal of Functional Programming
  • Year:
  • 2005

Quantified Score

Hi-index 0.00

Visualization

Abstract

Countdown is the name of a game in which one is given a list of source numbers and a target number, with the aim of building an arithmetic expression out of the source numbers to get as close to the target as possible. Starting with a relational specification we derive a number of functional programs for solving Countdown. These programs are obtained by exploiting the properties of the folds and unfolds of various data types, a style of programming Gibbons has aptly called origami programming. Countdown is attractive as a case study in origami programming both as an illustration of how different algorithms can emerge from a single specification, as well as the space and time trade-offs that have to be taken into account in comparing functional programs.