caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Specifying precedence ...
@ 2001-03-14 17:48 Andrzej M. Ostruszka
  2001-03-15  7:43 ` Jacques Garrigue
  0 siblings, 1 reply; 2+ messages in thread
From: Andrzej M. Ostruszka @ 2001-03-14 17:48 UTC (permalink / raw)
  To: Caml List

Hello,

Is it possible to specify precedence of an "operator"?
E.g. if I have something like

let (^^) x y =
  let rec pow res y p =
    if y = 0 then res
    else
      let newres = if y land 1 <> 0 then res * p else res in
      pow newres (y lsr 1) (p*p)
  in
    pow 1 y x

then I'd like to evaluate 2*3^^2 to 18 (not 36).

						Best regards
-- 
    ____   _  ___
   /  | \_/ |/ _ \		Andrzej Marek Ostruszka
  / _ |     | (_) | Instytut Fizyki, Uniwersytet Jagiellonski (Cracow)
 /_/ L|_|V|_|\___/	(PGP <-- finger ostruszk@order.if.uj.edu.pl)
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Specifying precedence ...
  2001-03-14 17:48 [Caml-list] Specifying precedence Andrzej M. Ostruszka
@ 2001-03-15  7:43 ` Jacques Garrigue
  0 siblings, 0 replies; 2+ messages in thread
From: Jacques Garrigue @ 2001-03-15  7:43 UTC (permalink / raw)
  To: ostruszk; +Cc: caml-list

From: "Andrzej M. Ostruszka" <ostruszk@order.if.uj.edu.pl>

> Is it possible to specify precedence of an "operator"?
> E.g. if I have something like
[...]
> then I'd like to evaluate 2*3^^2 to 18 (not 36).

This is section 6.7 of the ocaml 3.00 manual.
User defined operators have a fixed precedence, defined by their first
letter(s).

In this case, only operators starting by ** have higher precedence
than *, so you sould use ** or **...

     Jacques Garrigue
-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-03-15  7:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-03-14 17:48 [Caml-list] Specifying precedence Andrzej M. Ostruszka
2001-03-15  7:43 ` Jacques Garrigue

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).