Re: break a variable length list at a specific element

Alexandros Drymonitis <[email protected]>
Newsgroups gmane.comp.multimedia.puredata.general
Message-ID <[email protected]>
[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
>
> ---
> [email protected] - the Pure Data mailinglist
> https://lists.iem.at/hyperkitty/list/[email protected]/message/7EF2SASANM67WTX766GIKCN5OIR64PXN/
>
> To unsubscribe send an email to [email protected] mailing list
> UNSUBSCRIBE and account-management -> https://lists.iem.at/
>

---
[email protected] - the Pure Data mailinglist
https://lists.iem.at/hyperkitty/list/[email protected]/message/YZUHKCUC64EDGFQ4DCVRLI2DKGE6VY6P/

To unsubscribe send an email to [email protected] mailing list
UNSUBSCRIBE and account-management -> https://lists.iem.at/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.