De: "Diego Olivier Fernandez Pons" <dofp.ocaml@gmail.com>
À: "caml-list" <caml-list@inria.fr>
Envoyé: Dimanche 2 Octobre 2011 13:51:13
Objet: [Caml-list] How to simplify an arithmetic expression ?
OCaml list,
It's easy to encapsulate a couple of arithmetic simplifications into a function that applies them bottom up to an expression represented as a tree
Not absolutely sure it will fit your needs, but it will at least advertise a nice tool...
The "moca" preprocessor allows you to add properties to constructors of a sum type
(e. g. associativity, commutativity, etc.).
Example from the webpage (*):
type t = private
| Zero
| One
| Opp of t
| Add of t * t
begin
associative
commutative
neutral (Zero)
opposite (Opp)
end
;;
Regards,
Xavier Clerc
(*) http://moca.inria.fr/eng.htm