"Luis Manuel O.Soares" wrote:
>
> *This message was transferred with a trial version of CommuniGate(tm) Pro*
> Hello.
>
> I' working on a project at the university of Minho (Portugal), and i would
>like to leave a question to you.
>
> Is there any function that takes a String as an argument and returns a
>numeral??
>
> I would like a function that deals with things pretty much like this one:
> f ("2 + 3 * 2") = 8
>
> Thanks for your time, and i'll be waiting for an answer.
There is no built in function that does what you want. So what you
need to do is write (or obtain) a parser for the expression
language you want. Happy (the Yacc for Haskell) has an expression
parser as one of its examples. Alternatively, you might want to
look at parsing combinators. Look at the built in libs that
come with Hugs, and the www.haskell.org pages for more details.
Are you wanting a specific expression grammar evaluated, or arbitrary
expressions? Hugs does *not* have a reflection mechanism, unfortunately.
Andy Gill