Combine lists with different depth


Hi,

I’ve been struggling with this for a while… How can I achieve this?

1 Like

List.Create > List.Transpose. > List.Flatten (watch the list levels - likely want L4 or L3).

Thanks fot the reply! @jacob.small

Yes, I agree it should be solved with something like that, but can’t get it to work…

I rebuilt it with numbers so it’s easier to follow, but this is as far as I get. Any suggestions on how it can be changed?
The list structure can vary between each run of the script (the two structure types, both reversed and only each type of them), so I want to build it as flexible as possible.

Need to see the results of the List.OfRepeatedItem node (the amount is hidden).

Sorry for that!

Still can’t really see the structure of the various lists; feels like you’re adding unecessary depth early on. If data structures aren’t clean then it’s likely a sign that things can be done more effectively in the larger context. In this example, I’d look at List.AddItemToEnd pointing at the right level and with correct lacing as one example, but again I’d need the context to be sure.

The different depth appears in the IF-node, depending on earlier nodes and needs to be like that.
Here’s an overview of that part:

Does it help you to understand better?
The result should be as in the original post, but List.AddItemToFront doesn’t return the result that I want.

Sadly not; can you build a pair of lists in code blocks that duplicate the expected and post the .dyn?

Unfortunately I’m not allowed to do that since I needed to create a new account…

Bumped your trust level so you aren’t a ‘new user’ anymore. If it still doesn’t work you can post a link to a 3rd party hosting site such as Dropbox, Google drive, wetransfer, onedrive, etc…

List_test.dyn (12.3 KB)
Thanks!

Hi @JG-Dyn ,

Would a List.Combine with a List.Join as combinator work here?

PS: I don’t really know what is going on with your list levels/ structure and I agree with Jacob, it can probably be simplified, are those complicated list levels really necessary?