Abstract
We present a Prolog implementation of real-time persistent queues and double-ended queues. Our implementation is inspired by Okasaki’s lazy-functional approach, but relies only on standard Prolog, comprising of the pure subset plus if-then-else constructs to efficiently implement guards and meta-calls for convenience. The resulting data structure is a nice demonstration of the fact that the use of logic variables to hold the outcome of an unfinished computation can sometimes give the same kind of elegant and compact solutions as lazy evaluation.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Hood, R., Melville, R.: Real-time queue operations in pure LISP. Computer science technical report, Cornell University (1980), http://hdl.handle.net/1813/6273
O’Keefe, R.A.: The Craft of Prolog. The MIT Press, Cambridge (1990)
Okasaki, C.: Simple and Efficient Purely Functional Queues and Deques. J. Functional Programming 5(4), 583–592 (1995)
Schrijvers, T., Santos Costa, V., Wielemaker, J., Demoen, B.: Towards Typed Prolog. In: Garcia de la Banda, M., Pontelli, E. (eds.) ICLP 2008. LNCS, vol. 5366, pp. 693–697. Springer, Heidelberg (2008), http://dx.doi.org/10.1007/978-3-540-89982-2_59
Hood, R.T.: The Efficient Implementation of Very-High-Level Programming Language Constructs. Computer science technical report, Cornell University (1982), http://hdl.handle.net/1813/6343
Chuang, T.-R., Goldberg, B.: Real-time deques, multihead turing machines, and purely functional programming. In: Proceedings of the Conference on Functional Programming and Computer Architecture, pp. 289–298. ACM, New York (1993)
Sterling, L., Shapiro, E.: The Art of Prolog. The MIT Press, Cambridge (1986)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2012 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Bouma, G. (2012). Real-Time Persistent Queues and Deques with Logic Variables (Declarative Pearl). In: Schrijvers, T., Thiemann, P. (eds) Functional and Logic Programming. FLOPS 2012. Lecture Notes in Computer Science, vol 7294. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-29822-6_8
Download citation
DOI: https://doi.org/10.1007/978-3-642-29822-6_8
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-29821-9
Online ISBN: 978-3-642-29822-6
eBook Packages: Computer ScienceComputer Science (R0)