From: Jon Harrop <postmaster@jdh30.plus.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Infix operator
Date: Mon, 5 Jul 2004 23:02:31 +0100 [thread overview]
Message-ID: <200407052302.31376.postmaster@jdh30.plus.com> (raw)
In-Reply-To: <20040705213048.87011.qmail@web51604.mail.yahoo.com>
On Monday 05 July 2004 22:30, you wrote:
> Hi all,
> Is there any way to define infix operators in
> OCaml?
Yes. This is described in the excellent book "Developing applications with
objective Caml" in the "Functional core of Objective CAML" chapter, on page
25 under the heading "Declaration of infix functions". This book is freely
available in electronic form here:
http://caml.inria.fr/oreilly-book/html/index.html
Basically, use only symbols in infix function names and define the function
using the syntax:
# let ( ++ ) c1 c2 = (fst c1)+(fst c2), (snd c1)+(snd c2);;
val ( ++ ) : int * int -> int * int -> int * int = <fun>
# (2, 3) ++ (3, 4);;
- : int * int = (5, 7)
Cheers,
Jon.
-------------------
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 prev parent reply other threads:[~2004-07-05 22:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-05 21:30 Alexsandro Soares
2004-07-05 22:02 ` Jon Harrop [this message]
2004-07-05 22:08 ` Richard Jones
2004-07-05 23:01 ` Benjamin Geer
2004-07-06 4:59 ` skaller
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=200407052302.31376.postmaster@jdh30.plus.com \
--to=postmaster@jdh30.plus.com \
--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