digitalmars.D.learn - math evaluation on runtime
- Szabo Bogdan (5/5) Apr 08 2014 Hi,
- Rene Zwanenburg (3/8) Apr 08 2014 Not built in, but Pegged has an example which does exactly that:
- Szabo Bogdan (6/17) Apr 08 2014 Thanks!
- H. S. Teoh (7/11) Apr 08 2014 [...]
Hi, There is any way to evaluate simple math strings like this one: "(1 + 2) * 3" and pass the result? Thanks, Bogdan
Apr 08 2014
On Tuesday, 8 April 2014 at 20:18:43 UTC, Szabo Bogdan wrote:Hi, There is any way to evaluate simple math strings like this one: "(1 + 2) * 3" and pass the result? Thanks, BogdanNot built in, but Pegged has an example which does exactly that: https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/examples/arithmetic.d
Apr 08 2014
Thanks! I was looking for some kind of mixins but at the run time... But this library look interesting. I think i will use something like this. Bogdan On Tuesday, 8 April 2014 at 20:31:55 UTC, Rene Zwanenburg wrote:On Tuesday, 8 April 2014 at 20:18:43 UTC, Szabo Bogdan wrote:Hi, There is any way to evaluate simple math strings like this one: "(1 + 2) * 3" and pass the result? Thanks, BogdanNot built in, but Pegged has an example which does exactly that: https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/examples/arithmetic.d
Apr 08 2014
On Tue, Apr 08, 2014 at 08:18:41PM +0000, Szabo Bogdan wrote:Hi, There is any way to evaluate simple math strings like this one: "(1 + 2) * 3" and pass the result?[...] If you want this at runtime, you'd have to write your own expression parser. At compile-time, you can use a mixin. T -- It said to install Windows 2000 or better, so I installed Linux instead.
Apr 08 2014