TY - GEN
T1 - Backtracking iterators
AU - Filliâtre, Jean Christophe
PY - 2006/9/16
Y1 - 2006/9/16
N2 - Iterating over the elements of an abstract collection is usually done in ML using a fold-like higher-order function provided by the data structure. This article discusses a different paradigm of iteration based on purely functional, immutable cursors. Contrary to fold-like iterators, the iteration can be cleanly interrupted at any step. Contrary to imperative cursors (such as those found in C++ and Java libraries) it is possible to backtrack the iterator to a previous step. Several ways to iterate over binary trees are examined and close links with Gérard Huet's Zipper are established. Incidentally, we show the well-known two-lists implementation of functional queues arising from a Zipper-based breadth-first traversal.
AB - Iterating over the elements of an abstract collection is usually done in ML using a fold-like higher-order function provided by the data structure. This article discusses a different paradigm of iteration based on purely functional, immutable cursors. Contrary to fold-like iterators, the iteration can be cleanly interrupted at any step. Contrary to imperative cursors (such as those found in C++ and Java libraries) it is possible to backtrack the iterator to a previous step. Several ways to iterate over binary trees are examined and close links with Gérard Huet's Zipper are established. Incidentally, we show the well-known two-lists implementation of functional queues arising from a Zipper-based breadth-first traversal.
KW - Backtracking
KW - Iteration
KW - Persistent data structures
UR - https://www.scopus.com/pages/publications/34247348223
U2 - 10.1145/1159876.1159885
DO - 10.1145/1159876.1159885
M3 - Conference contribution
AN - SCOPUS:34247348223
SN - 1595934839
SN - 9781595934833
T3 - Proceedings of the ACM SIGPLAN 2006 Workshop on ML
SP - 54
EP - 62
BT - Proceedings of the ACM SIGPLAN 2006 Workshop on ML
PB - Association for Computing Machinery (ACM)
T2 - ACM SIGPLAN 2006 Workshop on ML
Y2 - 16 September 2006 through 16 September 2006
ER -