< Back to IRCAM Forum

OM function to extract sub-lists from their own data?

HI all

I am in trouble with the following patch programming.
Let’say I have ((0 a)(0 b)(1 c)(2 d)(2 e)(3 f)…))

I want to extract the sublists whose 1st element is (1) and/or (2),
[Expected output: ((1 c)(2 d)(2 e))]

then group together sub-lists with the same 1st element
[Expected output: ((1)©)((2)(d e))]

Guess 1st step has to do with sort-list, but don’t have any success for the while…

Thanks for the help anybody… :wink:

Didier

Hi
this patch for your first step.

Best
K

Patch-3.omp (3.24 KB)

Thanks Karim!

But 1 and 2 were only examples. It would be in fact a single list of integers of variable length… (1 3 4)…

Best

Didier

This might look a little convoluted but does the job in a one-stop-shop way

you can easily add the parenthesis within the groups in the loop if you need them

Michele

Screen-Shot-2014-04-09-at-1.56.26-PM.png

PS I wasnt able to open Karim’s, how do you save the file in order to open in in OM?

Thanks Michele

I will try your patch now.
When one downloads a .omp from here, the computer may add a .txt suffix (on the Mac at least). You have to manually remove it and put the patch into your “elements” workspace folder. And quit then reload OM (the “upgrade workspace” does not appear to function in this case).

Best

Didier

Michele

Works fine! Thanks a lot to both! :slight_smile:

(the “standard” way to import .omp files is rather to right-click on the workspace and Import File/Folder – then no need to restart OM)