< Back to IRCAM Forum

Integer to whole number

Hi,
Im a beginner on OpenMusic, and i don’t know how to do this operation

OMLoop input 1: list
output 1: list2
2: variable

If the list is only composed by whole numbers, then : output1 = list; output2 = 1
If not, multiply the list by 12 → now if the list is only composed by whole numbers, then : output1 = list2; output2 = 2
If not, multiply the list by 123 → now if the list is only composed by whole numbers, then : output1 = list23; output2 = 23
If not, multiply the list by 1
234 → now if the list is only composed by whole numbers, then : output1 = list23; output2 = 234
Etc… until the list is only composed by whole numbers

Thanks in advance

Hi

I guess if you have pi or an irrational complex number you can multiply endlessly ?

Can you give a concrete example ?

Best
K

Hi;
In fact it’s beacuse the CIRCLE classes can’t handle non-whole numbers
So I wanted convert my list into a list of whole numbers, keep their relations and even convert my list again after
So it was like:

List: 1 1/3 1 1/3 1 1/3
Whole? No → multiplication by 2

List 2 2/3 2 2/3 2 2/3
Whole? No → multiplication by 3

List 6 2 6 2 6 2

Whole? Yes→ output the last list and 3 as 2nd output

Finally I found another way to do my patch, even if it’s dont use this
Anyway thanks :slight_smile:

Hi J

Just for the record this is how your algo is done in OM . But beware it could run in a stack overflow if there’s no solution. And I must confess it is not a beginner’s patch. These things are easily done in lisp code.

Best

K

whole_num-2.omp (4.66 KB)