Walking Trees Backwards

Randall Reetz randall at randallreetz.com
Thu Sep 11 18:12:34 EDT 2008


The "do" restriction has to do with the complexity of constructing do statements or speed of execution? 

-----Original Message-----
From: "David Bovill" <david at architex.tv>
To: "How to use Revolution" <use-revolution at lists.runrev.com>
Sent: 9/11/2008 12:51 PM
Subject: Re: Walking Trees Backwards

Yes - thanks that's what I was thinking.... it does not work though as while
the maximum depth are all leaves of a tree structure there are other leaves
lower down the branches. So I think I'll have to use a technique I've done
before which is to turn the tree into an index of paths. So in your example:

task1
>    task1.a
>    task1.b
>        task1.b.1
> task2
>    task2.a
>        task2.a.1
>    task2.b
>    task2.c
> task3


becomes

task1
task1/task1.a
task1/task1.b
task1/task1.b/task1.b.1
task2
task2/task2.a
task2/task2.a/task2.a.1
task2/task2.b
task2/task2.c
task3

No each line is a leaf, and yu can do what you want to the index, as it is
easy to reconstruct the outline from the paths (order does not matter). Now
the "problem" with the new arrays":

What I really want to do with a line like "task1/task1.b/task1.b.1" is stuff
like:

put ""task1.b"" into outlineArray ["task1"]
put "task1.b.1" into outlineArray ["task1"]["task1.b"]

Things like:

put keys(outlineArray ["task1"])  => task1.b

Seem to work fine. And you can use vaiable keys - so:

put "task1" into someKey
> put "task1.b.1" into outlineArray [someKey] ["task1.b"]
> put keys(outlineArray)  => task1


Yet to be able to write a recursive function I need to be able to do this
without knowing how deep I am in the recursion: I'm going to try doing that
by defining a function to put a value into an array. I can't see how thats
possible right now without "do" in which case I would give up and keep using
XML as it will be faster.
_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list