Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build a tree from scratch if you can't insert on leaf nodes? #14

Open
Overdr0ne opened this issue Apr 27, 2024 · 0 comments
Open

Comments

@Overdr0ne
Copy link

If I try to insert a child on a leaf node, from a list zipper, treepy throws an error: "Called children on a leaf node", e.g.

(let* ((l '())
      (z (treepy-list-zip l))
      (z (treepy-insert-child z 1))
      (z (treepy-insert-child z 2))
      (z (treepy-down z))
      (z (treepy-insert-child z 3))
      )
  z)

Your tests show how to use a zipper created from an existing list. The much more common case would seem to be you start with an empty zipper, then add and remove things as needed. But how can you do that if you can't insert on a leaf node? How does clojure handle that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant