Hi,
I need to check a list with 11 elements for 0 (or 1) and would like to know which element has it.
I could do it like this...
[unpack f f f f f f f f f f f] and then on all outlets [sel 0]-[1(, [2( etx
...but rather just search the list.
Thanks!
Search list
Hi,
I need to check a list with 11 elements for 0 (or 1) and would like to know which element has it.
I could do it like this...
[unpack f f f f f f f f f f f] and then on all outlets [sel 0]-[1(, [2( etx
...but rather just search the list.
Thanks!
@cfry You can use [list-find] from list-abs.
I also made an alternative version that works the same: list-find.zip
@cfry It is also possible to put the list into an array and use [array max] to find the positions of all 1s:

thanks, that is neat.
So operations like this are more suitable for arrays, since there is no vanilla function?
@cfry With lists, the only way is to go element by element. [array] has max and min and sometimes they can be used in such ways. 
@cfry While you do have to go element by element with lists, you do not need to unpack the list, you can drip it which allows lists of any length.

list-search.pd
Edit: Fresh eyes revel a flaw, right outlet of [list store] bangs after the list is empty so the counter goes one to many, works for lists which end in zero but not those which end with a one. Suppose the simple fix is to just trigger the [until] with a [list length] instead of relying on [list store] to stop it.
Oops! Looks like something went wrong!