Publication View

The Under-Appreciated Unfold (1998)

Abstract
Folds are appreciated by functional programmers; the benefits of encapsulating common patterns of computation as higher-order operators are well-known and well understood. Their dual, unfolds, are nearly as well-known, but not nearly as well appreciated. We believe they deserve better. To illustrate, we present (indeed, we calculate) a number of algorithms for computing the breadth-first traversal of a tree. We specify breadth-first traversal in terms of level-order traversal, which we characterize first as a fold. The presentation as a fold is simple, but it is inefficient, and removing the inefficiency makes it no longer a fold. We calculate a characterization as an unfold from the characterization as a fold; this unfold is equally clear, but more efficient. We also calculate a characterization of breadth-first traversal directly as an unfold; this turns out to be the `standard' queue-based algorithm. Keywords: Program calculation, functional programming, fold, unfold, anamorphism, ...

Publication details
Download http://citeseerx.ist.psu.edu/viewdoc/summary?doi=?doi=10.1.1.46.708
Source ftp://ftp.comlab.ox.ac.uk/pub/Documents/techpapers/Geraint.Jones/FP-1-98.ps.Z
Publisher ACM Press
Contributors CiteSeerX
Repository CiteSeerX - Scientific Literature Digital Library and Search Engine (United States)
Keywords Program calculation, functional programming, fold, unfold, anamorphism, co-induction, traversal, breadth-first, level-order
Type text
Language English
Relation 10.1.1.100.9674, 10.1.1.41.125, 10.1.1.100.8004, 10.1.1.104.7428, 10.1.1.36.2763, 10.1.1.47.8825, 10.1.1.34.8466, 10.1.1.32.5446, 10.1.1.39.5363, 10.1.1.7.121, 10.1.1.41.7383, 10.1.1.11.8332, 10.1.1.41.5647, 10.1.1.35.1593, 10.1.1.103.6073, 10.1.1.104.4178, 10.1.1.106.738, 10.1.1.5.818, 10.1.1.133.9794, 10.1.1.102.1945, 10.1.1.96.6938, 10.1.1.97.195, 10.1.1.117.3764, 10.1.1.104.1972, 10.1.1.104.20, 10.1.1.104.5859, 10.1.1.107.9150, 10.1.1.11.114, 10.1.1.16.1915, 10.1.1.41.3607, 10.1.1.66.143, 10.1.1.66.2291, 10.1.1.66.4020, 10.1.1.78.4399, 10.1.1.95.4869, 10.1.1.96.2612, 10.1.1.114.7683, 10.1.1.120.4354, 10.1.1.123.2354, 10.1.1.21.179, 10.1.1.8.9256, 10.1.1.60.7751, 10.1.1.62.1028