Re: Prefix operators in ocaml

From: Jun P. Furuse (Jun.Furuse@inria.fr)
Date: Thu Jan 21 1999 - 17:13:52 MET


Message-Id: <199901211613.RAA16052@pernand.inria.fr>
To: caml-list@inria.fr
From: "Jun P. Furuse" <Jun.Furuse@inria.fr>
Date: Thu, 21 Jan 1999 17:13:52 +0100

> Which is the "prefix" name in Ocaml for the multiplication on
> integers? The symbols (+), (/), etc. work fine for the other
> arithmetic operations, but the symbol (*) does not.

You need a small trick. Try ( * ) or ( *).
 
> Similarly, is there any prefix name for the list constructor (a::l) ?
> I am thinking in something like (::) ....

:: is not an infix operator, but an infix constructor. It is handled
specially by the parser. Like the other normal constructors, you
always need its arguments i.e.:

# type 'a option =
    None
  | Some of 'a

# Some;;
The constructor Some expects 1 argument(s),
but is here applied to 0 argument(s)

# fun x -> Some x;;
- : 'a -> 'a option = <fun>

The constructor names themselves are not functions in O'Caml.
 
-----------------------------------------------------------------------
Jun P. Furuse Jun.Furuse@inria.fr
  INRIA
    Institut National de Recherche en Informatique et en Automatique



This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:18 MET