In functional programming, fold is a standard operator that encapsulates a simple pattern of recursion for processing lists. This article is a tutorial on two key aspects of the fold operator for lists. First of all, we emphasize the use of the universal property of fold both as a proof principle that avoids the need for inductive proofs, and as a definition principle that guides the transformation of recursive functions into definitions using fold. Secondly, we show that even though the pattern of recursion encapsulated by fold is simple, in a language with tuples and functions as first-class values the fold operator has greater expressive power than might first be expected. 1 Introduction Many programs that involve repetition are naturally expressed using some form of recursion, and properties proved of such programs using some form of induction. Indeed, in the functional approach to programming, recursion and induction are the primary tools for defining and proving properties of p...
|
1122
|
Introduction to Functional Programming
– Bird, Wadler
- 1988
|
|
506
|
Introduction to Metamathematics
– KLEENE
- 1952
|
|
385
|
Comprehending monads
– WADLER
- 1992
|
|
370
|
Programming be Liberated from the von Neumann Style? AFunctional Style and its Algebra of Programs," in \ACM Turing Award Lectures: The First Twenty Years
– Backus, \Can
- 1987
|
|
250
|
Functional programming with bananas, lenses, envelopes and barbed wire
– Meijer, Fokkinga, et al.
- 1991
|
|
172
|
Introduction to Functional Programming using Haskell
– Bird
- 1998
|
|
163
|
A Programming Language
– Iverson
- 1962
|
|
147
|
Polyp - a polytypic programming language extension
– Jansson, Jeuring
- 1997
|
|
111
|
The Lambda Calculus: Its Syntax and Semantics. North-Holland, revised edition
– Barendregt
- 1984
|
|
104
|
A Fold for All Seasons
– Sheard, Fegaras
- 1993
|
|
89
|
Algorithmics -- towards programming as a mathematical activity
– Meertens
- 1987
|
|
82
|
Shortcut deforestation in calculational form
– Takano, Meijer
- 1995
|
|
77
|
Generic programming — an introduction
– Backhouse, Jansson, et al.
- 1999
|
|
73
|
Algebraic Data Types and Program Transformation
– Malcolm
- 1990
|
|
72
|
Bananas in space: Extending fold and unfold to exponential types. Pages 324–333 of: Fpca95: Conference on functional programming languages and computer architecture
– Meijer, Hutton
- 1995
|
|
69
|
Warm Fusion: Deriving Build-Catas from Recursive Definitions
– Launchbury, Sheard
- 1995
|
|
68
|
Algebra of Programming
– Bird, Moor
- 1997
|
|
64
|
Three approaches to type structure
– Reynolds
- 1985
|
|
56
|
Nested datatypes
– Bird, Meertens
- 1998
|
|
44
|
Merging monads and folds for functional programming
– Meijer, Jeuring
- 1995
|
|
39
|
Calculating Compilers
– Meijer
- 1992
|
|
28
|
Generic program transformation
– Moor, Sittampalam
- 1998
|
|
28
|
Polytypic pattern matching
– Jeuring
- 1995
|
|
25
|
Monadic maps and folds for arbitrary datatypes. Memoranda Informatica 94-28
– Fokkinga
- 1994
|
|
24
|
Designing and implementing combinator languages
– Swierstra, Alcocer, et al.
|
|
21
|
Fold and unfold for program semantics
– Hutton
- 1998
|
|
20
|
Designing circuits by calculation
– Jones
- 1990
|
|
18
|
About charity
– Cockett, Fukushima
- 1992
|
|
16
|
Polytypic unification
– Jansson, Jeuring
- 1998
|
|
6
|
Applicative style programming, program transformation and list operators
– Wadler
- 1981
|
|
6
|
Reactive functional programming
– Kieburtz
- 1998
|
|
5
|
Paramorphisms
– Meertens
- 1992
|
|
4
|
Translating attribute grammars into catamorphisms. The Squiggolist
– Fokkinga, Jeuring, et al.
- 1991
|
|
3
|
Circuit design in Ruby. Staunstrup (ed), Formal methods for VLSI design
– Jones, Sheeran
- 1990
|
|
2
|
A relational theory of datatypes. Available on the World-Wide-Web from http://www.win.tue.nl/win/cs/wp/papers/papers.html
– Aarts, Backhouse, et al.
- 1992
|
|
2
|
Revisiting catemorphisms over datatypes with embedded functions
– Fegaras, Sheard
- 1996
|
|
2
|
A pragmatic approach to maps and folds for parameterized datatypes. Submitted for publication
– Jones
- 1998
|
|
2
|
The Haskell language report, version 1.4. Available on the World-Wide-Web from http://www.haskell.org
– Peterson
- 1997
|
|
1
|
Reactive functional programming
– Chapman, Hall
- 1998
|
|
1
|
A tutorial on the universality and expressiveness of fold 17
– Kieburtz, Lewis
- 1994
|