[Haskell-cafe] How to "Show" an Operation?
ozgurakgun at gmail.com
Fri Jun 4 11:51:07 EDT 2010
One way woul be to represent them usnig a data structure. If it's only
artihmetic operations, it should be pretty easy.
data Arith = Var String
| Plus Artih Arith
| Mult Arith Arith
| Pow Arith Arith
x + y would be Plus (Var "x") (Var "y"), so on so forth..
You can even use infix constructors like :+:, :*:, :^:
On 4 June 2010 16:37, Martin Drautzburg <Martin.Drautzburg at web.de> wrote:
> Dear all,
> If I have a problem where I have to select from a set of operations, how
> I print the result?
> Example: If I can chose from (x+y), (x*y), (x^2+y)...
> and I feed them all into my problem solver
> and it finds that "(x*y) is right", how can I print that string?
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe