Journal article
Under-appreciated unfold
- Abstract:
- Folds are appreciated by functional programmers. Their dual, unfolds, are not new, but they are 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.
Actions
Authors
- Publisher:
- Association for Computing Machinery
- Journal:
- Proceedings of the ACM SIGPLAN International Conference on Functional Programming, ICFP More from this journal
- Pages:
- 273-279
- Publication date:
- 1998-01-01
- Language:
-
English
- Pubs id:
-
pubs:329415
- UUID:
-
uuid:d4a2d5e1-7c9c-4d70-8eac-7e23eb6f699f
- Local pid:
-
pubs:329415
- Source identifiers:
-
329415
- Deposit date:
-
2013-11-17
Terms of use
- Copyright date:
- 1998
If you are the owner of this record, you can report an update to it here: Report update to this record