Combinators for breadth-first search

  • Authors:
  • Michael Spivey

  • Affiliations:
  • Oxford University Computing Laboratory, Wolfson Building, Parks Road, Oxford OX1 3QD, UK

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

Quantified Score

Hi-index 0.00

Visualization

Abstract

Every functional programmer knows the technique of "replacingfailure by a list of successes" (Wadler, 1985), but wiseprogrammers are aware also of the possibility that the list will beempty or (worse) divergent. In fact, the "lists of successes"technique is equivalent to the incomplete depth-first searchstrategy used in Prolog.At heart, the idea is quite simple:whenever we might want to use a 'multi-function' such as 'f'∶∶ á ↠ â that can return manyresults or none, we replace it by a genuine function f∶∶ α ↠ β stream that returns alazy stream of results, and rely on lazy evaluation to compute theanswers one at a time, and only as they are needed. For the sake ofclarity, I will distinguish between the types of finite lists(α list) and of potentially infinite, lazy streams(α stream), though both may be implemented in the sameway. Following the conventions used in ML, type constructors followtheir argument types.