[chuck] (no subject)

Mikael Johansson mikael at johanssons.org
Thu Feb 17 02:51:43 EST 2005


On Wed, 16 Feb 2005, Adam R. Tindale wrote:
> Hi All,
>
> When you do division on two durs a float is returned. When you divide a dur 
> by a float you get a dur as well.
>
> There are some examples on the reserved words page on the docs site.
>
> Here is how you can divide two durs to make a new dur.
>
> 10::second => dur a;
> 5::second => dur b;
> a/b => float g;
> g::second => dur newdur;
>
> Doing
>
> a/b::second => dur q;
>
> gives a parse error however.
>

Have you tried (a/b)::second => dur q; ? I've noticed that the parser is 
VERY nitpicking on arithmetic before the ::....

> This works nicely though.
>
> 10::second => dur a;
> a/2. => dur b;
>
> Hope that helps.
>
> art
>
> On Feb 16, 2005, at 3:11 PM, Philip Davidson wrote:
>
>> Micheal,
>> 
>> math on durs is supported, but not completely
>> ( some revision to dur handing is needed )
>> 
>> dur * float => dur ;  should work.
>> not sure about float * dur => dur;
>> I don't believe that division is properly supported.
>> 
>> this code would work
>> --
>> 1::second => dur beat;
>> beat * 0.5 => dur h;
>> -or-
>> beat * 0.5 => now;
>> --
>> 
>> 
>> where it stands for now...
>> 
>> Phil
>> 
>> 
>> 
>> On Feb 16, 2005, at 5:43 PM, Michael Heuer wrote:
>> 
>>> Hello ChucKers,
>>> 
>>> Is there any way to go from an int or float value of a variable to a
>>> duration? e.g.
>>> 
>>> 1 => int value;
>>> value::second => dur some_unknown_number_of_seconds;
>>> 
>>> What I'm really trying to do is math with durations and numbers,
>>> 
>>> 1::second => dur w;
>>> (w / 2) => dur h;
>>> 
>>> Thank you,
>>> 
>>>    michael
>>> 
>>> _______________________________________________
>>> chuck mailing list
>>> chuck at lists.cs.princeton.edu
>>> https://lists.cs.princeton.edu/mailman/listinfo/chuck
>> 
>> _______________________________________________
>> chuck mailing list
>> chuck at lists.cs.princeton.edu
>> https://lists.cs.princeton.edu/mailman/listinfo/chuck
>> 
>
>
> _______________________________________________
> chuck mailing list
> chuck at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck
>

-- 
Mikael Johansson                 | To see the world in a grain of sand
mikael at johanssons.org            |  And heaven in a wild flower
http://www.mikael.johanssons.org | To hold infinity in the palm of your hand
                                  |  And eternity for an hour


More information about the chuck mailing list