< Back to IRCAM Forum

Lists and Recursive Sublists

Could someone advise how to ‘recursively’ re-group a given list into a series of sublists? I suppose this could be somewhat similar to a rotation, by which the first element is systematically removed, except that the rotation process stops with the last ‘element pair’ in a list. Here’s what I wish to achieve given the list of four and five elements (assuming that this process could be applied to any number of elements in a list):

List (four elements): (1 2 3 4)
Sublists: (2 3 4) (3 4)

List (five elements): (1 2 3 4 5)
Sublists: (2 3 4 5) (3 4 5) (4 5)

Thank you!

Hi,

(maplist 'append '(1 2 3 4 5) )
OM => ((1 2 3 4 5) (2 3 4 5) (3 4 5) (4 5) (5))

Best
K

Hi,

In other ‘words’ (Cf. link)

:wink:

mapList.omp (1.12 KB)

Many thanks!! This is very helpful and all makes sense.

Just one more question, if I may. Now I’d like to get absolute intervals between ONLY the first and all others elements from the derived sublists. X->DX comes to mind, except that I’m not sure how to apply it to the constraint of what appears to be a cyclical process whereby the first element is always compared with the rest of the set: 1~1, 1~2, 1~3, 1`4, 1~5 (~ indicates an interval distance). I provide a bit more information below.

Following this:
(maplist 'append '(1 2 3 4 5) )
OM => ((1 2 3 4 5) (2 3 4 5) (3 4 5) (4 5) (5))

I’d like to get absolute intervals from each sublist by always comparing the first element with other elements from the list (e.g. 1~1, 1~2, 1~3, 1~4, 1~5, etc.). For example, the first two sublists from above (1 2 3 4 5) and (2 3 4 5) would produce the following intervals ((0 1 2 3 4) (0 1 2 3).

Eventually, if a derived interval is larger than, let’s say 10, it would be removed from the list of intervals.

THANK YOU!

Hi,

this is not exactly what you are searching for but maybe you can play around with it until you get a better solution…
I would also be interessted in how to solve it. :slight_smile:

Best
L

12345.omp (2.8 KB)

Thanks, everyone. This has been very helpful!

I had a chance to modify the MariaRose’s patch, which now recursively generates absolute interval distance between each successive element from the given list. See attached (I changed the sequence to something more complex to reflect different interval distances). However, I’m still looking for ways to get absolute intervals by always comparing the first element with other elements from the list. For example, the given list (1 2 3 5 8) should produce the following interval distances ((1 2 4 7) (1 3 6) (2 5) (3)).

In case anyone has further ideas, and if it would help to know, my ultimate goal is to get absolute pitch interval distances found within any chord or sonority. In fact, I welcome your advice if a function or library extension already exists for this type of calculation. Thank you!

12358.omp (3.47 KB)

Hi,

Maybe this ?

Best
K

ints.omp (3.06 KB)

Thank you! This is it.

Hello!
Would someone be able to suggest how to derive all possible pairs of digits from the given set? For instance, a list (1 2 3) should produce (1 2) (1 3) (2 3).
Thank you!

I attached a patch illustrating what I have done so far. Here, the ‘multiindexing’ OMlopp accepts the given list (1 2 3), and in turn produces (1 1) (1 2) (1 3) (2 2) (2 3) (3 3). Might anyone know how to modify the iteration so to exclude the following pairs from the list: (1 1) (2 2) (3 3)? Thanks again!

pairs.omp (4.85 KB)