< Back to IRCAM Forum

Group-list with expanded functionality

Hello,

I hope also suggestions are welcome here. I have a suggestion for an expanded version of group-list. I’ve been able to implement this via patches, but in seems to be highly inefficient as I personally need it for a test function. Maybe others would find it useful, too.

Here is what my patch does:
-Groups lists normally, eg. (1 2 3 4 5 6) (1 2 3) → ((1) (2 3) (4 5 6))
-Allows repetitions in grouping, signified here by a minus sign: eg. (1 2 3 4 5 6) (1 2 -3)-> ((1)(2 3)(3 4 5))
-In the case the first number is negative, the repeated element is taken from behind the list:
(1 2 3 4 5 6) (-1 2 -3) → ((6) (1 2) (2 3 4)).

Would someone here be able to implement a version that would be faster?
Thanks!

Dear Teemu,

If I understand you well, the minus sign just shifts the list by one element. If this is correct, your algorithm could be expressed as:


And therefore transcribed into a lambda function graphical object.

Here is the lisp code (if you need), and the om folder (to be imported after unzipping into your workspace.

Lisp code:
grplst.lisp (528 Bytes)

The folder:

grplst.zip (1.8 KB)

Best regards

K

Hi,
here an update of the code to make it work circularly

Lisp code:
grplst1.lisp (625 Bytes)

om folder:
grplst 2.zip (1.9 KB)

Best
K

Thank you! It seems to work correctly.

Teemu