< Back to IRCAM Forum

Count repetitions in a list

Hello Hello,

quick question. Is there an object that will return the number of repetitions in a list?

for exemple.

(1 1 1 1 2 2 2 2 1 1 1 2 2 2) would turn into (4 4 3 3)

thanks you!

Hi maringauthier,

No there is no ready-made function.
However you can do the following:

  1. group all successive repetitions
  2. then count each group:

Here is the folder with the lisp function and patch.
Just unzip, then import the folder into your workspace:
count_repetitions.zip (1.8 KB)

Best
K