< Back to IRCAM Forum

Indexed sub-list

Good evening all
is there a way to assign an index to a series of sublists or elements contained in a list? For example: ((0 2 3) (6 11 9 7 ) ( 8 5 ) (1 4) (10))
(0 2 3) = a
(6 11 9 7 ) = b
( 8 5 ) = c
(1 4) = d
(10) = e
Thanks for your help
AB

Dear AB

Yes of course. There is a Lisp mechanism for that:

and here is the patch:
indexed_sub-list.omp (3.2 KB)

I hope that what’s you were looking for.

Best
K

Hi,

I was going to figure how to do that ! And here it is ! Thank you both !

Still Karim, as you can see on the attached screenshot, there is an error while evaluating… kind a curious.

N.

Yes dear Nadir, this is due to the usage of symbol. It’s always problematic.
But how about this?:
Screenshot_2024-11-28_00-41-08

Best

Thanks for your reply Maestro,

I hope this does not scramble Able thread, otherwise I will open another one.

The index is very important because I want to compare items in multiple sublists and then have as a result the indexes of the sublists that include a given approximation of an item, i.e. let’s say I have :

list 1 : ((a1) (f1 f2)) ((b1) (f’1 f’2)) ((c1) (f"1 f"2))…

list 2 : ((a2) (f1 f2)) ((b2) (f’1 f’2)) ((b3) (f"1 f"2))…

list n : ((an) (f1 f2)) ((bn) (f’1 f’2)) ((cn) (f"1 f"2))…

Input : fn

If fn is included in list1 or/and list2… or/and listn (even if it is an approximation, I know I have to constraint that approximation)

Outcome : The index of that list

What do you think, any hint please :slight_smile:

Thanks again,

N.

Outcome : The indexes of any list including that Input

Dear Nadir,

How about this:

the patch:
indexed_sub-list-1.omp (3.5 KB)

Best
K

Thanks Karim !

Well, I want it the other way around i.e. from the example above :

input = (6 11 9 7) → output = b
And even : input : 6 or 11… → output : b

N.

That would be so practical to have all these lisp-fx documented, I could spare some time to help if ever… At least we can already retrieve them thanks to your tab-completion addon !

Maybe something like this:

the patch:
indexed_sub-list-1-inv.omp (4.8 KB)

Best
K

1 Like

Yes something like that ! Thank you Karim.

And thanks to Able for bringing the question.

All the best,

N.