Dynamo List Compare

Hello Forum

Would I be able to ask for help with another list compare issue? I am stuck trying to compare two unequal lists of items. I have tried as both numbers and strings but I am not getting the output I expect. I would expect to see it true twice as there is both 2 and 4 in both lists, but it is only giving me true once in the list.

Please could anyone help? I have tested all of the other examples in the many list compare topics, but I cannot seem to get any to work.

Thank you for any help.
Tim

Hi Tim,

Your == node is only getting 1 true output because it is matching your items 1,2 to 4,2. So only the 2 match up this way. To Get around this i would use the node List.AllIndicesOf to get the indices of each individual value in your list. Also i added some nodes to recreate your true / false lists.

Like this:

2021-01-05 Comparing Sublists of Unequal Lengths.dyn (13.4 KB)

There are probably multiple (and better) ways that can achieve this result. Like setting the == node to cross-lacing, but i couldnt get the first list to only match up to the other first list.

2 Likes

Hi Daan

This is fantastic, thank you very much for your solution. I will give this a try. I usually use the == with cross-lacing as you mention, then use an AnyTrue node and then FilterByBooleanMark. However I still could not get the result, but it will be the issue you mention about only comparing certain indices. I will try again.

Thank you also for your graph.
Cheers
Tim

1 Like

Exactly, maybe making it a custom node would work if you are using the == node.

Thanks again Daan

I have managed to replicate your solution, but using strings not numbers. For some reason numbers from the code block did not work with the List.All.Indicies.Of node giving me Empty Lists? It worked when I convered them to strings, I had to use a rounding node to remove the decimal places, so maybe this is casuing an issue?


I am happy with the string data, so thank you again.
Tim

Hi Tim,

Check with the node Object.Type if you are possibly comparing Integers to Doubles. I don’t know if this is the problem but you could check that.

Great, many thanks again.
Tim