ABSTRACT
A nexus is a tree that contains shared nodes, nodes that have more than one incoming arc. Shared nodes are created in almost every functional program---for instance, when updating a purely functional data structure---though programmers are seldom aware of this. In fact, there are only a few algorithms that exploit sharing of nodes consciously. One example is constructing a tree in sublinear time. In this pearl we discuss an intriguing application of nexuses; we show that they serve admirably as memo structures featuring constant time access to memoized function calls. Along the way we encounter Boolean lattices and binomial trees.
- Richard Bird and Oege de Moor. Algebra of Programming. Prentice Hall Europe, London, 1997. Google ScholarDigital Library
- Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms. The MIT Press, Cambridge, Massachusetts, second edition, 2001. Google ScholarDigital Library
- Ralf Hinze. Memo functions, polytypically! In Johan Jeuring, editor, Proceedings of the 2nd Workshop on Generic Programming, Ponte de Lima, Portugal, pages 17--32, July 2000. The proceedings appeared as a technical report of Universiteit Utrecht, UU-CS-2000-19.Google Scholar
- Graham Hutton. Functional Pearl: the countdown problem. Journal of Functional Programming, 12(6):609--616, November 2002. Google ScholarDigital Library
- Donald E. Knuth. The Art of Computer Programming, Volume 1: Fundamental Algorithms. Addison-Wesley Publishing Company, 3rd edition, 1997. Google ScholarDigital Library
- E. Meijer, M. Fokkinga, and R. Paterson. Functional programming with bananas, lenses, envelopes and barbed wire. In 5th ACM Conference on Functional Programming Languages and Computer Architecture, FPCA'91, Cambridge, MA, USA, volume 523 of Lecture Notes in Computer Science, pages 124--144. Springer-Verlag, 1991. Google ScholarDigital Library
- Donald Michie. "Memo" functions and machine learning. Nature, (218):19--22, April 1968.Google Scholar
- Shin-Cheng Mu. A calculational approach to program inversion. PhD thesis, Oxford University Computing Laboratory, 2003.Google Scholar
- Chris Okasaki. Functional Pearl: Three algorithms on Braun trees. Journal of Functional Programming, 7(6), November 1997. Google ScholarDigital Library
- Simon Peyton Jones. Haskell 98 Language and Libraries. Cambridge University Press, 2003.Google Scholar
- Neil Sarnak and Robert~E. Tarjan. Planar point location using persistent search trees. Communications of the ACM, 29(7):669--679, July 1986. Google ScholarDigital Library
Index Terms
- Functional Pearl trouble shared is trouble halved
Recommendations
Lightweight semiformal time complexity analysis for purely functional data structures
POPL '08: Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesOkasaki and others have demonstrated how purely functional data structures that are efficient even in the presence of persistence can be constructed. To achieve good time bounds essential use is often made of laziness. The associated complexity analysis ...
FUNCTIONAL PEARL
A common solution to the problem of handling list indexing efficiently in a functional program is to build a binary tree. The tree has the given list as frontier and is of minimum height. Each internal node of the tree stores size information (actually, ...
Lightweight semiformal time complexity analysis for purely functional data structures
POPL '08Okasaki and others have demonstrated how purely functional data structures that are efficient even in the presence of persistence can be constructed. To achieve good time bounds essential use is often made of laziness. The associated complexity analysis ...
Comments