Confused about joining text within complex data tree

Hello community!

It has happened again, I’m stuck! :smiley:
I’m getting this Data Tree as a result of an Anemone-Loop and want to join the resulting strings in a specific way.

Using a dash as separator I want to join every item in front of the item on the “next level” of the branch, if that makes sense. Probably mixing up terms here.
So for example, if I have 1 string on {0;0} I want to put that string in front of all strings on branches that have the form {0;0;X}. Further these strings should all be added to items of the form {0;0;X;Y} and so forth until there’s nothing more to add.

I very much doubt that what I just wrote makes sense to anyone so I’m adding a sketch that will hopefully make clear what I’m aiming to do :smiley:

Are there any Ideas? I’d be ever so greatful! :slight_smile: :slight_smile:

I’ve separated the branches by depth to make it clearer here but in the end it should work with Trees of even greater “branchiness” :smiley:

Data (5.4 KB)


How about this monstrosity ?

In 7 years I’ve never used data trees with different levels… Not certain without seeing the code genereting this atrocity but there should be a better solution to store the texts.

Data (13.8 KB)

1 Like

Yeah! That seems to work! thank you!! :slight_smile: :slight_smile:

haha atrocity indeed, the tree is the result of an iterative loop (Anemone) that tries to generate all possible ways to reconstruct a string with elements taken from a list of possible patterns. So it kind of makes sense that the path levels are increasing with every iteration. I’ve attached the script in case you are interested. Though now that i’m using your script to check my results I’m realising that its not giving me all possibilities - will need to check that again, anyway, super grateful for your help! :slight_smile:

Fragment (18.3 KB)

I don’t have Anemone (but expect it would give the same tree as in your first file), but is this what you want ?

not sure i understand - this basically creates a library of all possible combinations of adding 3 valid segmetns right? Well I guess i could create a sort of library of all combinations of all (realistic) lengths and then match my given strings with that. Rather than generate them ‘live’. However i dont exactly know how long my strings will get - maybe up to 30 segments - that’s a lot of combinations. but yeah maybe that’ll still be better than the live process, now that i think of it… thanks i migh try that!

ah yeah no of course - i can’t cross reference the list more than a handfull of times before we’re getting to “number of atoms in the universe” territory :smiley: :smiley:
ill try to get that iteration process right - in fact on checking it, i think it is right - there seems to be something in your script that doesn’t quite do what i want - it’s omiting solutions that are reached before the last level of the tree is reached, therefore only giving me those solutions containing many but short segments, if that makes sense - but i think i understand what you did well enough to find the mistake, let’s see :slight_smile:

I get all paths that are of the maximum length in the tree and then loop through all sub-paths, so even if the last path is empty, as long as it exists it should work. Maybe remove the first Clean Tree ?

I fail at understanding the inputs and outputs of this :sweat_smile: But pretty confident no Anemone is required.

The only ins and outs are that i have strings made up of Ls and Fs (LFFFLLLLLFLLFLL) and i have a list of allowed segments (ex LFF, LL, LLL,…) to separate the string into.
To illustrate: (for reasons that don’t make sense in english) F stands for ‘window’ and L stands for ‘no window’
now i have a list of specific panels, like for example LFF, LL, LLL etc… i need to find a way to get all ways to cut up this long string into these possible segements.

the reasons why i need all (or enough) combinations is that i’m then going to have to match the sequence of segment lengths to the ones on top or below.

LF-FFF-LFF …valid cause 2-3-3 matches 2-3-3

LF-FFF-LFF …not valid cause 3-2-3 doesn’t match 2-3-3 eventhough they are for themselves valid

so i’ve tried other non iterative ways but they all start breaking the bank when the string gets too long, so i’m gonna explore this solution a little more :smiley: :smiley:

haha so much for the ins and outs, sorry for the spam :smiley:

i very easily managed to adjust your script to my needs by adding a 0 to all empty branches so that they all run through to the end and then i just subsequently removed the ‘-0’ :slight_smile:

This is a job for recursion, I think this should be working as intended :

With the option to give a list of integers that filter the lengths of each pattern : (10.7 KB)

1 Like

Oh my God, Teddy you are magic indeed! You have just obliterated my worries of making this project work with a few lines of code - and it’s so much faster. Thank you, thank you, thank you!!
This means two things: i really really need to finally take a little time off to start to learn how to code python at least, and you are angelically kind for taking this time to help me! :slight_smile:

1 Like