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.

[BEGINNER HELP] Integer to whole number

Author 2 Subscribed Users |
Profile photo of JKristoph
JKristoph

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 1*2 → now if the list is only composed by whole numbers, then : output1 = list*2; output2 = 2
If not, multiply the list by 1*2*3 → now if the list is only composed by whole numbers, then : output1 = list*2*3; output2 = 2*3
If not, multiply the list by 1*2*3*4 → now if the list is only composed by whole numbers, then : output1 = list*2*3; output2 = 2*3*4
Etc…. until the list is only composed by whole numbers

Thanks in advance

October 26, 2017 at 15:44 #24149
Profile photo of Karim
Karim

Hi

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

Can you give a concrete example ?

Best
K

October 27, 2017 at 17:23 #24151
Profile photo of JKristoph
JKristoph

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

October 28, 2017 at 17:03 #24152
Profile photo of JKristoph
JKristoph

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

October 28, 2017 at 19:24 #24153
Profile photo of Karim
Karim

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

October 29, 2017 at 13:35 #24156

You must be logged in to reply to this topic.

Log in now