Circular Programs and Self-Referential Structures (2403.01866v1)
Abstract: A circular program creates a data structure whose computation depends upon itself or refers to itself. The technique is used to implement the classic data structures circular and doubly-linked lists, threaded trees and queues, in a functional programming language. These structures are normally thought to require updatable variables found in imperative languages. For example, a functional program to perform the breadth-first traversal of a tree is given. Some of the examples result in circular data structures when evaluated. Some examples are particularly space-efficient by avoiding the creation of intermediate temporary structures which would otherwise later become garbage. Lastly, the technique can be applied in an imperative language to give an elegant program.
- L. Allison. Two functional programming techniques: continuations and circular programs. TR 87/91, Monash University, Deptartment of Computer Science, January 1987.
- R. S. Bird. Using circular programs to eliminate multiple traversals of data. Acta Informatica, 21(3):239–250, October 1984.
- J. Cohen. Garbage collection of linked data structures. Computing Surveys, 13(3):341–367, September 1981.
- Cons should not evaluate its arguments. In Automata, Languages and Programming, pages 257–284. Edinburgh University Press, 1976.
- P. Henderson. A lazy evaluator. In 3rd ACM Symposium in Principles of Programming Languages, pages 95–103, January 1976.
- P. Henderson. Functional Programming: Application and Implementation. Prentice Hall, 1980.
- J. Hughes. Lazy memo functions. In J.-P. Jouannaud, editor, Functional Programming Languages and Computer Architecture, volume 201 of LNCS, pages 129–146. Springer Verlag, 1985.
- E. S. Page and B. Wilson. Information Representation and Manipulation in a Computer, volume 2 of Cambridge Computer Science Texts. Cambridge University Press, 1973.
- S. L Peyton-Jones. An introduction to fully-lazy supercombinators. In Cousineau G., Curien P.-L., and Robinet B., editors, Combinators and Functional Programming Languages, volume 242 of LNCS, pages 176–208. Springer Verlag, 1985.