First item of first sublist, second item of second sublist

Hi all,

First time posting here but reading other posts on these forums has been an invaluable resource as I’ve been learning Dynamo so many thanks for that.

So I have a problem which sounds simple but I can’t work out. What it comes to is that I have a list which has N sublists, all of which have N sublists of their own. There are further levels of nesting beyond this, but I don’t think that’s relevant right now. What I want is to return the first element of the first sublist, the second element of the second sublist, the third of the third sublist and so on. Basically for a list ‘X’ I would want a new list ‘Y’ where Y[n] = X [n][n] for all n between 0 and N-1 i.e Y = {X[0][0],X[1][1],X[2][2]…}. Is this something anyone has encountered before?

Many Thanks

Like this?
NthOfNth

5 Likes

Exactly like that!

I eventually worked out my own solution by basically flattening the list and having a section of the graph working out the indices I wanted to retrieve. Yours is a much simpler solution although I have to admit I don’t entirely understand it, I haven’t used the ‘use levels’ checkbox before. Is there a tutorial anywhere you’re aware of which explains how exactly this works?

Many thanks again for your solution!

Start here:
http://dynamobim.org/introducing-listlevel-working-with-lists-made-easier/

2 Likes

Many thanks Andreas