Simplify nested lists

My Snap! skills have failed on me (again) :slight_smile:

How can I transform from 1st to the 2nd one (in generic manner - this is just a sample)

[edit] each list isn’t necessarily the same length

OpenSCAD_7_2_3_dev script pic (2)

OpenSCAD_7_2_3_dev script pic (3)

i.e. rows can contain any number of lists but they are all simple ones - there is no further nesting

I think you can use the append block to add two lists (or even more together) without forming a nested list

Could post an example of using append to get from 1st structure to 2nd structure

https://snap.berkeley.edu/project?username=redgeographysnap&projectname=append%20example

Maybe…


Thank you very much :slight_smile:

Is the input always of rank 3? (a list of lists of lists of atoms) If so, you can just do this:


If the input can be of any rank, then use dardoro’s solution.

Yes - it’s always going to be rank 3 so your answer will work as well :slight_smile:

But I’m struggling to see why your’s works :slight_smile: Give me a few minutes to see if I can work it out for myself :slight_smile:

[edit]

Of course, all I had to do was read how the block is coded using Snap! itself and all is now clear :slight_smile:

did you know that you can use reshape and if you leave dimensions blank (or enter zero) it will automatically fill them up to make it fit all the elements? This lets you easily and directly solve your issue like this:

Yes but

image

It’s more like stripping leaves from the tree that are simple lists (with rank=1).


, rather than creating uniform bricks of wood :wink:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.