Would anyone mind sending a good example for loop "until" ? I simply want a shred to stop automatically after a 10 seconds. Here is what I wrote: do{ Std.rand2f(200,50.0) + Math.sin(v*100.0)*20.0 => v2 => f.pfreq; Std.rand2f(5000.0, 60) + Math.sin(v*30.0)*80.0 => f3.pfreq; Std.rand2f(1500, 80.0) + Math.sin(v*200.0)*50.0 => f2.pfreq; std.rand2f(.551,.549)=>buf.rate; .0+(.9*maybe)=>buf.gain; 0=>buf.pos; .1:: T =>now; } until (5::second); thanks so much! -tim
you need the following:
now => time then;
do { ...
} until (then < (now - 10::second));
also, I'm not sure that "do..until" is a functioning construct. It may
just be a keyword in the miniAudicle, maybe a scrap from its
Java-based highlighting (right? java?)
-Andrew
2010/9/23 Timothy Leonido
Would anyone mind sending a good example for loop "until" ? I simply want a shred to stop automatically after a 10 seconds. Here is what I wrote:
do{
Std.rand2f(200,50.0) + Math.sin(v*100.0)*20.0 => v2 => f.pfreq;
Std.rand2f(5000.0, 60) + Math.sin(v*30.0)*80.0 => f3.pfreq;
Std.rand2f(1500, 80.0) + Math.sin(v*200.0)*50.0 => f2.pfreq;
std.rand2f(.551,.549)=>buf.rate;
.0+(.9*maybe)=>buf.gain;
0=>buf.pos;
.1:: T =>now; } until (5::second);
thanks so much!
-tim
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
It appears as a reserved keyword here
http://chuck.cs.princeton.edu/doc/language/overview.html#reserve
2010/9/23 Andrew C. Smith
you need the following:
now => time then;
do { ... } until (then < (now - 10::second));
also, I'm not sure that "do..until" is a functioning construct. It may just be a keyword in the miniAudicle, maybe a scrap from its Java-based highlighting (right? java?)
-Andrew
2010/9/23 Timothy Leonido
: Would anyone mind sending a good example for loop "until" ? I simply want a shred to stop automatically after a 10 seconds. Here is what I wrote:
do{
Std.rand2f(200,50.0) + Math.sin(v*100.0)*20.0 => v2 => f.pfreq;
Std.rand2f(5000.0, 60) + Math.sin(v*30.0)*80.0 => f3.pfreq;
Std.rand2f(1500, 80.0) + Math.sin(v*200.0)*50.0 => f2.pfreq;
std.rand2f(.551,.549)=>buf.rate;
.0+(.9*maybe)=>buf.gain;
0=>buf.pos;
.1:: T =>now; } until (5::second);
thanks so much!
-tim
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
-- http://www.twitter.com/lfzawacki http://www.linesocode.wordpress.com http://www.umblag.wordpress.com
On 24 September 2010 01:16, Lucas Zawacki
It appears as a reserved keyword here http://chuck.cs.princeton.edu/doc/language/overview.html#reserve
Also; until ( foo )
sorry; odd keyboard shortcuts in Chromium until (foo) { do.stuff() } is equivalent to while (! foo) { do.stuff() } hope that helps, Kas.
Yeah, I guess one thing we didn't really mention is that the argument
has to be a true/false value. until(5::second) won't work because
5::second will not evaluate to true nor false. I think that's the main
misconception.
-Andrew
2010/9/23 Kassen
sorry; odd keyboard shortcuts in Chromium until (foo) { do.stuff() } is equivalent to while (! foo) { do.stuff() } hope that helps, Kas. _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On Fri, Sep 24, 2010 at 8:37 AM, Andrew C. Smith
Yeah, I guess one thing we didn't really mention is that the argument has to be a true/false value. until(5::second) won't work because 5::second will not evaluate to true nor false. I think that's the main misconception.
Is that true? This works how I'd think it should: until(5::second) { <<< "won't happen" >>>; } do { <<< "hi" >>>; second => now; } until(5::second); while(5::second) { <<< "bye" >>>; second => now; } -- Tom Lieber http://AllTom.com/ http://favmusic.net/
Hi Folks,
I've always done this:
now + 10::second => time later;
while (now < later) {
// do stuff...
}
since, "time < time" resolves to either true or false, then the while()
construct will work.
Mike
On Fri, Sep 24, 2010 at 1:57 PM, Tom Lieber
On Fri, Sep 24, 2010 at 8:37 AM, Andrew C. Smith
wrote: Yeah, I guess one thing we didn't really mention is that the argument has to be a true/false value. until(5::second) won't work because 5::second will not evaluate to true nor false. I think that's the main misconception.
Is that true? This works how I'd think it should:
until(5::second) { <<< "won't happen" >>>; }
do { <<< "hi" >>>; second => now; } until(5::second);
while(5::second) { <<< "bye" >>>; second => now; }
-- Tom Lieber http://AllTom.com/ http://favmusic.net/ _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
On 28 September 2010 00:27, Daniel Trueman
i just wish you could do until an Event... of course, there are other ways...
There is of course the option to extend Event, to also hold a truth value. What this won't do is set the value as .send() or .broadcast() is called, but we can make our own .transmit() that would set the value as well as call .send() or .broadcast(). I find Event nearly always needs to be extended or encapsulated, but that's fine; it's about as versatile as Envelope and about as useful on it's own. To return for a moment to truth values as well; time and duration type variables or constants will evaluate to "true" when they are non-zero. This means that "if(now)" is a useful way of checking whether the VM is currently starting. However; && and || aren't overloaded to deal with this kind of stuff, only the "top level" evaluations like "if", "while" and "until" are. I still hold that to be a inconsistency that needs some care. Nothing new here but I thought I'd go over the useful tricks and trivia, Kas.
participants (7)
-
Andrew C. Smith
-
Daniel Trueman
-
Kassen
-
Lucas Zawacki
-
mike clemow
-
Timothy Leonido
-
Tom Lieber