List Comprehension

So Im here studying again list comprehension and I got this apearently simple but tought exercise that I dont know how to face. The point is… I want a letter as an index for VALUE1,VALUE2, and VALUE3, being VALUE1 the items in L3, VALUE2, the items in L2, and VALUE3, the items in L1. So I would have an unique identifier like “A-A-A” for every item in the list.

This exercises are being as funny as frustrating for me!

What if your list was 3 levels deeper? How would you expect this to scale then? Likely your best best is to step back to the original keys which you used to group the values initially, and convert and combine those as desired. This will likely scale much better and reduce calculation time.

1 Like

This also brings up the question of the number of unique values within the list. If there are more than 26 values, how is this handled? As in spreadsheet applications, the label could be generated based on the number (e.g. the column after Z (26) is column AA (27), which expands indefinitely using the same rule. However, this may reduce readability if the labels are of different lengths (e.g. A-AB-D and C-D-E).

1 Like

Thats right but in this case I think thats not possible due to that the whole point of the exercise is group the values that way. I give you some context:

  • The objetive is to get an unique identifier for every single chair in a library. The criteria is that in the chair has to be referenced both the Space in which the chair is and the table that is closest to every chair. Spaces must be ordered from the bigger one (volume) to the smalest. And the tables for every space, from the top left, to the bottom right. And the chairs for every table table also from the top left, to the bottom right.
    Being that clear, I think the only way to solve this is first grouping the items that way. And then asigning the values (value1=space,value2=table,value3=chair).
    I know this is a theorical aproximation to list comprehension and that the definition have serious scalability problems. In this case there´s not gonna be problems cause there are only 3rooms, 6 tables, and 15 chairs.
    I also leave the definition and a RVT example file here in case that someone has more interest on this after reading this post. (I know for sure my definition is not optimal thought)
    Numeracion de sillas y mesas.dyn (105.9 KB)

This should actually make things easier (in theory). For each chair you would have to first find its relative location (top left to bottom right), then just get the nearest table, and the space. You can then use each of these values as a part of the unique identifier. This is the “best” way to go about automating a solution as it takes care of any potential list structure or scaling issues. It’s also logically how you want to group your chairs anyway.

Just as an example, here’s how you could accomplish what you initially asked for even if it’s not what your final solution will look like.


That was my initial aproach to the problem, but as I couldn´t do list structure on the code blocks I tried something else. Anyway, yours seems fine, but when I do the same I dont get the same result. I got the same output for all de count nodes except for the last one. What am I missing?

Your last List.Count needs to have Keep List Structure turned on. Your list structure doesn’t match otherwise.

1 Like

That was! Thanks!

I am trying to retrieve a list of items which are nearest to a difference of zero, yet l am getting this error…!
Any thoughts welcomed.

Please start a new thread so your issue can be documented separately from this one.

1 Like