User loginNavigation |
"Folding"/FP traversal over treesI've been working on defining a "fold" operation for trees. There was some helpful discussion in the past "Folding over trees", but I haven't been able to find anything beyond the XML-type examples suggested there. My problem: I want to have more control of the traversal. That is, when a certain node is reached I want the possibility of skipping further descent, or reentering an already-traversed node. So yeah, this isn't actually a "fold". Maybe its a "visitor with control"? Olin Shiver's paper "The Anatomy of a Loop" (previously on LtU) discusses a general framework for separating these kinds of concerns.. But I'm looking for something a bit simpler.. (and am doing this in C++ besides) So... any suggestions on general FP approaches to this kind of problem? [hopefully this isn't OT!] (seed 'fup node) => (next-seed, reenter-children?) (seed 'fdown node) => (next-seed, skip-children?) (seed 'fhere leaf) => (next-seed, skip-the-rest-of-the-children?) By dbfaken at 2006-12-06 15:51 | LtU Forum | previous forum topic | next forum topic | other blogs | 11522 reads
|
Browse archives
Active forum topics |
Recent comments
27 weeks 2 days ago
27 weeks 2 days ago
27 weeks 2 days ago
49 weeks 3 days ago
1 year 1 week ago
1 year 3 weeks ago
1 year 3 weeks ago
1 year 5 weeks ago
1 year 10 weeks ago
1 year 10 weeks ago