Common LISP: the language
Program development using lambda abstraction
Proc. of the seventh conference on Foundations of software technology and theoretical computer science
Deforestation: transforming programs to eliminate trees
Proceedings of the Second European Symposium on Programming
Back to direct style II: first-class continuations
LFP '92 Proceedings of the 1992 ACM conference on LISP and functional programming
FPCA '93 Proceedings of the conference on Functional programming languages and computer architecture
Dependent types in practical programming
Proceedings of the 26th ACM SIGPLAN-SIGACT symposium on Principles of programming languages
Continuation-Based Program Transformation Strategies
Journal of the ACM (JACM)
Glossary for Partial Evaluation and Related Topics
Higher-Order and Symbolic Computation
Concrete Math
Definitional Interpreters for Higher-Order Programming Languages
Higher-Order and Symbolic Computation
A Comparative Revisitation of Some Program Transformation Techniques
Selected Papers from the Internaltional Seminar on Partial Evaluation
Proceedings of the 3rd ACM SIGPLAN international conference on Principles and practice of declarative programming
A Retrospective on Region-Based Memory Management
Higher-Order and Symbolic Computation
Journal of Functional Programming
Science of Computer Programming
Swapping arguments and results of recursive functions
MPC'06 Proceedings of the 8th international conference on Mathematics of Program Construction
Hi-index | 0.00 |
We present a programming pattern where a recursive function defined over a data structure traverses another data structure at return time. The idea is that the recursive calls get us 'there' by traversing the first data structure and the returns get us 'back again' while traversing the second data structure. We name this programming pattern of traversing a data structure at call time and another data structure at return time "There And Back Again" (TABA). The TABA pattern directly applies to computing symbolic convolutions and to multiplying polynomials. It also blends well with other programming patterns such as dynamic programming and traversing a list at double speed. We illustrate TABA and dynamic programming with Catalan numbers. We illustrate TABA and traversing a list at double speed with palindromes and we obtain a novel solution to this traditional exercise. Finally, through a variety of tree traversals, we show how to apply TABA to other data structures than lists. A TABA-based function written in direct style makes full use of an ALGOL-like control stack and needs no heap allocation. Conversely, in a TABA-based function written in continuation-passing style and recursively defined over a data structure (traversed at call time), the continuation acts as an iterator over a second data structure (traversed at return time). In general, the TABA pattern saves one from accumulating intermediate data structures at call time.