mailing-list for TeXmacs Users

Text archives Help


Re: list of relative tree paths of matched trees


Chronological Thread 
  • From: Murali Agastya <address@hidden>
  • To: Giovanni Piredda <address@hidden>
  • Cc: address@hidden
  • Subject: Re: list of relative tree paths of matched trees
  • Date: Mon, 1 Feb 2021 11:12:53 +1100

Thanks Giovanni for the quick response. 
That is however not what I was looking for.   A concrete example may clarify,  (tree-search (buffer-tree) (lambda(s) (equal? (tree-name s) "proposition")))  will give be a list of all the "proposition" trees.  How do I get the  path of each of those "proposition" trees in the above list?     
best,
Murali


On Mon, Feb 1, 2021 at 10:42 AM Giovanni Piredda <address@hidden> wrote:


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.

Top of page