Re: Py 2.6b Update
- Posted by Matthew Lewis <MatthewL at KAPCOUSA.COM> Dec 01, 2000
- 420 views
> From: David Cuny > ? 5-3+2 > in Py, you get 0 instead of 4. I always seem to have trouble with this > left/right associativity business. <nitpick> I'd call this a distributive problem: distributive: ? 5-1*(3+2) instead of ? 5+1*(-3+2) associative: ? (5-3)+2 ? 5+(-3+2) </nitpick> Dealing with subtraction (esp symbolically) can be a pain: -- It's not commutative. -- Do you treat subtraction as adding a negative number? -- Subtracting a positive? -- What if there's a variable in the expression? -- What if you're just looking for a negative number ( '? -1' ). I had lot's of errors writing Matheval (see the archives :), and eventually hacked the parser enough to treat negative/minus signs somewhat consistently. Matt Lewis http://www.realftp.com/matthewlewis