Cycle therapy: a prescription for fold and unfold on regular trees
Cycle therapy: a prescription for fold and unfold on regular trees
复制标题
自行车疗法:在普通树木上折叠和展开的处方
DOI:
10.1145/773184.773200
复制
发表时间:
2001
期刊:
影响因子:
--
通讯作者:
J. Wells
中科院分区:
文献类型:
--
作者:
F. Turbak;J. Wells
Cyclic data structures can be tricky to create and manipulate in declarative programming languages. In a declarative setting, a natural way to view cyclic structures is as denoting regular trees, those trees which may be infinite but have only a finite number of distinct subtrees. This paper shows how to implement the unfold (anamorphism) operator in both eager and lazy languages so as to create cyclic structures when the result is a regular tree as opposed to merely infinite lazy structures. The usual fold (catamorphism) operator when used with a strict combining function on any infinite tree yields an undefined result. As an alternative, this paper defines and show how to implement a cycfold operator with more useful semantics when used with a strict function on cyclic structures representing regular trees. This paper also introduces an abstract data type (cycamores) to simplify the use of cyclic structures representing regular trees in both eager and lazy languages. Implementions of cycamores in both SML and Haskell are presented.