Grasshopper Item Index Issue

Can anyone tell me why this doesn’t work? I have a list items, and want to replace some of them based on a boolean list. Looks like the replace only takes and index and not a pattern, so I thought I could use the List Index component to see which are true, but that doesn’t seem to work. Any thoughts.

Actually I figured out a way to do with the pick and choose component, which puts in a “null”, and then I was able to replace that null. Still not sure why the first method didn’t work.

List Index only compares identical values, not similar ones. Ie. they have to exist in the same location in memory, it’s not enough for them to have the same value. You can use Member Index in the Set panel if you want to find items by value.

This is a very common mistake, List Index should have been called something scary like ‘Memory-wise lookup’ or something…

2 Likes

Thanks for reply. I figured it was similar to what list.index(x) in python does, which if I not correct compares values, or maybe that is just what it looks like on the surface.

I don’t know about Python but the C# List.IndexOf method relies on the Equals method of the data itself, which may use value like equality, or it may use reference like equality, or it may just always return true or false, it depends on whoever designed the types in question. The Grasshopper index components do not use type equality, they always use either reference equality or value equality. The downside is that Member Index can only handle simple data types, it won’t work for Curves or Breps or Meshes or…