Subject: mailing-list for TeXmacs Users
List archive
From : Giovanni Piredda <address@hidden>- To: address@hidden
- Subject: Re: list of relative tree paths of matched trees
- Date: Mon, 1 Feb 2021 00:42:24 +0100
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)
- Re: list of relative tree paths of matched trees, Giovanni Piredda, 02/01/2021
- Re: list of relative tree paths of matched trees, Murali Agastya, 02/01/2021
- Re: list of relative tree paths of matched trees, Giovanni Piredda, 02/01/2021
- Re: list of relative tree paths of matched trees, Murali Agastya, 02/01/2021
Archive powered by MHonArc 2.6.19.