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 | 11495 reads
|
Browse archives
Active forum topics |
Recent comments
22 weeks 6 days ago
22 weeks 6 days ago
22 weeks 6 days ago
45 weeks 20 hours ago
49 weeks 2 days ago
50 weeks 6 days ago
50 weeks 6 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago