Swift - conversion of string to expression -


i working on application in simple mathematical expressions passed around strings (for example "2+3"). need execute these expressions make sure equal target.

in mathematica / wolfram language, 1 can convert strings expressions simple command toexpression[]. there equivalent in swift? if not, how might 1 convert string workable math?

use [nsexpression][1], this...

let expression = nsexpression(format:"2+3") if let result = expression.expressionvaluewithobject(nil, context: nil) as? nsnumber {   print(result) } else {   print("error evaluating expression") } 

here's blog post nshipster on using nsexpression (includes swift examples).


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

excel - I can't get the attachement of the email PHP -

node.js - Express and Redis - If session exists for this user, don't allow access -