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 OAA05222; Tue, 8 Jan 2002 14:18:42 +0100 (MET) 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 OAA05408 for ; Tue, 8 Jan 2002 14:18:41 +0100 (MET) Received: from rotie.inria.fr (rotie.inria.fr [128.93.11.103]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g08DITr11935; Tue, 8 Jan 2002 14:18:31 +0100 (MET) Received: by rotie.inria.fr (Postfix, from userid 12018) id AD6CC75D74; Tue, 8 Jan 2002 14:18:29 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by rotie.inria.fr (Postfix) with ESMTP id AC72675D73; Tue, 8 Jan 2002 14:18:29 +0100 (CET) Date: Tue, 8 Jan 2002 14:18:29 +0100 (CET) From: Clement Renard X-Sender: clrenard@rotie.inria.fr To: =?iso-8859-1?Q?Jos=E9_Romildo_Malaquias?= Cc: caml-list@inria.fr Subject: Re: [Caml-list] Function definition with multiple patterns in multiple equations In-Reply-To: <20020108110836.A9147@darling.home.br> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tue, 8 Jan 2002, José Romildo Malaquias wrote: > Hello. > > I am trying to define a function in OCaml with multiple equations (rules) > and multiple patterns in each equation. I have tried the 3 forms below, > without success. > > let f 0 0 = 1 > | f _ _ = 0 > > let f = fun 0 0 -> 1 > | _ _ -> 0 > > let f = function 0 0 -> 1 > | _ _ -> 0 > > None of them seems to be supported by the language. In SML, one can write > > fun f 0 0 = 1 > | f _ _ = 0 > > What is the equivalent in OCaml? For example : let f x y = match x,y with 0,0 -> 1 |_,_ -> 0 Clement Renard ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr