Skip to main content

Loopless Functional Algorithms

  • Conference paper
Mathematics of Program Construction (MPC 2006)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 4014))

Included in the following conference series:

Abstract

A loopless algorithm is a procedure for generating a list of values under two restrictions: the first element should be produced in linear time and each subsequent element in constant time. Loopless algorithms arise in the enumeration of combinatorial patterns such as permutations or subsequences. The elements of the generated list describe transitions that determine how the next combinatorial pattern is to be determined from its predecessor. Loopless algorithms were introduced in a procedural setting, and many clever tricks, such as focus pointers, doubly-linked lists and coroutines, have been used to construct them. This paper explores what a purely functional approach can bring to the subject, and calculates loopless functional versions of the Gray code algorithm, the Koda-Ruskey algorithm for listing the prefixes of a forest, and the Johnson-Trotter algorithm for generating permutations. The functional algorithms are completely different from their procedural counterparts, and rely on nothing more fancy than lists, trees and queues.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Bird, R.S.: Introduction to Functional Programming Using Haskell. Prentice Hall, Englewood Cliffs (1998)

    Google Scholar 

  2. Ehrlich, G.: Loopless algorithms for generating permutations, combinations, and other combinatorial configurations. J. of ACM 20, 500–513 (1973)

    Article  MATH  MathSciNet  Google Scholar 

  3. Filliatre, J.-C., Pottier, F.: Producing all ideals of a forest, functionally. J. of Funct. Program. 13(5), 945–956 (2003)

    Article  MATH  Google Scholar 

  4. Knuth, D.E.: SPIDERS (2001), A program downloadable from: www-cs-faculty.stanford.edu/~knuth/programs.html

  5. Knuth, D.E.: The Art of Computer Programming, vol. 4 (2004), www-cs-faculty.stanford.edu/~knuth/

  6. Koda, Y., Ruskey, R.: A Gray code for the ideals of a forest poset. J. of Algorithms 15, 324–340 (1993)

    Article  MATH  MathSciNet  Google Scholar 

  7. Okasaki, C.: Simple and efficient purely functional queues and deques. J. of Funct. Program. 5(4), 583–592 (1995)

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2006 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Bird, R.S. (2006). Loopless Functional Algorithms. In: Uustalu, T. (eds) Mathematics of Program Construction. MPC 2006. Lecture Notes in Computer Science, vol 4014. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11783596_9

Download citation

  • DOI: https://doi.org/10.1007/11783596_9

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-35631-8

  • Online ISBN: 978-3-540-35632-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics