DDMathParser icon indicating copy to clipboard operation
DDMathParser copied to clipboard

Pure left-to-right evaluation

Open horaceho opened this issue 12 years ago • 6 comments

How to make + − the same precedence as x ÷ ?

Such that 3+5x2=13 becomes 3+5x2=16

horaceho avatar Jan 28 '13 04:01 horaceho

Well, you could edit the code in _DDMathOperatorInfo.m to make the operators have the same precedence, but that would only get you half-way there. What you're really asking for is for things to be always evaluated left-to-right, regardless of precedence. That would require significant work. However, I recognize that when it comes to writing a calculator app, left-to-right evaluation often feels "more natural", so I'll see if I can get around to doing this.

davedelong avatar Jan 28 '13 05:01 davedelong

This could be accomplished by writing a custom Expressionizer (the thing that turns GroupedTokens into Expressions).

davedelong avatar Sep 19 '15 15:09 davedelong

I'm looking to be able to toggle precedence at runtime. Could you provide an example (or link) to how this would be done using a custom Expressionizer (in Objective-C)?

joshdistler avatar Jan 02 '16 05:01 joshdistler

Hi Dave. Just wondering if you've gotten a chance to add this (to the Obj-C version)?

joshdistler avatar May 21 '16 17:05 joshdistler

I've been evaluating the Swift (3) branch recently. Any movement on this there (I assume you're no longer updating Obj-C as actively)?

joshdistler avatar Jul 31 '16 06:07 joshdistler

@davedelong Hey Dave. Getting back on my project and hoping this is still in the cards?

joshdistler avatar Dec 17 '16 05:12 joshdistler