Talk:Operator precedence

From Rosetta Code
Revision as of 20:12, 24 September 2012 by rosettacode>Paddy3118 (→‎maybe a little more specific?: A link plus example.)

maybe a little more specific?

What does "associate from left to right" mean?

When I look at

((a + b) + c)

or

(a + (b + c))

I could implement either of them by associating from left to right. In the first case, I would be doing bottom-up association, in the second case I would be doing top-down association. --Rdm 18:20, 24 September 2012 (UTC)

From here, given the expression without parenthesis of a + b + c then if '+' is left associative it should be evaluated as (a + b) + c, which I think is what was meant by "associate from left to right". You can add brackets to make the evaluation order explicit, the associativity is used when you don't. --Paddy3118 20:12, 24 September 2012 (UTC)