Open alphapapa opened 7 years ago
Hey,
You are right, it's missing some examples.
For the time being, the best way to see the functions in action is by going through the tests, particularly:
https://github.com/volrath/treepy.el/blob/master/test/treepy.el-walker-test.el#L75 https://github.com/volrath/treepy.el/blob/master/test/treepy.el-walker-test.el#L103
Which show the traversal order for treepy-prewalk
and treepy-postwalk
respectively.
Regarding treepy-walk
, it applies inner
to each element of the given form. In your example list, it would apply inner
to a
and then to (list b c)
. treepy-walk
doesn't really take care of recursion, that's the job for treepy-prewalk
and treepy-postwalk
. You can think of it as a helper function that you can use to create your own "walkers" or "reducers". This test might also help with that clarification.
Also, you can go through the zipper tests to see examples of the zipper structure. And Alex Miller's article on tree visitors in Clojure is really useful as well.
I'll leave this issue open and close it when better examples are provided. Thanks for the feedback!
Thanks!
Hi,
This is really cool, thanks for sharing it.
It would help a lot to have some examples, especially for Emacers who haven't used Clojure before. I was hoping the links to the Clojure docs would have some examples, but it seems as sparse as the definitions here. :)
For example,
treepy-walk
seems confusing to me: from the docstring, it sounds like it appliesinner
to each leaf of the tree, but looking at the code, it doesn't seem like it would do that for a list like:Maybe I'm misunderstanding it, though.
Thanks.