From: Diego Olivier Fernandez Pons <Diego-Olivier.FERNANDEZ-PONS@cicrp.jussieu.fr>
To: caml-list@inria.fr
Subject: [Caml-list] égalité physique (==) avec Pervasives.(+)
Date: Mon, 6 Jan 2003 18:58:13 +0100 (NFT) [thread overview]
Message-ID: <Pine.A41.4.44.0301061837320.3793098-100000@ibm1.cicrp.jussieu.fr> (raw)
Bonjour,
Je suis en train de préparer le système de description de contraintes
pour les algorithmes de descente sur les polyhèdres (i.e. simplexe et
variantes locales) que l'on utilise dans les approximations de
problèmes NP-difficiles
J'essaie d'encapsuler le type ['a] dans un type ['a expr]
type 'a expr =
| Constante of 'a
| Variable of int
| Operateur of 'a expr * 'a expr * ('a -> 'a -> 'a)
| Application of 'a expr * ('a -> 'a)
let inj = function x -> Constante x
let inj1 f = function expression ->
match expression with
| Constante v -> Constante f v
| Variable _ | Operateur _ | Application _ ->
Application (expression, f)
let inj2 f = fun x y ->
match (x, y) with
| (Constante s, Constante t) -> Constante (f s t)
| _ -> Operateur (x, y, f)
val inj : 'a -> 'a expr
val inj1 : ('a -> 'a) -> ('a expr -> 'a expr)
val inj2 : ('a -> 'a -> 'a) -> ('a expr -> 'a expr -> 'a expr)
val eval : 'a env -> 'a expr -> 'a
Maintenant je veux traverser la syntaxe abstaite et optimiser le
traitement des opérateurs les plus simples (*, +, /, ...) et pour les
reconnaître j'utilise l'égalité physique (==)
Seulement, les opérateurs Pervasive.qqch ne semblent pas se comporter
comme les fonctions définies par l'utilisateur :
let f = function x -> x + 1
let a = (1, f)
let (_, g) = a
f == g
- : bool = true
let a = (1, (+))
let (_, g) = a
(+) == g
- : bool = false
let a = (1, Pervasives.(+))
let (_, g) = a
Pervasives.(+) == g
- : bool = false
Pourquoi ce comportement ? Comment contourner le problème ?
Diego Olivier
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next reply other threads:[~2003-01-06 17:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-01-06 17:58 Diego Olivier Fernandez Pons [this message]
2003-01-07 14:41 ` Christophe Raffalli
2003-01-08 16:51 ` Florian Hars
2003-01-08 17:34 ` Diego Olivier Fernandez Pons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.A41.4.44.0301061837320.3793098-100000@ibm1.cicrp.jussieu.fr \
--to=diego-olivier.fernandez-pons@cicrp.jussieu.fr \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).