Folding left and right matters: Direct style, accumulators, and continuations. (14th February 2023)
- Record Type:
- Journal Article
- Title:
- Folding left and right matters: Direct style, accumulators, and continuations. (14th February 2023)
- Main Title:
- Folding left and right matters: Direct style, accumulators, and continuations
- Authors:
- DANVY, OLIVIER
- Abstract:
- Abstract: The equivalence of folding left and right over Peano numbers and lists makes it possible to minimalistically inter-derive (1) structurally recursive functions in direct style, (2) structurally tail-recursive functions that use an accumulator, and (3) structurally tail-recursive functions in delimited continuation-passing style, using Ohori and Sasano's lightweight fusion by fixed-point promotion. When the fold-left and the fold-right functions account for primitive iteration for Peano numbers, this equivalence is unconditional. When they account for primitive recursion for Peano numbers, this equivalence is modulo left permutativity of their induction-step parameter – a property which is more general than associativity and commutativity. And when they account for primitive iteration or for primitive recursion over lists, this equivalence is modulo left permutativity of their induction-step parameter if these two fold functions have the same type. Since the 1980s, however, the two fold functions for lists do not have the same type: the arguments for their induction-step parameter are swapped, a re-ordering that complicated Bird and Wadler's duality theorems and whose history is reviewed in an appendix. Without this re-ordering, Bird and Wadler's second duality theorem more visibly accounts for "re-bracketing, " which is a key step to make recursive programs tail recursive in the general area of program development, from Cooper in the 1960s and onwards.
- Is Part Of:
- Journal of functional programming. Volume 33(2023)
- Journal:
- Journal of functional programming
- Issue:
- Volume 33(2023)
- Issue Display:
- Volume 33, Issue 2023 (2023)
- Year:
- 2023
- Volume:
- 33
- Issue:
- 2023
- Issue Sort Value:
- 2023-0033-2023-0000
- Page Start:
- Page End:
- Publication Date:
- 2023-02-14
- Subjects:
- Functional programming (Computer science) -- Periodicals
- Journal URLs:
- http://journals.cambridge.org/action/displayJournal?jid=JFP ↗
http://firstsearch.oclc.org ↗ - DOI:
- 10.1017/S0956796822000156 ↗
- Languages:
- English
- ISSNs:
- 0956-7968
- Deposit Type:
- Legaldeposit
- View Content:
- Available online (eLD content is only available in our Reading Rooms) ↗
- Physical Locations:
- British Library STI - ELD Digital store
- Ingest File:
- 25687.xml