On Sun, Aug 13 Edward K. Ream wrote:
> Is it possible to write [*c.all_vnode_positions*]?
You bet:
def all_vnode_positions(self) -> Generator:
c = self
to_be_visited: list[VNode] = [c.hiddenRootNode]
while to_be_visited:
v = to_be_visited.pop()
yield v
for child in reversed(v.children):
to_be_visited.append(child)
This generator passes the following consistency test:
vnodes1 = [c.hiddenRootNode] + [z.v for z in c.all_positions()]
vnodes2 = list(c.all_vnode_positions())
assert vnodes1 == vnodes2
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/leo-editor/CAMF8tS1rwk6A6QnYeCoVwKEcJ6RiAxhUS8DRzLa4VbdOztUbTQ%40mail.gmail.com.