Hello everyone :)
How can I have the index of true values of a spread in gamma?
In beta I was used to use the node select, but in gamma i don’t think it is the correct node to do this:
Thanks a lot,
have a good year ;)
Hello everyone :)
How can I have the index of true values of a spread in gamma?
In beta I was used to use the node select, but in gamma i don’t think it is the correct node to do this:
Thanks a lot,
have a good year ;)
Hey @Martina1
You could use a ForEach region to achieve such a thing. I would suggest watching this tutorial first to get an overview of how to use it :
Now to answer your question, you could use the following :
What’s happening here is that we’re iterating over all the slices of the input spread of integers, and we are exiting or “breaking” the loop when the condition is satisfied (here : when the value is equal to 3).
We then connect the Index
pin to the accumulator output of the region (the one that has a diamond shape) : doing that will always only return the last value of the iteration.
Since we are breaking the loop when the condition is satisfied, the accumulator gives us the index of the slice that satisfies the condition.
If you want to get all the values that match your condition, you would rather do it like that :
You can see it’s almost the same thing with two differences :
Break
pin of the region, but rather Keep
: this kinda acts like a Select
in beta : for each iteration that sets this Keep
pin to True
, the value is outputted from the region.= 3
).Now you could argue that you could as use the second example with a FirstOrDefault
node if you’re only interested in the first slice :
But I find the first one to be more straightforward :)