Tuesday, 15 May 2012

ios - Swift string formula into a real calculation -


I have several sources, such as in a picture like A * B. I am trying to understand how I can take it. The formula is currently stored in a plaster as a string and uses it as a real calculation formula. I tried to form the formula for (a) * (b) and then tried to establish A and B before trying to use the formula but it was not working. any suggestion?

example

  let's do a = 5 b = 2 printlen (formula)  

actually printed "\ (a) * \

> extension string {var expression: NSE expression {return NSE expression (format: self)}} let's give a = 5 b = 2 intDictionary = ["a": a, "b": b] var Formula = "A * B" if time, Result = Formula Expression Expression value (with: introct, contact: blue)? Int {print (timesResult) // 10} formula = "(a + b) / 2" if intAvgResult = formula.expression.expressionValue (with: intDictionary, context: zero)? Int {print (intAvgResult) // 3} Let x = 5.0 give commands = "two" Y + z) / 3 "if binary processing = formula expression.expression value (with: double-extension, reference: zero) Double? {Print (doubleavargelt)}

No comments:

Post a Comment