IndexOf


#1

Is there a way to get the index of all occurrences within a list?


#2

Follow up to my first post why does this IndexOf return -1 when the item I am looking for is in the list?


#3

Try the “List.AllIndicesOf” node.

About your second question, that’s just an oversight. Somebody just forgot that “-1” is a valid list index in DS:


#4

Dimitar,

Thanks for the reply, “List.AllIndicesOf” was what I was looking for. It unfortunately does not work if the list contains null values. I will put something together in the next couple of days and submit it to GH per your comment on my other post.

Thanks again,


#5

Steven,

If you use Clockwork’s List.ReplaceNull, to replace all the nulls with “nulls” it will give you what you want. I dont know if this causes you problems further down your graph.

 


#6

That would work and then I just look for “null”. I was trying to replace the null values with a matching index value from another list. Thats why I needed the index value. I ended up using an if statement and is value null. True use value from list B if false use value from list A.

Since many of the nodes do not take nulls I ended up replacing the null with a value the node would take and then placing the null back into the list after the node. Not very efficient but the only workaround I could think of at the time.

Thanks for the reply,


#7

Alternatively, for this particular case, you could try the “NullAllIndicesOf” from spring nodes.

2016-03-02_10-00-47


#8

Wow did not know that was in spring nodes. thanks dimitar,