Way to tell if a given list index # is in another set of numbers?

I would like to basically do an “includes” operation, but on multiple numbers.
I have a list of indices… and I want to pick out specific indices if they match some other numbers, ie. ‘2, 5, and 10’ (or the result of some other/multiple calculations).

I tried to do this with the ‘Includes’ and also the ‘Equality’ operator, but it doesn’t seem to work for multiple numbers.

Does anyone know of an operator that will work on a list, to tell if a given index/number is within a another set of numbers?

For this you can use the Member Index component:
image

1 Like

Thanks! Gave it a go, but it doesn’t seem to be producing output for the matching numbers… any idea why? The data seems to be the same types as your example…

place a text panel between the member and gene pool and then it will work

1 Like

Ahh, unclear why the data type incongruency, but it works. Thanks a lot! :raised_hands: :slight_smile:

1 Like

Maybe I did not look for the correct solution…

This solution does work to tell if a member is in a given set of numbers… however, I need to produce a list of basically ‘True/False’ of whether or not the number is in the index set, for the entire original set.

So in the above example, I’d like to compare the List Indices to the gene pool, and generate a full list of the indices with ‘True/False’ if they are or aren’t in the gene pool. So the result above would be all False with indices 2, 5, and 10 set to True…

Trying to think of how to do this… do you have any ideas? Is there a way to construct a domain and then have it replace numbers

maybe this:


list_contains.gh (7.1 KB)

1 Like

Ah thanks, this is good! I’m a programmer, but haven’t gotten into scripting in grasshopper yet. Thanks for the introduction… way easier to implement some of these approaches this way :slight_smile: Cheers :raised_hands: