Nested for loop and 2D lists

Hi,
I have a problem with nested FOR loop.

  • I have two list with 10 subtlist within it

  • I want to check if each element on the 1st sublist in first list is present on the 1st sublist in second list.

  • Next check 2nd sublist first list and compare with 2nd sublist second list etc.
    So far I wrote this but it does not work

    Odniesienie;
    Kable;
    Wejscie1;
    Wejscie2;
    Test2 = [Imperative]
    {
    warunek = {};
    for (i in Wejscie1)
    {
    Wejscie1[i];
    Wejscie2[i];
    for (j in Wejscie1[i])
    {
    for (k in Wejscie2[i])
    {
    x = Kable[i][j];
    y = Odniesienie[i][k];
    if (x == y)
    {
    warunek[i][j][k] = "Tak " + x + “" + y;
    }
    else
    {
    warunek[i][j][k] = "Nie " + x + "
    ” + y;
    };
    //return = Kable[i][j];
    //return = l;
    //return = Wejscie2[k];
    }
    //return = warunek;
    }
    //return = warunek;
    }
    return = warunek;
    };

@Robert1992 If I understood your intent, you should be able to do this in a simpler way.
Hope this helps …

1 Like

Today I did workaround my problem (graph below). The problem was in get value from sublist via for loop. Check two values was just an example. Here’s what I means in details:

  1. Get BoundaryBox and filtered details items (easy)
  2. Group all the elements by owner view (easy)
  3. Check which element from first group intersects other element from second group (all elements are on the same view) (problem with for loop).
  4. If yes set ID.

Problem with this script is in performance. 3 views, ~70 elements in first group, ~520 elements in second group, over 46k combinations and about one minute execute.

One minute for ~42,000 tests isn’t a bad run time, but maybe limiting the initial selection would help speed things along? Maybe something like all elements in active view for a selected list of views (controlled by a radio button input) and filtered by category would help? Elements would also be grouped by view as a result so one less grouping exercise too.

Thanks for help but for now I would like to remove unnecessary tests without filtering element by active view. I think that will be enough to change the script from first screen but I don’t know how.