< Back to IRCAM Forum

While in omloop

Hy everyone,

I’m trying to built a patch that divides a given number X into a given number Y of different integer, not float, numbers (was that comprehensive? lol)

I couldn’t find a way to do that so now I’m trying to choose randomly from a list numbers from a given range and summing them until they reach a specific predicative, in my case grater or equal to a 120.

I understand the concept of and the difference between the iterators but I’m not quite sure how to use while function. When I use the for loop every thing works. But when I use while loop the result is always zero.

(I know I should attach a image of my patch to make myself more clear but I’m not with my computer)

I appreciate your help!

Sorry , but your explanation is really unclear for me.
Can you give some sort of example ?
Dividing an integer with another is easy , but you seem to want something more subtle…

Best
K

Yes, Karim, sorry for that.
It’s almost like the arithmetic series object. You go from one number to another in a constant step value. I wanted with randomly integer steps. I want to generate different random lists of numbers from 1 to 100 for example.

And it would be nice to have a inlet for the amount of steps. For example: I want to have the number 100 divided I four different values
Evaluation 1 - (30, 60, 9, 1)
Evaluation 2 - (50, 3, 27, 20) etc.

Another inlet to estipulate the maximum and minimum step size. That would be great as well.

I’m trying to do that with while iterator. I guess it would be the best way. But I cant find a solid documentation, with a lot of examples illustrating how to use it. The only thing I could find was the examples from the OM manual and tutorials.

Karim, thank you for your help again! And maybe we should exchange emails so you can give me OM classes from Skype. I really need that!

Yes, Karim, sorry for that.
It’s almost like the arithmetic series object. You go from one number to another in a constant step value. I wanted with randomly integer steps. I want to generate different random lists of numbers from 1 to 100 for example.

And it would be nice to have a inlet for the amount of steps. For example: I want to have the number 100 divided I four different values
Evaluation 1 - (30, 60, 9, 1)
Evaluation 2 - (50, 3, 27, 20) etc.

Another inlet to estipulate the maximum and minimum step size. That would be great as well.

I’m trying to do that with while iterator. I guess it would be the best way. But I cant find a solid documentation, with a lot of examples illustrating how to use it. The only thing I could find was the examples from the OM manual and tutorials.

Karim, thank you for your help again! And maybe we should exchange emails so you can give me OM classes from Skype. I really need that!

Hi,

Sorry for the late response. I have figured out what you want. But i did it in lisp code (easier for me). (so put the file in the patches folder of om).
I don’t know if it is the simplest way to do it but it works. However here you will have maybe repeated integers. I don’t think the while loop function is necessary for your problem.

When you put the file (or load it) you will have the sum-rec function.
use it as (sum-rec 100 4) in order to divide randomly 100 in 4 integers where the sum of these will equal 100

Note : The problem with the non repetition of integers is problematic. Say you want to divide 4 in 4. This will give (1 1 1 1) and not else.
So in order to do the good programing for the non-repetitive ints maybe it should be in a constraint program. I am not sure.

Best
K

divisions.lisp (457 Bytes)