caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Baptiste Rouquier <jrouquiethearchivesshouldaddafewantispamtricks@ens-lyon.fr>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Associativity precedence for the user-defined operator.
Date: Fri, 23 Jul 2004 13:42:01 -0400	[thread overview]
Message-ID: <41014DE9.5020606@ens-lyon.fr> (raw)
In-Reply-To: <Pine.LNX.4.44.0407231614060.12107-100000@strudel.di.unipi.it>



Claudio Trento wrote:

>Hi,
>
>I've defined a set of new operetors, for instance:
>
>let ( /+/ ) = add_num   (where add_num is a function that added two sometype 
>			elements.) 
>
>but I don't know if I can set associativity precedence for this operator,
>writing: el1 ( /+/ ) el2 ( /+/ ) el3 without parenthesis, what happens?
>
The manual says that here you have left associativity. See 
http://caml.inria.fr/ocaml/htmlman/manual015.html.

# let ( /+/ ) a b =
  Printf.printf "a=%i, b=%i\n%!" a b;
  a + b;;
    val ( /+/ ) : int -> int -> int = <fun>
# let _ = 1 /+/ 2 /+/ 39;;
a=1, b=2
a=3, b=39
- : int = 42


Cheers,
Jean-Baptiste.

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


  parent reply	other threads:[~2004-07-23 17:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-23 14:27 Claudio Trento
2004-07-23 14:36 ` Richard Jones
2004-07-23 17:42 ` Jean-Baptiste Rouquier [this message]
2004-07-23 19:52   ` John Prevost

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=41014DE9.5020606@ens-lyon.fr \
    --to=jrouquiethearchivesshouldaddafewantispamtricks@ens-lyon.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).