Hostname: page-component-78c5997874-mlc7c Total loading time: 0 Render date: 2024-11-17T14:38:48.821Z Has data issue: false hasContentIssue false

Solving the snake cube puzzle in Haskell

Published online by Cambridge University Press:  25 March 2013

MARK P. JONES*
Affiliation:
Department of Computer Science, Portland State University, Portland, Oregon, USA (e-mail: mpj@cs.pdx.edu)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

We describe a concise and elegant functional program, written in Haskell, that computes solutions for a classic puzzle known as the “snake cube.” The program reflects some of the fundamental characteristics of the functional style, identifying key abstractions, and defining a small collection of operators for manipulating and working with the associated values. Well-suited for an introductory course on functional programming, this example highlights the use of visualization tools to explain and demonstrate the choices of data structures and algorithms that are used in the development.

Type
Functional Pearls
Copyright
Copyright © Cambridge University Press 2013

References

Peyton Jones, S. (ed) (2003) Haskell 98 Language and Libraries, The Revised Report. Cambridge, UK: Cambridge University Press.Google Scholar
Ressler, G. (2012) Sketch: Simple 3D Sketching, Version 0.3. Available at: http://www.frontiernet.net/~eugene.ressler/. Accessed 1 March 2013.Google Scholar
Tantau, T. (2010) The TikZ and pgf Packages Manual for version 2.10. Institut für Theoretische Informatik, Universität zu Lübeck. Available at: http://sourceforge.net/projects/pgf. Accessed 1 March 2013.Google Scholar
Wadler, P. (1985) How to replace failure by a list of successes. In The Second International Conference on Functional Programming Languages and Computer Architecture (FPCA 1985), Lecture Notes in Computer Science, vol. 201. Nancy, France: Springer-Verlag.Google Scholar
Supplementary material: File

Jones Supplementary Material

Supplementary Material

Download Jones Supplementary Material(File)
File 51.1 KB
Submit a response

Discussions

No Discussions have been published for this article.