[Haskell-beginners] Data structure for Propositional Logic formulas
Christian Maeder
Christian.Maeder at dfki.de
Thu Oct 13 11:12:10 CEST 2011
Am 12.10.2011 23:24, schrieb Benedict Eastaugh:
> Hi Alex,
>
> since Daniel has done a nice job of actually answering your questions,
> I shall just note that I have a module similar to this available on
> Hackage as part of my hatt package, which generates truth tables for
> formulae in classical propositional logic.
>
> http://hackage.haskell.org/package/hatt
> http://hackage.haskell.org/packages/archive/hatt/1.3.0/doc/html/Data-Logic-Propositional.html
Why do most people like duplicate or repeated code?
Instead of
data Expr = Variable String
| Negation Expr
| Conjunction Expr Expr
| Disjunction Expr Expr
| Conditional Expr Expr
| Biconditional Expr Expr
you are usually better served by:
data Expr = Variable String
| Negation Expr
| Junct BinOp Expr Expr
data BinOp = Conjunction | Disjunction | Conditional | Biconditional
Cheers Christian
>
> Benedict
>
More information about the Beginners
mailing list