Group Admins

  • Profile picture of Karim
  • Profile picture of Jean

OpenMusic

Public Group active 3 hours, 42 minutes ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Lists and Recursive Sublists

Author 4 Subscribed Users |
Profile photo of nagymusic
nagymusic

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!

November 23, 2017 at 03:40 #24402
Profile photo of Karim
Karim

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

November 23, 2017 at 04:15 #24403
Profile photo of nadir B.
nadir B.

Hi,

In other ‘words’ (Cf. link)

šŸ˜‰

November 23, 2017 at 11:27 #24404
Profile photo of nagymusic
nagymusic

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!

November 23, 2017 at 15:28 #24410
Profile photo of MariaRose
MariaRose

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. :)

Best
L

Attachments:
  1. 12345.omp
  2. 12345.omp
November 23, 2017 at 19:40 #24411
Profile photo of nagymusic
nagymusic

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!

Attachments:
  1. 12358.omp
  2. 12358.omp
November 25, 2017 at 03:20 #24440
Profile photo of Karim
Karim

Hi,

Maybe this ?

Best
K

Attachments:
  1. ints.omp
  2. ints.omp
November 25, 2017 at 03:30 #24443
Profile photo of nagymusic
nagymusic

Thank you! This is it.

November 25, 2017 at 14:40 #24447

You must be logged in to reply to this topic.

Log in now