Re: [Caml-list] How to simplify an arithmetic expression ?

2011-10-02 Thread Gabriel Scherer
> Below is a quick tentative implementation of NbE, on a slightly > restricted expression type (I removed the not-so-interesting Minus > nodes). Sorry, I forgot to give a small example of what the implementation does. Really the obvious thing, but it may not be so obvious just looking at the code.

Re: [Caml-list] How to simplify an arithmetic expression ?

2011-10-02 Thread Xavier Clerc
- Mail original - > De: "Diego Olivier Fernandez Pons" > À: "caml-list" > 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

Re: [Caml-list] How to simplify an arithmetic expression ?

2011-10-02 Thread Gabriel Scherer
On Sun, Oct 2, 2011 at 6:32 PM, Xavier Leroy wrote: > NBE is neat, but I'm skeptical that it will work out of the box here: > if you apply NBE to a standard evaluator for arithmetic expressions, > it's not going to take advantage of associativity and distributivity > the way Diego wants. My idea

Re: [Caml-list] How to simplify an arithmetic expression ?

2011-10-02 Thread Xavier Leroy
On Sun, Oct 2, 2011 at 10:08 AM, Gabriel Scherer wrote: > One approach I like for such simplifications is the "normalization by > evaluation" approach. NBE is neat, but I'm skeptical that it will work out of the box here: if you apply NBE to a standard evaluator for arithmetic expressions, it's no

Re: [Caml-list] ANN: lablgtk-react preview

2011-10-02 Thread Adrien
I forgot to mention that you need lablgtk2's adrien/mix branch for the examples (and only for the examples iirc). There are two reasons. It uses some additional API, especially #as_something methods and "notify::foo" signals. lablwebkit also requires a bug fix that it not merged into master yet.

Re: [Caml-list] How to simplify an arithmetic expression ?

2011-10-02 Thread Ernesto Posse
> On Sun, Oct 2, 2011 at 1:51 PM, Diego Olivier Fernandez Pons > wrote: >>     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 >> let rec simplify = function >>     | Plus (e1, e2)

[Caml-list] ANN: lablgtk-react preview

2011-10-02 Thread Adrien
Hi, I am pleased and relieved to announce lablgtk-react, a project to ease the use of Functional Reactive Programming (FRP) for lablgtk-based graphical user interfaces. Currently, the project is available as a preview but I am happy with the way it is looking and with the programming style it off

Re: [Caml-list] How to simplify an arithmetic expression ?

2011-10-02 Thread Gabriel Scherer
In my experience, the OCaml code doing recursive call and pattern matching is a relatively bad way to reason about such rewrite systems. Your questions are extremely pertinent, and relatively difficult to answer in general. For a start, I think your code indeed repeats useless traversals. This can

[Caml-list] How to simplify an arithmetic expression ?

2011-10-02 Thread Diego Olivier Fernandez Pons
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 let rec simplify = function | Plus (e1, e2) -> match (simplify e1, simplify e2) with | (Constant 0, _) -> e2

Re: [Caml-list] Problem with un-flushed output getting mangled

2011-10-02 Thread Tiphaine Turpin
Le 30/09/2011 02:00, Taylor Venable a écrit : > B. Although I link to Batteries (version 1.4.1) I don't use its IO > layer. If so, then my experience is probably irrelevant. But sometimes with batteries there are "implicit" things. A long time ago I had a problem which looked similar (output seemed