|
There's no operator precedence in SC.
Your _expression_ evaluates like this: ((l < 0) && m_abs) > (l_abs - 1)
Instead:
l < 0 && (m_abs > (l_abs - 1))
Or, better (because it can shortcircuit the second logical test and run it only if needed):
l < 0 and: { m_abs > (l_abs - 1) }
hjh
On May 10, 2009, at 9:07 AM, Michael Dzjaparidze wrote: Hello, I have the following problem I just can't figure out. The code below throws an error and I don't understand why. ( var l, m, l_abs, m_abs, curr, prev, next; curr = prev = next = 1.0; l = 7; m = 5; l_abs = l.abs; m_abs = m.abs; if(l != m_abs, { //if l is negative && absolute value of m > absolute value of l - 1 if(l < 0 && m_abs > (l_abs - 1), { 1.postln; }); //if l is negative && absolute value of l - 1 == m if(l < 0 && (l_abs - 1) == m_abs, { 2.postln; }); //if l is negative and l - 1 > m if(l < 0 && (l_abs - 1) > m_abs, { 3.postln; }); //if l > m && NOT negative if(l > 0, { 4.postln; }); }); ) Logically, I would think that by executing this, it would post 4 in the posting window, but it doesn't... By the way, if I comment out the last if statement and then change l to -7 and m to 7 it DOES print 1, as would be expected. Same holds for l = -7 and m = 6 --> posts 2 and for l = -7 and m smaller than 6 --> posts 3. I also made sure that m can never be negative and can never be greater than l, don't know if that's really relevant here, but just to be sure. If anybody could give me a hint about what I might be doing wrong that would be great.
: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
"Come said the Muse, Sing me a song no poet has yet chanted, Sing me the universal." -- Whitman
|