Skip to main navigation Skip to search Skip to main content

There and back again functional pearl

    Research output: Contribution to conferencePaperpeer-review

    6 Scopus citations

    Abstract

    We present a programming pattern where a recursive function traverses a data structure-typically a list-at return time. The idea is that the recursive calls get us there (typically to a base case) and the returns get us back again while traversing the data structure. We name this programming pattern of traversing a data structure at return time "There And Back Again" (TABA). The TABA pattern directly applies to computing a symbolic convolution. It also synergizes well with other programming patterns, e.g., 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. 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, the continuation acts as a list iterator. In general, the TABA pattern saves one from constructing intermediate lists in reverse order.

    Original languageEnglish
    Pages230-234
    Number of pages5
    StatePublished - 1 Dec 2002
    EventProceedings of the Seventh ACM SIGPLAN; International Conference on Functional Programming (ICFP'02) - Pittsburgh, PA, United States
    Duration: 4 Oct 20026 Oct 2002

    Conference

    ConferenceProceedings of the Seventh ACM SIGPLAN; International Conference on Functional Programming (ICFP'02)
    Country/TerritoryUnited States
    CityPittsburgh, PA
    Period4/10/026/10/02

    Keywords

    • Catalan numbers
    • Continuation-based programming
    • Palindrome detection
    • Symbolic convolutions

    ASJC Scopus subject areas

    • Software

    Fingerprint

    Dive into the research topics of 'There and back again functional pearl'. Together they form a unique fingerprint.

    Cite this