Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Red [
Title: "Walk through a VID tree (non-recursive)"
Author: "Christopher Ross-Gill"
Date: 18-Aug-2019
Comment: "Goes backwards - most prominent faces first"
]
Rebol [
Comment: "Works in Rebol 2 as well"
]
walk-through: func [
face [object!] invoke [any-function!]
/local parents stack
][
parents: make block! 5 ; arbitrary block space allocation
stack: reduce [face]
while [not empty? stack][
face: first stack
case [
not all [
object? :face
in face 'pane
][
remove stack
]
same? face pick parents 1 [
; we've already handled the kids
remove parents
remove stack
invoke face parents
]
object? get in face 'pane [
insert parents face
insert stack face/pane
]
block? get in face 'pane [
insert parents face
insert stack reverse copy face/pane
]
face [
remove stack
invoke face parents
]
]
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.