Hi, Am 16.10.2008 um 23:07 schrieb Meikel Brandmeyer:
I'll will mull a bit more about this. But something along the lines of (goto loc some-predicate path) seems like it could do what it want.
Ok. The attached patch is what I came up with. It is actually split up in two functions walk-along-and-do and walk-along. (Naming suggestions welcome). So the idea is: I give it a location in the zipper, a predicate to identify the nodes and path, which is basically a sequence of things. (pred node thing) should identify the desired node however. Using this I successfully implemented a two-tree widget in Swing, where selected nodes are moved between the two widgets inserting dependent structure as necessary. Here I also saw the need of a try-walk-along, which returns the last node of the path, which is contained in the tree and the rest of the path, which is missing. So I extracted the walker code and added two callbacks, a found-action and a not-found-action. In the current implementation it only finds the left-most path in a tree, in case the nodes are not unique. The difference to your XML code is, that xml-> allows a different filter for each step. This is not the case here. Sincerely Meikel
walk-along.clj
Description: Binary data
smime.p7s
Description: S/MIME cryptographic signature