Hi all-
Running into a little confusion here, I was hoping someone could help.
I’ve created a function to take a “starting number”. If the starting number drops below 2, it is reassigned a value of 20. There is also a random function, depending on the outcome it will subtract either a 1 or a 2 from the starting number, with each iteration.
Now, obviously, if I start calling on this function with a start number, it never accumulates the changes.
~func.(10);
I could change all of the variables in ~func, so that they were global variables - and that would potentially fix the issue… but then, the function would no longer be flexible to be used in multiple instances.
I’m curious how a problem like this is dealt with in SuperCollider. My apologies if I haven’t explained it well. I can try to fill in some of the details as necessary.
It looks like you want to make a function that you can call many times and get a different value out? That isn’t best achieved with a function, but with a routine (or something else).
Well, I was hoping to use it as a function, since I’m using it with the Pattern language… but there is maybe an easy way to wrap it into a Prout, so I will dig around and see what I can come up with. Thanks!
Out of curiosity, if I were dealing with an array in this situation, as opposed to a single number - would there be a way to take the array returned by Prout and apply it to something like a Prand?