Am 01.02.2021 um 00:00 schrieb Murali Agastya:
Hello all,
I am able to get a list of all the subtrees of a given name in a given tree T using the function(tree-search T (lambda(s) (equal? (tree-name s) name)) )
Can someone help me with an analogous script that returns the list of relative paths of those trees instead of the trees themselves?
Thank you and kind regards,Murali
It is possible that I am misunderstanding your question, said this.
Get the list of paths of the subtrees mapping tree->path on the results of your _expression_
Get the path of the parent tree with (tree->path T)
Use the following to map onto the list of paths (assumes parent is a parent of child!):
(define (relative-path parent child)
(cond ((null? parent) child)
(else (relative-path (cdr parent) (cdr child)))))With results:
(relative-path '(1 2 3) '(1 2 3))
; ()
(relative-path '(1 2 3) '(1 2 3 4))
(4)
Archive powered by MHonArc 2.6.19.