wesg macrumors regular Original poster Jan 2, 2008 211 0 Toronto, ON Sep 28, 2010 #1 Has anyone had success turning strings into equations? ie. take a stored string of 2*5+6 and output 16
Has anyone had success turning strings into equations? ie. take a stored string of 2*5+6 and output 16
(marc) macrumors 6502a Sep 15, 2010 724 2 the woods Sep 29, 2010 #2 You'll have to write a parser. EDIT: This might not be trivial. I googled "c equation parser" and found this.
You'll have to write a parser. EDIT: This might not be trivial. I googled "c equation parser" and found this.
dejo Moderator emeritus Sep 2, 2004 15,982 454 The Centennial State Sep 29, 2010 #3 Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7) Perhaps you can use JavaScript's eval() function.
Wirelessly posted (Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7) Perhaps you can use JavaScript's eval() function.
PhoneyDeveloper macrumors 68040 Sep 2, 2008 3,114 93 Sep 29, 2010 #4 This has been an assignment in CS courses since 1962. I think you'll be able to find some source code online. expression evaluation code http://www.google.com/search?q=expression+evaluation+code&hl=en&num=100&lr=&ft=i&cr=&safe=off
This has been an assignment in CS courses since 1962. I think you'll be able to find some source code online. expression evaluation code http://www.google.com/search?q=expression+evaluation+code&hl=en&num=100&lr=&ft=i&cr=&safe=off
wesg macrumors regular Original poster Jan 2, 2008 211 0 Toronto, ON Sep 29, 2010 #5 Thanks for all the suggestions. I'm going to look into storing them as actual values... we'll see how it goes.
Thanks for all the suggestions. I'm going to look into storing them as actual values... we'll see how it goes.