clamp-gadget-path ( path gadget -- path' )


Vocabulary
ui.traverse

Inputs
pathan object
gadgetan object


Outputs
path'an object


Definition


:: clamp-gadget-path ( path gadget -- path' )
path empty? gadget not or
[ { } ] [
gadget children>> :> children children empty?
[ { } ] [
path first 0 children length 1 - clamp
:> index path first index = [
path rest-slice index children nth
clamp-gadget-path
] [ { } ] if index prefix
] if
] if ;