Hi,
I put together a little implementation for traversals. It is inspired by an original implementation from Mariano. Using DeepTraverser, you can traverse arbitrary graphs by describing the traversal and by specifying the actions you want to perform on the nodes and relations.
The code is available in the Moose image as part of the MooseAlgos subproject, but can also be loaded separately in a Pharo image via:
Gofer new
package: ‘ConfigurationOfDeepTraverser’;
load.
(Smalltalk globals at: #ConfigurationOfDeepTraverser) loadDevelopment.
Just to give you an idea, here are some representative examples:
Number
deep: #subclasses
do: [:each | Transcript show: each; cr].
Number deepCollect: #subclasses.
Number
deep: #subclasses
collect: #name.
Number
deep: #subclasses
do: [:each | Transcript show: each; cr]
relationDo: [ :from :to | Transcript show: from; show: ' <-- '; show: to; cr ].
More details about the usages and a little description of the implementation can be found here:
Cheers,
Doru
--
"Every thing has its own flow"