[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jon Harrop <postmaster@j...> |
| Subject: | Re: [Caml-list] Infix operator |
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