[list-abs/list-find] finds the position of an element in a list. You can use this to split your list with [list split]. Here's an example:
[4 ( [1 2 3 4 5 6(
| |
[list-abs/list-find]
|
[t b f]
|
[list]
|
[list split]
| |
| [list split 1]
| |
[print left] [print right]
I hope the ASCII patch above is readable. The top [list split] sends its middle outlet to the bottom [list split 1], which in turn sends its middle outlet to [print right]. This way you'll get two lists printed, one by each [print], "1 2 3" and "5 6".
On 9/29/24 22:08, Peter P. wrote:
Hi list,
I am having lists with a variable number of items and I want to break them up two lists dependent on the presence of a specific item. I can't seem to understand how to do it though. Here's a quick example of what I mean:
1 2 3 4 5 6 look for the number 4 and output two lists (at separate outlets) which are before and after that number 4, giving: 1 2 3 and 5 6 respectively
I'd need the solution to work for lists of other lengths as well, i.e. 55 66 77 88 4 102 -33 should be broken up into 55 66 77 88 and 102 -33 alike.
I tried [route] and [list] objects but can't get them to do what I want.
thanks! P
pd-list@lists.iem.at - the Pure Data mailinglist https://lists.iem.at/hyperkitty/list/pd-list@lists.iem.at/message/7EF2SASANM...
To unsubscribe send an email to pd-list-leave@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.iem.at/