You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by frank asseg <fr...@congrace.de> on 2011/01/05 20:49:12 UTC
[lang] math expression parser
hola guys,
i am currently working on a math expression parser, and wanted to ask if
there is interest in adding such a functionality to commons-lang?
it's a simple algorithm and id be happy to contribute to this project...
http://projects.congrace.de/exp4j/download.html
have fun!
--
*frank asseg*
softwareentwicklung
sebastian-kneipp-strasse 14a
79104 freiburg i. brsg.
tel.: ++49-761-88790001
fax.: ++49-761-88790002
mail: frank.asseg@congrace.de
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by frank asseg <fr...@congrace.de>.
Hola Paul,
On 05.01.2011 20:51, Paul Libbrecht wrote:
> I don't see why langs would have this, especially since it generally involves variables, scopes, objects, etc.
> Can you compare that to JEXL ?
In comparison to JEXL i was looking for a possiblity to pass a simple
math expression to an evaluator containing some simple functions from
java.lang.Math like Math.sin(double x). An example taking user input
like "2^log(2-3)" and evaluating the result at runtime in a java
application.
I did try using the Scripting engine in Java but firing it up and
evaluating expressions in this way is quite slow. With an unwarmed
javascript engine it took 1sec for 800 evaluations, while the evaluation
using a java implementation was done in 8ms.
I thought this was of interest for commons-lang because i looked in the
lang.math.* package if there was an expression evaluator there.
have fun!
--
*frank asseg*
softwareentwicklung
sebastian-kneipp-strasse 14a
79104 freiburg i. brsg.
tel.: ++49-761-88790001
fax.: ++49-761-88790002
mail: frank.asseg@congrace.de
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by Jason Young <in...@gmail.com>.
While we're at it, I also have a feature complete mathematical parser that
evaluates sets of expressions, variables and functions all at once over an
arbitrary domain. Go to http://zee.dev.java.net and see the code samples.
What do you think?
On Jan 5, 2011 3:18 PM, "frank asseg" <fr...@congrace.de> wrote:
> Hola Ted,
>
> On 05.01.2011 21:02, Ted Dunning wrote:
>> Or bsh or jruby or rhino or groovy?
> sorry, i did not make myself clear but i was talking about a pure
> mathematical expresssion parser, intended for evaluating user input and
> the like, not a turing complete grammer but simply a way to evaluate
> thigs like "log(2)^2.4" at runtime.
>
> Have fun!
>
> --
> *frank asseg*
> softwareentwicklung
> sebastian-kneipp-strasse 14a
> 79104 freiburg i. brsg.
> tel.: ++49-761-88790001
> fax.: ++49-761-88790002
> mail: frank.asseg@congrace.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
Re: [lang] math expression parser
Posted by Ted Dunning <te...@gmail.com>.
These things tend to be a slippery slope. Turing completeness is at the
bottom of that hill.
On Wed, Jan 5, 2011 at 12:18 PM, frank asseg <fr...@congrace.de>wrote:
> Hola Ted,
>
> On 05.01.2011 21:02, Ted Dunning wrote:
> > Or bsh or jruby or rhino or groovy?
> sorry, i did not make myself clear but i was talking about a pure
> mathematical expresssion parser, intended for evaluating user input and
> the like, not a turing complete grammer but simply a way to evaluate
> thigs like "log(2)^2.4" at runtime.
>
> Have fun!
>
> --
> *frank asseg*
> softwareentwicklung
> sebastian-kneipp-strasse 14a
> 79104 freiburg i. brsg.
> tel.: ++49-761-88790001
> fax.: ++49-761-88790002
> mail: frank.asseg@congrace.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [lang] math expression parser
Posted by frank asseg <fr...@congrace.de>.
Hola Paul,
On 05.01.2011 21:49, Paul Libbrecht wrote:
> I find the classname PostfixExpression pretty bizarre... should it be simply MathExpressionParser ?
heh, you got me there, the naming is pretty awkward and stems from the
fact that an infix expression "2 + 2", where the operator stands between
the operands is gets translated into postfix notation ("2 2 +").
But i can see your point and will give the naming of the classes some
more thought.
have fun!
--
*frank asseg*
softwareentwicklung
sebastian-kneipp-strasse 14a
79104 freiburg i. brsg.
tel.: ++49-761-88790001
fax.: ++49-761-88790002
mail: frank.asseg@congrace.de
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by Henri Yandell <fl...@gmail.com>.
Or kick it off at apache-extras.org :)
On Thu, Jan 6, 2011 at 12:17 AM, Paul Libbrecht <pa...@hoplahup.net> wrote:
> Frank,
>
> why not propose this as another project?
> It requires more maintenance, that is true.
> Sandbox is designed for that, including to evaluate if there are user bases.
>
> I tend to feel your contribution is not useless.
> A readable syntax instead of java syntax for formulæ that are rather longer than 3 operations.
> Somewhat in the comfort of using xpath instead of calling getChildren of all sorts.
>
> paul
>
>
> Le 5 janv. 2011 à 22:12, frank asseg a écrit :
>
>> Hola Gary!
>>
>> On 05.01.2011 22:04, Gary Gregory wrote:
>>> Why should this be in [lang] instead of [math]?
>> I actually thought about posting on [math] but when i browsed the math
>> library i gained the impression that it's much more concerned with more
>> complex mathematical issues like integration of numerical analysis
>> rather than parsing user input, so imho i decided to post to [lang], the
>> library which i always associate with Strings ;)
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by Paul Libbrecht <pa...@hoplahup.net>.
Frank,
why not propose this as another project?
It requires more maintenance, that is true.
Sandbox is designed for that, including to evaluate if there are user bases.
I tend to feel your contribution is not useless.
A readable syntax instead of java syntax for formulæ that are rather longer than 3 operations.
Somewhat in the comfort of using xpath instead of calling getChildren of all sorts.
paul
Le 5 janv. 2011 à 22:12, frank asseg a écrit :
> Hola Gary!
>
> On 05.01.2011 22:04, Gary Gregory wrote:
>> Why should this be in [lang] instead of [math]?
> I actually thought about posting on [math] but when i browsed the math
> library i gained the impression that it's much more concerned with more
> complex mathematical issues like integration of numerical analysis
> rather than parsing user input, so imho i decided to post to [lang], the
> library which i always associate with Strings ;)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
RE: [lang] math expression parser
Posted by Gary Gregory <GG...@seagullsoftware.com>.
Bonjour Frank,
I think of [lang] as "what is missing in java.lang", and, to be honest, evaluating math expressions is not on my list ;)
Complex or not I expect math things in [math].
I, as others, am leery of introducing yet another expression language.
Gary Gregory
Senior Software Engineer
Rocket Software
3340 Peachtree Road, Suite 820 • Atlanta, GA 30326 • USA
Tel: +1.404.760.1560
Email: ggregory@seagullsoftware.com
Web: seagull.rocketsoftware.com
> -----Original Message-----
> From: frank asseg [mailto:frank.asseg@congrace.de]
> Sent: Wednesday, January 05, 2011 16:12
> To: Commons Developers List
> Subject: Re: [lang] math expression parser
>
> Hola Gary!
>
> On 05.01.2011 22:04, Gary Gregory wrote:
> > Why should this be in [lang] instead of [math]?
> I actually thought about posting on [math] but when i browsed the math
> library i gained the impression that it's much more concerned with more
> complex mathematical issues like integration of numerical analysis
> rather than parsing user input, so imho i decided to post to [lang], the
> library which i always associate with Strings ;)
>
> have fun!
>
> --
> *frank asseg*
> softwareentwicklung
> sebastian-kneipp-strasse 14a
> 79104 freiburg i. brsg.
> tel.: ++49-761-88790001
> fax.: ++49-761-88790002
> mail: frank.asseg@congrace.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by frank asseg <fr...@congrace.de>.
Hola Gary!
On 05.01.2011 22:04, Gary Gregory wrote:
> Why should this be in [lang] instead of [math]?
I actually thought about posting on [math] but when i browsed the math
library i gained the impression that it's much more concerned with more
complex mathematical issues like integration of numerical analysis
rather than parsing user input, so imho i decided to post to [lang], the
library which i always associate with Strings ;)
have fun!
--
*frank asseg*
softwareentwicklung
sebastian-kneipp-strasse 14a
79104 freiburg i. brsg.
tel.: ++49-761-88790001
fax.: ++49-761-88790002
mail: frank.asseg@congrace.de
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
RE: [lang] math expression parser
Posted by Gary Gregory <GG...@seagullsoftware.com>.
Why should this be in [lang] instead of [math]?
Gary Gregory
Senior Software Engineer
Rocket Software
3340 Peachtree Road, Suite 820 . Atlanta, GA 30326 . USA
Tel: +1.404.760.1560
Email: ggregory@seagullsoftware.com
Web: seagull.rocketsoftware.com
> -----Original Message-----
> From: Paul Libbrecht [mailto:paul@hoplahup.net]
> Sent: Wednesday, January 05, 2011 15:49
> To: Commons Developers List
> Subject: Re: [lang] math expression parser
>
> Well... I never thought about such.... but maybe it's indeed useful.
> Something short and tiny that is a lot more compact than the java syntax for
> math but would have about the same capabilities.
>
> I am not used to commit to lang so we'll have to wait for them to answer.
>
> I find the classname PostfixExpression pretty bizarre... should it be simply
> MathExpressionParser ?
>
> paul
>
>
> Le 5 janv. 2011 à 21:18, frank asseg a écrit :
>
> > Hola Ted,
> >
> > On 05.01.2011 21:02, Ted Dunning wrote:
> >> Or bsh or jruby or rhino or groovy?
> > sorry, i did not make myself clear but i was talking about a pure
> > mathematical expresssion parser, intended for evaluating user input and
> > the like, not a turing complete grammer but simply a way to evaluate
> > thigs like "log(2)^2.4" at runtime.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by Paul Libbrecht <pa...@hoplahup.net>.
Well... I never thought about such.... but maybe it's indeed useful.
Something short and tiny that is a lot more compact than the java syntax for math but would have about the same capabilities.
I am not used to commit to lang so we'll have to wait for them to answer.
I find the classname PostfixExpression pretty bizarre... should it be simply MathExpressionParser ?
paul
Le 5 janv. 2011 à 21:18, frank asseg a écrit :
> Hola Ted,
>
> On 05.01.2011 21:02, Ted Dunning wrote:
>> Or bsh or jruby or rhino or groovy?
> sorry, i did not make myself clear but i was talking about a pure
> mathematical expresssion parser, intended for evaluating user input and
> the like, not a turing complete grammer but simply a way to evaluate
> thigs like "log(2)^2.4" at runtime.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by Gary Gregory <GG...@seagullsoftware.com>.
On Jan 5, 2011, at 18:05, "Stephen Colebourne" <sc...@joda.org> wrote:
> I would recommend against this for [lang].
>
> [lang] is a low-level project intended to have no framework or
> "religious" aspects, just simple relatively non-controversial elements
> that assist the basic Java packages. A maths parser, however useful,
> isn't that closely related IMO.
+1
Gary
>
> Stephen
>
>
> On 5 January 2011 20:18, frank asseg <fr...@congrace.de> wrote:
>> Hola Ted,
>>
>> On 05.01.2011 21:02, Ted Dunning wrote:
>>> Or bsh or jruby or rhino or groovy?
>> sorry, i did not make myself clear but i was talking about a pure
>> mathematical expresssion parser, intended for evaluating user input and
>> the like, not a turing complete grammer but simply a way to evaluate
>> thigs like "log(2)^2.4" at runtime.
>>
>> Have fun!
>>
>> --
>> *frank asseg*
>> softwareentwicklung
>> sebastian-kneipp-strasse 14a
>> 79104 freiburg i. brsg.
>> tel.: ++49-761-88790001
>> fax.: ++49-761-88790002
>> mail: frank.asseg@congrace.de
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by Stephen Colebourne <sc...@joda.org>.
I would recommend against this for [lang].
[lang] is a low-level project intended to have no framework or
"religious" aspects, just simple relatively non-controversial elements
that assist the basic Java packages. A maths parser, however useful,
isn't that closely related IMO.
Stephen
On 5 January 2011 20:18, frank asseg <fr...@congrace.de> wrote:
> Hola Ted,
>
> On 05.01.2011 21:02, Ted Dunning wrote:
>> Or bsh or jruby or rhino or groovy?
> sorry, i did not make myself clear but i was talking about a pure
> mathematical expresssion parser, intended for evaluating user input and
> the like, not a turing complete grammer but simply a way to evaluate
> thigs like "log(2)^2.4" at runtime.
>
> Have fun!
>
> --
> *frank asseg*
> softwareentwicklung
> sebastian-kneipp-strasse 14a
> 79104 freiburg i. brsg.
> tel.: ++49-761-88790001
> fax.: ++49-761-88790002
> mail: frank.asseg@congrace.de
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by frank asseg <fr...@congrace.de>.
Hola Ted,
On 05.01.2011 21:02, Ted Dunning wrote:
> Or bsh or jruby or rhino or groovy?
sorry, i did not make myself clear but i was talking about a pure
mathematical expresssion parser, intended for evaluating user input and
the like, not a turing complete grammer but simply a way to evaluate
thigs like "log(2)^2.4" at runtime.
Have fun!
--
*frank asseg*
softwareentwicklung
sebastian-kneipp-strasse 14a
79104 freiburg i. brsg.
tel.: ++49-761-88790001
fax.: ++49-761-88790002
mail: frank.asseg@congrace.de
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: [lang] math expression parser
Posted by Ted Dunning <te...@gmail.com>.
Or bsh or jruby or rhino or groovy?
Why yet another?
On Wed, Jan 5, 2011 at 11:51 AM, Paul Libbrecht <pa...@hoplahup.net> wrote:
> Frank,
>
> I don't see why langs would have this, especially since it generally
> involves variables, scopes, objects, etc.
> Can you compare that to JEXL ?
>
> paul
>
>
> Le 5 janv. 2011 à 20:49, frank asseg a écrit :
>
> > hola guys,
> >
> > i am currently working on a math expression parser, and wanted to ask if
> > there is interest in adding such a functionality to commons-lang?
> >
> > it's a simple algorithm and id be happy to contribute to this project...
> > http://projects.congrace.de/exp4j/download.html
> >
> > have fun!
> > --
> > *frank asseg*
> > softwareentwicklung
> > sebastian-kneipp-strasse 14a
> > 79104 freiburg i. brsg.
> > tel.: ++49-761-88790001
> > fax.: ++49-761-88790002
> > mail: frank.asseg@congrace.de
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>
Re: [lang] math expression parser
Posted by Paul Libbrecht <pa...@hoplahup.net>.
Frank,
I don't see why langs would have this, especially since it generally involves variables, scopes, objects, etc.
Can you compare that to JEXL ?
paul
Le 5 janv. 2011 à 20:49, frank asseg a écrit :
> hola guys,
>
> i am currently working on a math expression parser, and wanted to ask if
> there is interest in adding such a functionality to commons-lang?
>
> it's a simple algorithm and id be happy to contribute to this project...
> http://projects.congrace.de/exp4j/download.html
>
> have fun!
> --
> *frank asseg*
> softwareentwicklung
> sebastian-kneipp-strasse 14a
> 79104 freiburg i. brsg.
> tel.: ++49-761-88790001
> fax.: ++49-761-88790002
> mail: frank.asseg@congrace.de
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org