From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA19181; Tue, 6 Jul 2004 00:04:43 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA19638 for ; Tue, 6 Jul 2004 00:04:42 +0200 (MET DST) Received: from ptb-relay02.plus.net (ptb-relay02.plus.net [212.159.14.213]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i65M4fSH028754 for ; Tue, 6 Jul 2004 00:04:41 +0200 Received: from [80.229.56.224] (helo=chetara) by ptb-relay02.plus.net with esmtp (Exim) id 1BhbZp-0006iD-7R for caml-list@inria.fr; Mon, 05 Jul 2004 22:04:41 +0000 From: Jon Harrop To: caml-list@inria.fr Subject: Re: [Caml-list] Infix operator Date: Mon, 5 Jul 2004 23:02:31 +0100 User-Agent: KMail/1.6.2 References: <20040705213048.87011.qmail@web51604.mail.yahoo.com> In-Reply-To: <20040705213048.87011.qmail@web51604.mail.yahoo.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200407052302.31376.postmaster@jdh30.plus.com> X-Miltered: at concorde with ID 40E9D079.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; postmaster:99 caml-list:01 2004:99 val:01 ocaml:01 caml:01 caml:01 int:01 int:01 syntax:02 wrote:03 infix:03 infix:03 let:04 functions:05 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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 = # (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